diff --git a/ui/hv2-ui/package.json b/ui/hv2-ui/package.json index 87b68fa..58153b2 100644 --- a/ui/hv2-ui/package.json +++ b/ui/hv2-ui/package.json @@ -9,7 +9,6 @@ "lint": "ng lint", "e2e": "ng e2e", "generate": "python ../helpers/hv2-api/generate.py -s ../helpers/hv2-api/schema.json -t ./src/app/*.tmpl" - }, "private": true, "dependencies": { diff --git a/ui/hv2-ui/src/app/app-routing.module.ts b/ui/hv2-ui/src/app/app-routing.module.ts index d85ec66..76801a5 100644 --- a/ui/hv2-ui/src/app/app-routing.module.ts +++ b/ui/hv2-ui/src/app/app-routing.module.ts @@ -3,12 +3,19 @@ import { RouterModule, Routes } from '@angular/router'; import { AuthGuardService } from './auth-guard.service'; import { LoginComponent } from './login/login.component'; import { LogoutComponent } from './logout/logout.component'; -import { TestOutputComponent } from './test-output/test-output.component'; - +import { MyTenantsComponent } from './my-tenants/my-tenants.component'; +import { MyPremisesComponent } from './my-premises/my-premises.component'; +import { MyFlatsComponent } from './my-flats/my-flats.component'; +import { MyParkingsComponent } from './my-parkings/my-parkings.component'; +import { MyCommercialUnitsComponent } from './my-commercial-units/my-commercial-units.component'; const routes: Routes = [ - { path: 'test', component: TestOutputComponent, canActivate: [ AuthGuardService ] }, + { path: 'tenants', component: MyTenantsComponent, canActivate: [ AuthGuardService ] }, + { path: 'premises', component: MyPremisesComponent, canActivate: [ AuthGuardService ] }, + { path: 'flats', component: MyFlatsComponent, canActivate: [ AuthGuardService ] }, + { path: 'parkings', component: MyParkingsComponent, canActivate: [ AuthGuardService ] }, + { path: 'commercialunits', component: MyCommercialUnitsComponent, canActivate: [ AuthGuardService ] }, { path: 'logout', component: LogoutComponent }, { path: 'login', component: LoginComponent } ] diff --git a/ui/hv2-ui/src/app/app.module.ts b/ui/hv2-ui/src/app/app.module.ts index d9c876c..b269b29 100644 --- a/ui/hv2-ui/src/app/app.module.ts +++ b/ui/hv2-ui/src/app/app.module.ts @@ -22,6 +22,11 @@ import { LoginComponent } from './login/login.component'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatInputModule } from '@angular/material/input'; import { MyTenantsComponent } from './my-tenants/my-tenants.component'; +import { MatTableModule } from '@angular/material/table'; +import { MyPremisesComponent } from './my-premises/my-premises.component'; +import { MyFlatsComponent } from './my-flats/my-flats.component'; +import { MyParkingsComponent } from './my-parkings/my-parkings.component'; +import { MyCommercialUnitsComponent } from './my-commercial-units/my-commercial-units.component'; @NgModule({ @@ -32,7 +37,11 @@ import { MyTenantsComponent } from './my-tenants/my-tenants.component'; TestOutputComponent, LogoutComponent, LoginComponent, - MyTenantsComponent + MyTenantsComponent, + MyPremisesComponent, + MyFlatsComponent, + MyParkingsComponent, + MyCommercialUnitsComponent ], imports: [ BrowserModule, @@ -48,6 +57,7 @@ import { MyTenantsComponent } from './my-tenants/my-tenants.component'; AppRoutingModule, FormsModule, ReactiveFormsModule, + MatTableModule, MatInputModule ], providers: [ diff --git a/ui/hv2-ui/src/app/auth-handler.interceptor.ts b/ui/hv2-ui/src/app/auth-handler.interceptor.ts index 080cf53..396812c 100644 --- a/ui/hv2-ui/src/app/auth-handler.interceptor.ts +++ b/ui/hv2-ui/src/app/auth-handler.interceptor.ts @@ -8,6 +8,8 @@ import { import { Observable } from 'rxjs'; import { MessageService } from './message.service'; import { TokenService } from './token.service'; +import { serviceBaseUrl } from './config'; + @Injectable() export class AuthHandlerInterceptor implements HttpInterceptor { @@ -16,7 +18,7 @@ export class AuthHandlerInterceptor implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler): Observable> { const token = localStorage.getItem(TokenService.Id_Token_Key) - if (request.url.includes('api.hv.nober.de') && token) { + if (request.url.includes(serviceBaseUrl) && token) { const clone = request.clone({ setHeaders: { Authorization: `Bearer ${token}`} }) diff --git a/ui/hv2-ui/src/app/config.ts b/ui/hv2-ui/src/app/config.ts index 65c4d0e..783dc89 100644 --- a/ui/hv2-ui/src/app/config.ts +++ b/ui/hv2-ui/src/app/config.ts @@ -1,2 +1,4 @@ -export const serviceBaseUrl = "https://api.hv.nober.de"; +// export const serviceBaseUrl = "https://api.hv.nober.de"; // export const serviceBaseUrl = "http://172.16.10.38:5000"; +export const serviceBaseUrl = "http://localhost:8080"; + diff --git a/ui/hv2-ui/src/app/data-object-service.ts b/ui/hv2-ui/src/app/data-object-service.ts index 33e4646..387ba49 100644 --- a/ui/hv2-ui/src/app/data-object-service.ts +++ b/ui/hv2-ui/src/app/data-object-service.ts @@ -28,120 +28,129 @@ import { TenancyFeeMapping } from './data-objects'; import { AccountEntry } from './data-objects'; -@Injectable({ - providedIn: 'root' -}) +@Injectable({ providedIn: 'root' }) export class AccountService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getAccount(): Promise { + async getAccounts(): Promise { this.messageService.add(`AccountService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/account`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/accounts`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class TenantService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getTenant(): Promise { + async getTenants(): Promise { this.messageService.add(`TenantService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/tenant`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/tenants`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class PremiseService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getPremise(): Promise { + async getPremises(): Promise { this.messageService.add(`PremiseService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/premise`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/premises`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class FlatService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getFlat(): Promise { + async getFlats(): Promise { this.messageService.add(`FlatService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/flat`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/flats`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class OverheadAdvanceService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getOverheadAdvance(): Promise { + async getOverheadAdvances(): Promise { this.messageService.add(`OverheadAdvanceService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/overhead_advance`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/overhead_advances`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class OverheadAdvanceFlatMappingService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getOverheadAdvanceFlatMapping(): Promise { + async getOverheadAdvanceFlatMappings(): Promise { this.messageService.add(`OverheadAdvanceFlatMappingService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/overhead_advance_flat_mapping`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/overhead_advance_flat_mappings`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class ParkingService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getParking(): Promise { + async getParkings(): Promise { this.messageService.add(`ParkingService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/parking`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/parkings`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class CommercialPremiseService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getCommercialPremise(): Promise { + async getCommercialPremises(): Promise { this.messageService.add(`CommercialPremiseService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/commercial_premise`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/commercial_premises`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class TenancyService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getTenancy(): Promise { + async getTenancys(): Promise { this.messageService.add(`TenancyService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/tenancy`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/tenancys`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class FeeService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getFee(): Promise { + async getFees(): Promise { this.messageService.add(`FeeService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/fee`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/fees`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class TenancyFeeMappingService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getTenancyFeeMapping(): Promise { + async getTenancyFeeMappings(): Promise { this.messageService.add(`TenancyFeeMappingService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/tenancy_fee_mapping`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/tenancy_fee_mappings`).toPromise() } } +@Injectable({ providedIn: 'root' }) export class AccountEntryService { constructor(private messageService: MessageService, private http: HttpClient) { } - async getAccountEntry(): Promise { + async getAccountEntrys(): Promise { this.messageService.add(`AccountEntryService: fetch data`); - return this.http.get(`${serviceBaseUrl}/v1/account_entry`).toPromise() + return this.http.get(`${serviceBaseUrl}/v1/account_entrys`).toPromise() } } diff --git a/ui/hv2-ui/src/app/data-object-service.ts.tmpl b/ui/hv2-ui/src/app/data-object-service.ts.tmpl index 177e2bb..518a53f 100644 --- a/ui/hv2-ui/src/app/data-object-service.ts.tmpl +++ b/ui/hv2-ui/src/app/data-object-service.ts.tmpl @@ -14,9 +14,6 @@ import { ${JsNameConverter($table.name)} } from './data-objects'; #end for -@Injectable({ - providedIn: 'root' -}) @@ -25,12 +22,13 @@ import { ${JsNameConverter($table.name)} } from './data-objects'; #from generateHelper import JsNameConverter #for $table in $tables +@Injectable({ providedIn: 'root' }) export class ${JsNameConverter($table.name)}Service { constructor(private messageService: MessageService, private http: HttpClient) { } - async get${JsNameConverter($table.name)}(): Promise<${JsNameConverter($table.name)}> { + async get${JsNameConverter($table.name)}s(): Promise<${JsNameConverter($table.name)}[]> { this.messageService.add(`${JsNameConverter($table.name)}Service: fetch data`); - return this.http.get<${JsNameConverter($table.name)}>(`\${serviceBaseUrl}/v1/${table.name}`).toPromise() + return this.http.get<${JsNameConverter($table.name)}[]>(`\${serviceBaseUrl}/v1/${table.name}s`).toPromise() } } diff --git a/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.css b/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.css new file mode 100644 index 0000000..e69de29 diff --git a/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.html b/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.html new file mode 100644 index 0000000..d19549c --- /dev/null +++ b/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.html @@ -0,0 +1,25 @@ +
+ + + + Meine Büros + + + +
+ + + + + + + + + + + +
Beschreibung{{element.description}}Haus{{element.premise}}
+
+
+
+
diff --git a/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.spec.ts b/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.spec.ts new file mode 100644 index 0000000..470bd27 --- /dev/null +++ b/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyCommercialUnitsComponent } from './my-commercial-units.component'; + +describe('MyCommercialUnitsComponent', () => { + let component: MyCommercialUnitsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ MyCommercialUnitsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MyCommercialUnitsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.ts b/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.ts new file mode 100644 index 0000000..8d143b2 --- /dev/null +++ b/ui/hv2-ui/src/app/my-commercial-units/my-commercial-units.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core'; +import { MessageService } from '../message.service'; +import { CommercialPremiseService } from '../data-object-service'; +import { CommercialPremise } from '../data-objects'; +import { MatTableDataSource } from '@angular/material/table' + +@Component({ + selector: 'app-my-commercial-units', + templateUrl: './my-commercial-units.component.html', + styleUrls: ['./my-commercial-units.component.css'] +}) +export class MyCommercialUnitsComponent implements OnInit { + + commercialPremises: CommercialPremise[] + dataSource: MatTableDataSource + displayedColumns: string[] = ["description", "premise"] + + constructor(private commercialPremiseService: CommercialPremiseService, private messageService: MessageService) { } + + async getCommercialPremises(): Promise { + try { + this.messageService.add("Trying to load commercialPremises") + this.commercialPremises = await this.commercialPremiseService.getCommercialPremises() + this.messageService.add("CommercialPremises loaded") + + this.dataSource = new MatTableDataSource(this.commercialPremises) + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + ngOnInit(): void { + this.messageService.add("MyCommercialUnitsComponent.ngOnInit") + this.getCommercialPremises() + } + +} diff --git a/ui/hv2-ui/src/app/my-flats/my-flats.component.css b/ui/hv2-ui/src/app/my-flats/my-flats.component.css new file mode 100644 index 0000000..732345b --- /dev/null +++ b/ui/hv2-ui/src/app/my-flats/my-flats.component.css @@ -0,0 +1,3 @@ +table { + width: 75%; +} diff --git a/ui/hv2-ui/src/app/my-flats/my-flats.component.html b/ui/hv2-ui/src/app/my-flats/my-flats.component.html new file mode 100644 index 0000000..74328e6 --- /dev/null +++ b/ui/hv2-ui/src/app/my-flats/my-flats.component.html @@ -0,0 +1,33 @@ +
+ + + + Meine Wohnungen + + + +
+ + + + + + + + + + + + + + + + + + + +
Beschreibung{{element.description}}Haus{{element.premise}}Wohnfläche{{element.area}}Wohnungsnummer{{element.flat_no}}
+
+
+
+
diff --git a/ui/hv2-ui/src/app/my-flats/my-flats.component.spec.ts b/ui/hv2-ui/src/app/my-flats/my-flats.component.spec.ts new file mode 100644 index 0000000..b93b58f --- /dev/null +++ b/ui/hv2-ui/src/app/my-flats/my-flats.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyFlatsComponent } from './my-flats.component'; + +describe('MyFlatsComponent', () => { + let component: MyFlatsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ MyFlatsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MyFlatsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/hv2-ui/src/app/my-flats/my-flats.component.ts b/ui/hv2-ui/src/app/my-flats/my-flats.component.ts new file mode 100644 index 0000000..a530d27 --- /dev/null +++ b/ui/hv2-ui/src/app/my-flats/my-flats.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core'; +import { MessageService } from '../message.service'; +import { FlatService } from '../data-object-service'; +import { Flat } from '../data-objects'; +import { MatTableDataSource } from '@angular/material/table' + +@Component({ + selector: 'app-my-flats', + templateUrl: './my-flats.component.html', + styleUrls: ['./my-flats.component.css'] +}) +export class MyFlatsComponent implements OnInit { + + flats: Flat[] + dataSource: MatTableDataSource + displayedColumns: string[] = ["description", "premise", "area", "flat_no"] + + constructor(private flatService: FlatService, private messageService: MessageService) { } + + async getFlats(): Promise { + try { + this.messageService.add("Trying to load flats") + this.flats = await this.flatService.getFlats() + this.messageService.add("Flats loaded") + + this.dataSource = new MatTableDataSource(this.flats) + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + ngOnInit(): void { + this.messageService.add("MyFlatsComponent.ngOnInit") + this.getFlats() + } + +} diff --git a/ui/hv2-ui/src/app/my-parkings/my-parkings.component.css b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.css new file mode 100644 index 0000000..732345b --- /dev/null +++ b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.css @@ -0,0 +1,3 @@ +table { + width: 75%; +} diff --git a/ui/hv2-ui/src/app/my-parkings/my-parkings.component.html b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.html new file mode 100644 index 0000000..56670b3 --- /dev/null +++ b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.html @@ -0,0 +1,25 @@ +
+ + + + Meine Garagen + + + +
+ + + + + + + + + + + +
Beschreibung{{element.description}}Haus{{element.premise}}
+
+
+
+
diff --git a/ui/hv2-ui/src/app/my-parkings/my-parkings.component.spec.ts b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.spec.ts new file mode 100644 index 0000000..6fdbbdb --- /dev/null +++ b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyParkingsComponent } from './my-parkings.component'; + +describe('MyParkingsComponent', () => { + let component: MyParkingsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ MyParkingsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MyParkingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/hv2-ui/src/app/my-parkings/my-parkings.component.ts b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.ts new file mode 100644 index 0000000..3c627d9 --- /dev/null +++ b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core'; +import { MessageService } from '../message.service'; +import { ParkingService } from '../data-object-service'; +import { Parking } from '../data-objects'; +import { MatTableDataSource } from '@angular/material/table' + +@Component({ + selector: 'app-my-parkings', + templateUrl: './my-parkings.component.html', + styleUrls: ['./my-parkings.component.css'] +}) +export class MyParkingsComponent implements OnInit { + + parkings: Parking[] + dataSource: MatTableDataSource + displayedColumns: string[] = ["description", "premise"] + + constructor(private parkingService: ParkingService, private messageService: MessageService) { } + + async getParkings(): Promise { + try { + this.messageService.add("Trying to load parkings") + this.parkings = await this.parkingService.getParkings() + this.messageService.add("Parkings loaded") + + this.dataSource = new MatTableDataSource(this.parkings) + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + ngOnInit(): void { + this.messageService.add("MyParkingsComponent.ngOnInit") + this.getParkings() + } + +} diff --git a/ui/hv2-ui/src/app/my-premises/my-premises.component.css b/ui/hv2-ui/src/app/my-premises/my-premises.component.css new file mode 100644 index 0000000..732345b --- /dev/null +++ b/ui/hv2-ui/src/app/my-premises/my-premises.component.css @@ -0,0 +1,3 @@ +table { + width: 75%; +} diff --git a/ui/hv2-ui/src/app/my-premises/my-premises.component.html b/ui/hv2-ui/src/app/my-premises/my-premises.component.html new file mode 100644 index 0000000..f219cb7 --- /dev/null +++ b/ui/hv2-ui/src/app/my-premises/my-premises.component.html @@ -0,0 +1,33 @@ +
+ + + + Meine Häuser + + + +
+ + + + + + + + + + + + + + + + + + + +
Beschreibung{{element.description}}Strasse{{element.street}}PLZ{{element.zip}}Ort{{element.city}}
+
+
+
+
diff --git a/ui/hv2-ui/src/app/my-premises/my-premises.component.spec.ts b/ui/hv2-ui/src/app/my-premises/my-premises.component.spec.ts new file mode 100644 index 0000000..e17ab96 --- /dev/null +++ b/ui/hv2-ui/src/app/my-premises/my-premises.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyPremisesComponent } from './my-premises.component'; + +describe('MyPremisesComponent', () => { + let component: MyPremisesComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ MyPremisesComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MyPremisesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/hv2-ui/src/app/my-premises/my-premises.component.ts b/ui/hv2-ui/src/app/my-premises/my-premises.component.ts new file mode 100644 index 0000000..35a64c1 --- /dev/null +++ b/ui/hv2-ui/src/app/my-premises/my-premises.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core'; +import { MatTableDataSource } from '@angular/material/table'; +import { PremiseService } from '../data-object-service'; +import { MessageService } from '../message.service'; +import { Premise } from '../data-objects' + +@Component({ + selector: 'app-my-premises', + templateUrl: './my-premises.component.html', + styleUrls: ['./my-premises.component.css'] +}) +export class MyPremisesComponent implements OnInit { + + premises: Premise[] + dataSource: MatTableDataSource + displayedColumns: string[] = [ "description", "street", "zip", "city" ] + + constructor(private premiseService: PremiseService, private messageService: MessageService) { } + + async getPremises(): Promise { + try { + this.messageService.add("Trying to load premises") + this.premises = await this.premiseService.getPremises() + this.messageService.add("Premises loaded") + + this.dataSource = new MatTableDataSource(this.premises) + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + ngOnInit(): void { + this.messageService.add("MyPremisesComponent.ngOnInit") + this.getPremises() + } + +} diff --git a/ui/hv2-ui/src/app/my-tenants/my-tenants.component.css b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.css new file mode 100644 index 0000000..732345b --- /dev/null +++ b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.css @@ -0,0 +1,3 @@ +table { + width: 75%; +} diff --git a/ui/hv2-ui/src/app/my-tenants/my-tenants.component.html b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.html new file mode 100644 index 0000000..6f882ae --- /dev/null +++ b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.html @@ -0,0 +1,29 @@ +
+ + + + Meine Mieter/innen + + + +
+ + + + + + + + + + + + + + + +
Nachname{{element.lastname}}Vorname{{element.firstname}}Adresse 1{{element.address1}}
+
+
+
+
diff --git a/ui/hv2-ui/src/app/my-tenants/my-tenants.component.spec.ts b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.spec.ts new file mode 100644 index 0000000..f921af1 --- /dev/null +++ b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MyTenantsComponent } from './my-tenants.component'; + +describe('MyTenantsComponent', () => { + let component: MyTenantsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ MyTenantsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MyTenantsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/hv2-ui/src/app/my-tenants/my-tenants.component.ts b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.ts new file mode 100644 index 0000000..d8bcaed --- /dev/null +++ b/ui/hv2-ui/src/app/my-tenants/my-tenants.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core'; +import { MessageService } from '../message.service'; +import { TenantService } from '../data-object-service'; +import { Tenant } from '../data-objects'; +import { MatTableDataSource } from '@angular/material/table' + +@Component({ + selector: 'app-my-tenants', + templateUrl: './my-tenants.component.html', + styleUrls: ['./my-tenants.component.css'] +}) +export class MyTenantsComponent implements OnInit { + + tenants: Tenant[] + dataSource: MatTableDataSource + displayedColumns: string[] = ["lastname", "firstname", "address1"] + + constructor(private tenantService: TenantService, private messageService: MessageService) { } + + async getTenants(): Promise { + try { + this.messageService.add("Trying to load tenants") + this.tenants = await this.tenantService.getTenants() + this.messageService.add("Tenants loaded") + + this.dataSource = new MatTableDataSource(this.tenants) + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + ngOnInit(): void { + this.messageService.add("MyTenantsComponent.ngOnInit") + this.getTenants() + } + +} diff --git a/ui/hv2-ui/src/app/navigation/navigation.component.html b/ui/hv2-ui/src/app/navigation/navigation.component.html index ffedafb..d3d15f7 100644 --- a/ui/hv2-ui/src/app/navigation/navigation.component.html +++ b/ui/hv2-ui/src/app/navigation/navigation.component.html @@ -5,7 +5,11 @@ [opened]="(isHandset$ | async) === false"> Menu - Mein Test + Meine Häuser + Meine Wohnungen + Meine Garagen + Meine Büros + Meine Mieter/innen