diff --git a/ui/hv2-ui/src/app/app-routing.module.ts b/ui/hv2-ui/src/app/app-routing.module.ts index fb66cf1..11daa0c 100644 --- a/ui/hv2-ui/src/app/app-routing.module.ts +++ b/ui/hv2-ui/src/app/app-routing.module.ts @@ -11,6 +11,8 @@ import { MyCommercialUnitsComponent } from './my-commercial-units/my-commercial- import { TenantDetailsComponent } from './tenant-details/tenant-details.component'; import { PremiseDetailsComponent } from './premise-details/premise-details.component'; import { FlatDetailsComponent } from './flat-details/flat-details.component'; +import { ParkingDetailsComponent } from './parking-details/parking-details.component'; +import { CommercialUnitDetailsComponent } from './commercial-unit-details/commercial-unit-details.component'; const routes: Routes = [ @@ -25,6 +27,10 @@ const routes: Routes = [ { path: 'premise', component: PremiseDetailsComponent, canActivate: [ AuthGuardService ] }, { path: 'flat/:id', component: FlatDetailsComponent, canActivate: [ AuthGuardService ] }, { path: 'flat', component: FlatDetailsComponent, canActivate: [ AuthGuardService ] }, + { path: 'parking/:id', component: ParkingDetailsComponent, canActivate: [ AuthGuardService ] }, + { path: 'parking', component: ParkingDetailsComponent, canActivate: [ AuthGuardService ] }, + { path: 'commercialunit/:id', component: CommercialUnitDetailsComponent, canActivate: [ AuthGuardService ] }, + { path: 'commercialunit', component: CommercialUnitDetailsComponent, 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 16f6f6a..3e61716 100644 --- a/ui/hv2-ui/src/app/app.module.ts +++ b/ui/hv2-ui/src/app/app.module.ts @@ -31,7 +31,9 @@ import { MyCommercialUnitsComponent } from './my-commercial-units/my-commercial- import { TenantDetailsComponent } from './tenant-details/tenant-details.component'; import { PremiseDetailsComponent } from './premise-details/premise-details.component'; import { FlatDetailsComponent } from './flat-details/flat-details.component'; -import { MatSelectModule } from '@angular/material/select' +import { MatSelectModule } from '@angular/material/select'; +import { ParkingDetailsComponent } from './parking-details/parking-details.component'; +import { CommercialUnitDetailsComponent } from './commercial-unit-details/commercial-unit-details.component' @NgModule({ declarations: [ AppComponent, @@ -47,7 +49,9 @@ import { MatSelectModule } from '@angular/material/select' MyCommercialUnitsComponent, TenantDetailsComponent, PremiseDetailsComponent, - FlatDetailsComponent + FlatDetailsComponent, + ParkingDetailsComponent, + CommercialUnitDetailsComponent ], imports: [ BrowserModule, diff --git a/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.css b/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.css new file mode 100644 index 0000000..e69de29 diff --git a/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.html b/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.html new file mode 100644 index 0000000..78a04c6 --- /dev/null +++ b/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.html @@ -0,0 +1,31 @@ +
+ + + + {{commercialPremise?.description}} {{premise?.description}} + + + ID: {{commercialPremise?.id}} + + + +
+
+
+ + Beschreibung + + + + Haus + + {{p.description}} + + +
+ +
+
+
+
+
diff --git a/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.spec.ts b/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.spec.ts new file mode 100644 index 0000000..4f6c498 --- /dev/null +++ b/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CommercialUnitDetailsComponent } from './commercial-unit-details.component'; + +describe('CommercialUnitDetailsComponent', () => { + let component: CommercialUnitDetailsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ CommercialUnitDetailsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(CommercialUnitDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.ts b/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.ts new file mode 100644 index 0000000..224eeab --- /dev/null +++ b/ui/hv2-ui/src/app/commercial-unit-details/commercial-unit-details.component.ts @@ -0,0 +1,73 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatButton } from '@angular/material/button'; +import { ActivatedRoute, Router } from '@angular/router'; +import { CommercialPremiseService, PremiseService } from '../data-object-service'; +import { NULL_CommercialPremise, NULL_Premise, CommercialPremise, Premise } from '../data-objects'; +import { MessageService } from '../message.service'; + +@Component({ + selector: 'app-commercial-unit-details', + templateUrl: './commercial-unit-details.component.html', + styleUrls: ['./commercial-unit-details.component.css'] +}) +export class CommercialUnitDetailsComponent implements OnInit { + + @ViewChild('submitButton') submitButton: MatButton + + commercialPremise: CommercialPremise = NULL_CommercialPremise + premise: Premise = NULL_Premise + + premises: Premise[] + + constructor( + private commercialPremiseService: CommercialPremiseService, + private premiseService: PremiseService, + private messageService: MessageService, + private route: ActivatedRoute, + private router: Router + ) { } + + + + async getCommercialPremise(): Promise { + try { + const id = +this.route.snapshot.paramMap.get('id') + if (id != 0) { + this.commercialPremise = await this.commercialPremiseService.getCommercialPremise(id) + this.premise = await this.premiseService.getPremise(this.commercialPremise.premise) + } + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + async getPremises(): Promise { + try { + this.messageService.add("Trying to load premises") + this.premises = await this.premiseService.getPremises() + this.messageService.add("Premises loaded") + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + async saveCommercialPremise() { + this.submitButton.disabled = true + this.messageService.add(`saveCommercialPremise: ${ JSON.stringify(this.commercialPremise, undefined, 4) }`) + if (this.commercialPremise.id == 0) { + this.messageService.add("about to insert new commercialPremise") + this.commercialPremise = await this.commercialPremiseService.postCommercialPremise(this.commercialPremise) + this.messageService.add(`Successfully added flat with id ${this.commercialPremise.id}`) + } else { + this.messageService.add("about to update existing commercialPremise") + } + this.router.navigate(['/commercialunits']) + } + + + ngOnInit(): void { + this.getPremises() + this.getCommercialPremise() + } + +} 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 index d19549c..f061f1b 100644 --- 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 @@ -3,6 +3,9 @@ Meine Büros + Meine Büros + + Neu anlegen @@ -10,14 +13,14 @@ - + - + - +
Beschreibung{{element.description}}{{element.commercialPremise.description}} Haus{{element.premise}}{{element.premise.description}}
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 index 8d143b2..3cf6ecf 100644 --- 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 @@ -1,9 +1,14 @@ import { Component, OnInit } from '@angular/core'; import { MessageService } from '../message.service'; -import { CommercialPremiseService } from '../data-object-service'; -import { CommercialPremise } from '../data-objects'; +import { CommercialPremiseService, PremiseService } from '../data-object-service'; +import { CommercialPremise, Premise } from '../data-objects'; import { MatTableDataSource } from '@angular/material/table' +interface DN_CommercialPremise { + commercialPremise: CommercialPremise + premise: Premise +} + @Component({ selector: 'app-my-commercial-units', templateUrl: './my-commercial-units.component.html', @@ -12,18 +17,40 @@ import { MatTableDataSource } from '@angular/material/table' export class MyCommercialUnitsComponent implements OnInit { commercialPremises: CommercialPremise[] - dataSource: MatTableDataSource + premises: Premise[] + dnCommercialPremises: DN_CommercialPremise[] = [] + + dataSource: MatTableDataSource displayedColumns: string[] = ["description", "premise"] - constructor(private commercialPremiseService: CommercialPremiseService, private messageService: MessageService) { } + constructor( + private commercialPremiseService: CommercialPremiseService, + private premiseService: PremiseService, + 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.messageService.add("Trying to load premises") + this.premises = await this.premiseService.getPremises() + this.messageService.add(`Premises loaded: ${ JSON.stringify(this.premises, undefined, 4) }`) - this.dataSource = new MatTableDataSource(this.commercialPremises) + const premisesDict = new Map() + for (let p of this.premises) { + premisesDict.set(p.id, p) + } + for (let f of this.commercialPremises) { + this.dnCommercialPremises.push({ + commercialPremise: f, + premise: premisesDict.get(f.premise) + }) + } + + + this.dataSource = new MatTableDataSource(this.dnCommercialPremises) } catch (err) { this.messageService.add(JSON.stringify(err, undefined, 4)) } 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 index 7d4d914..b49aa55 100644 --- a/ui/hv2-ui/src/app/my-flats/my-flats.component.html +++ b/ui/hv2-ui/src/app/my-flats/my-flats.component.html @@ -27,7 +27,7 @@ {{element.flat.flat_no}} - + 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 index 05f936d..c992e43 100644 --- a/ui/hv2-ui/src/app/my-flats/my-flats.component.ts +++ b/ui/hv2-ui/src/app/my-flats/my-flats.component.ts @@ -17,7 +17,7 @@ interface DN_Flat { export class MyFlatsComponent implements OnInit { flats: Flat[] premises: Premise[] - dnFlats: DN_Flat[] + dnFlats: DN_Flat[] = [] dataSource: MatTableDataSource displayedColumns: string[] = ["description", "premise", "area", "flat_no"] @@ -39,20 +39,18 @@ export class MyFlatsComponent implements OnInit { const premisesDict = new Map() for (let p of this.premises) { - this.messageService.add(`p2pd: ${p.id}`) premisesDict.set(p.id, p) } - this.messageService.add(`premisesDict: ${ JSON.stringify(premisesDict, undefined, 4) }`) for (let f of this.flats) { this.dnFlats.push({ flat: f, premise: premisesDict.get(f.premise) }) } - this.messageService.add(`dnFlats: { JSON.stringify(this.dnFlats, undefined, 4) }`) this.dataSource = new MatTableDataSource(this.dnFlats) } catch (err) { + // throw err this.messageService.add(`Error in getFlats: ${ JSON.stringify(err, undefined, 4) }`) } } 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 index 56670b3..8bdfb0d 100644 --- a/ui/hv2-ui/src/app/my-parkings/my-parkings.component.html +++ b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.html @@ -3,6 +3,9 @@ Meine Garagen + Meine Garagen + + Neu anlegen @@ -10,14 +13,14 @@ - + - + - +
Beschreibung{{element.description}}{{element.parking.description}} Haus{{element.premise}}{{element.premise.description}}
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 index 3c627d9..067dbc6 100644 --- a/ui/hv2-ui/src/app/my-parkings/my-parkings.component.ts +++ b/ui/hv2-ui/src/app/my-parkings/my-parkings.component.ts @@ -1,29 +1,54 @@ import { Component, OnInit } from '@angular/core'; import { MessageService } from '../message.service'; -import { ParkingService } from '../data-object-service'; -import { Parking } from '../data-objects'; +import { ParkingService, PremiseService } from '../data-object-service'; +import { Parking, Premise } from '../data-objects'; import { MatTableDataSource } from '@angular/material/table' +interface DN_Parking { + parking: Parking + premise: Premise +} + @Component({ selector: 'app-my-parkings', templateUrl: './my-parkings.component.html', styleUrls: ['./my-parkings.component.css'] }) export class MyParkingsComponent implements OnInit { - parkings: Parking[] - dataSource: MatTableDataSource + premises: Premise[] + dnParkings: DN_Parking[] = [] + + dataSource: MatTableDataSource displayedColumns: string[] = ["description", "premise"] - constructor(private parkingService: ParkingService, private messageService: MessageService) { } + constructor( + private parkingService: ParkingService, + private premiseService: PremiseService, + 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.messageService.add("Trying to load premises") + this.premises = await this.premiseService.getPremises() + this.messageService.add(`Premises loaded: ${ JSON.stringify(this.premises, undefined, 4) }`) - this.dataSource = new MatTableDataSource(this.parkings) + const premisesDict = new Map() + for (let p of this.premises) { + premisesDict.set(p.id, p) + } + for (let p of this.parkings) { + this.dnParkings.push({ + parking: p, + premise: premisesDict.get(p.premise) + }) + } + + this.dataSource = new MatTableDataSource(this.dnParkings) } catch (err) { this.messageService.add(JSON.stringify(err, undefined, 4)) } diff --git a/ui/hv2-ui/src/app/parking-details/parking-details.component.css b/ui/hv2-ui/src/app/parking-details/parking-details.component.css new file mode 100644 index 0000000..e69de29 diff --git a/ui/hv2-ui/src/app/parking-details/parking-details.component.html b/ui/hv2-ui/src/app/parking-details/parking-details.component.html new file mode 100644 index 0000000..7db8abd --- /dev/null +++ b/ui/hv2-ui/src/app/parking-details/parking-details.component.html @@ -0,0 +1,31 @@ +
+ + + + {{parking?.description}} {{premise?.description}} + + + ID: {{parking?.id}} + + + +
+
+
+ + Beschreibung + + + + Haus + + {{p.description}} + + +
+ +
+
+
+
+
diff --git a/ui/hv2-ui/src/app/parking-details/parking-details.component.spec.ts b/ui/hv2-ui/src/app/parking-details/parking-details.component.spec.ts new file mode 100644 index 0000000..e1e433a --- /dev/null +++ b/ui/hv2-ui/src/app/parking-details/parking-details.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ParkingDetailsComponent } from './parking-details.component'; + +describe('ParkingDetailsComponent', () => { + let component: ParkingDetailsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ParkingDetailsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ParkingDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ui/hv2-ui/src/app/parking-details/parking-details.component.ts b/ui/hv2-ui/src/app/parking-details/parking-details.component.ts new file mode 100644 index 0000000..606d0d1 --- /dev/null +++ b/ui/hv2-ui/src/app/parking-details/parking-details.component.ts @@ -0,0 +1,73 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatButton } from '@angular/material/button'; +import { ActivatedRoute, Router } from '@angular/router'; +import { ParkingService, PremiseService } from '../data-object-service'; +import { NULL_Parking, NULL_Premise, Parking, Premise } from '../data-objects'; +import { MessageService } from '../message.service'; + +@Component({ + selector: 'app-parking-details', + templateUrl: './parking-details.component.html', + styleUrls: ['./parking-details.component.css'] +}) +export class ParkingDetailsComponent implements OnInit { + + @ViewChild('submitButton') submitButton: MatButton + + parking: Parking = NULL_Parking + premise: Premise = NULL_Premise + + premises: Premise[] + + constructor( + private parkingService: ParkingService, + private premiseService: PremiseService, + private messageService: MessageService, + private route: ActivatedRoute, + private router: Router + ) { } + + + + async getParking(): Promise { + try { + const id = +this.route.snapshot.paramMap.get('id') + if (id != 0) { + this.parking = await this.parkingService.getParking(id) + this.premise = await this.premiseService.getPremise(this.parking.premise) + } + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + async getPremises(): Promise { + try { + this.messageService.add("Trying to load premises") + this.premises = await this.premiseService.getPremises() + this.messageService.add("Premises loaded") + } catch (err) { + this.messageService.add(JSON.stringify(err, undefined, 4)) + } + } + + async saveParking() { + this.submitButton.disabled = true + this.messageService.add(`saveParking: ${ JSON.stringify(this.parking, undefined, 4) }`) + if (this.parking.id == 0) { + this.messageService.add("about to insert new parking") + this.parking = await this.parkingService.postParking(this.parking) + this.messageService.add(`Successfully added flat with id ${this.parking.id}`) + } else { + this.messageService.add("about to update existing parking") + } + this.router.navigate(['/parkings']) + } + + + ngOnInit(): void { + this.getPremises() + this.getParking() + } + +}