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 index 224eeab..43e105f 100644 --- 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 @@ -52,16 +52,22 @@ export class CommercialUnitDetailsComponent implements OnInit { } 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") + try { + 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 commercialPremise with id ${this.commercialPremise.id}`) + } else { + this.messageService.add("about to update existing commercialPremise") + this.commercialPremise = await this.commercialPremiseService.putCommercialPremise(this.commercialPremise) + this.messageService.add(`Successfully changed commercialPremise with id ${this.commercialPremise.id}`) + } + this.router.navigate(['/commercialunits']) + } finally { + this.submitButton.disabled = false } - this.router.navigate(['/commercialunits']) } diff --git a/ui/hv2-ui/src/app/flat-details/flat-details.component.ts b/ui/hv2-ui/src/app/flat-details/flat-details.component.ts index 9d3037f..97b24bf 100644 --- a/ui/hv2-ui/src/app/flat-details/flat-details.component.ts +++ b/ui/hv2-ui/src/app/flat-details/flat-details.component.ts @@ -63,16 +63,22 @@ export class FlatDetailsComponent implements OnInit { } async saveFlat() { - this.submitButton.disabled = true - this.messageService.add(`saveFlat: ${ JSON.stringify(this.flat, undefined, 4) }`) - if (this.flat.id == 0) { - this.messageService.add("about to insert new flat") - this.flat = await this.flatService.postFlat(this.flat) - this.messageService.add(`Successfully added flat with id ${this.flat.id}`) - } else { - this.messageService.add("about to update existing flat") + try { + this.submitButton.disabled = true + this.messageService.add(`saveFlat: ${ JSON.stringify(this.flat, undefined, 4) }`) + if (this.flat.id == 0) { + this.messageService.add("about to insert new flat") + this.flat = await this.flatService.postFlat(this.flat) + this.messageService.add(`Successfully added flat with id ${this.flat.id}`) + } else { + this.messageService.add("about to update existing flat") + this.flat = await this.flatService.putFlat(this.flat) + this.messageService.add(`Successfully changed flat with id ${this.flat.id}`) + } + this.router.navigate(['/flats']) + } finally { + this.submitButton.disabled = false } - this.router.navigate(['/flats']) } ngOnInit(): void { diff --git a/ui/hv2-ui/src/app/overhead-advance-details/overhead-advance-details.component.ts b/ui/hv2-ui/src/app/overhead-advance-details/overhead-advance-details.component.ts index 655e074..a96eb7a 100644 --- a/ui/hv2-ui/src/app/overhead-advance-details/overhead-advance-details.component.ts +++ b/ui/hv2-ui/src/app/overhead-advance-details/overhead-advance-details.component.ts @@ -35,18 +35,23 @@ export class OverheadAdvanceDetailsComponent implements OnInit { } async saveOverheadAdvance() { - this.submitButton.disabled = true - this.messageService.add("saveOverheadAdvance") - this.messageService.add(JSON.stringify(this.overheadAdvance, undefined, 4)) - if (this.overheadAdvance.id == 0) { - this.messageService.add("about to insert new overheadAdvance") - this.overheadAdvance = await this.overheadAdvanceService.postOverheadAdvance(this.overheadAdvance) - this.messageService.add(`Successfully added overheadAdvance with id ${this.overheadAdvance.id}`) - } else { - this.messageService.add("about to update existing overheadAdvance") + try { + this.submitButton.disabled = true + this.messageService.add("saveOverheadAdvance") + this.messageService.add(JSON.stringify(this.overheadAdvance, undefined, 4)) + if (this.overheadAdvance.id == 0) { + this.messageService.add("about to insert new overheadAdvance") + this.overheadAdvance = await this.overheadAdvanceService.postOverheadAdvance(this.overheadAdvance) + this.messageService.add(`Successfully added overheadAdvance with id ${this.overheadAdvance.id}`) + } else { + this.messageService.add("about to update existing overheadAdvance") + this.overheadAdvance = await this.overheadAdvanceService.putOverheadAdvance(this.overheadAdvance) + this.messageService.add(`Successfully changed overheadAdvance with id ${this.overheadAdvance.id}`) + } + this.router.navigate(['/overheadadvances']) + } finally { + this.submitButton.disabled = false } - this.router.navigate(['/overheadadvances']) - // this.submitButton.disabled = false } 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 index 606d0d1..736662d 100644 --- a/ui/hv2-ui/src/app/parking-details/parking-details.component.ts +++ b/ui/hv2-ui/src/app/parking-details/parking-details.component.ts @@ -52,16 +52,22 @@ export class ParkingDetailsComponent implements OnInit { } 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") + try { + 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 parking with id ${this.parking.id}`) + } else { + this.messageService.add("about to update existing parking") + this.parking = await this.parkingService.putParking(this.parking) + this.messageService.add(`Successfully changed parking with id ${this.parking.id}`) + } + this.router.navigate(['/parkings']) + } finally { + this.submitButton.disabled = false } - this.router.navigate(['/parkings']) } diff --git a/ui/hv2-ui/src/app/premise-details/premise-details.component.ts b/ui/hv2-ui/src/app/premise-details/premise-details.component.ts index 9e07dbf..2eb4a08 100644 --- a/ui/hv2-ui/src/app/premise-details/premise-details.component.ts +++ b/ui/hv2-ui/src/app/premise-details/premise-details.component.ts @@ -41,18 +41,23 @@ export class PremiseDetailsComponent implements OnInit { } async savePremise() { - this.submitButton.disabled = true - this.messageService.add("savePremise") - this.messageService.add(JSON.stringify(this.premise, undefined, 4)) - if (this.premise.id == 0) { - this.messageService.add("about to insert new premise") - this.premise = await this.premiseService.postPremise(this.premise) - this.messageService.add(`Successfully added premises with id ${this.premise.id}`) - } else { - this.messageService.add("about to update existing premise") + try { + this.submitButton.disabled = true + this.messageService.add("savePremise") + this.messageService.add(JSON.stringify(this.premise, undefined, 4)) + if (this.premise.id == 0) { + this.messageService.add("about to insert new premise") + this.premise = await this.premiseService.postPremise(this.premise) + this.messageService.add(`Successfully added premises with id ${this.premise.id}`) + } else { + this.messageService.add("about to update existing premise") + this.premise = await this.premiseService.putPremise(this.premise) + this.messageService.add(`Successfully changed premises with id ${this.premise.id}`) + } + this.router.navigate(['/premises']) + } finally { + this.submitButton.disabled = false } - this.router.navigate(['/premises']) - // this.submitButton.disabled = false } ngOnInit(): void { diff --git a/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts b/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts index 37fab40..1d06ebd 100644 --- a/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts +++ b/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts @@ -56,23 +56,29 @@ export class TenantDetailsComponent implements OnInit { } async saveTenant() { - this.submitButton.disabled = true - this.messageService.add("saveTenant") - this.messageService.add(JSON.stringify(this.tenant, undefined, 4)) - if (this.tenant.id == 0) { - this.messageService.add("about to insert new tenant") - this.account = { - "id": 0, - "description": `account_${this.tenant.firstname}_${this.tenant.lastname}` + try { + this.submitButton.disabled = true + this.messageService.add("saveTenant") + this.messageService.add(JSON.stringify(this.tenant, undefined, 4)) + if (this.tenant.id == 0) { + this.messageService.add("about to insert new tenant") + this.account = { + "id": 0, + "description": `account_${this.tenant.firstname}_${this.tenant.lastname}` + } + this.account = await this.accountService.postAccount(this.account) + this.tenant.account = this.account.id + this.tenant = await this.tenantService.postTenant(this.tenant) + this.messageService.add(`Successfully added account with id ${this.account.id} and tenant with id ${this.tenant.id}`) + } else { + this.messageService.add("about to update existing tenant") + this.tenant = await this.tenantService.putTenant(this.tenant) + this.messageService.add(`Successfully changed tenant with id ${this.tenant.id}`) } - this.account = await this.accountService.postAccount(this.account) - this.tenant.account = this.account.id - this.tenant = await this.tenantService.postTenant(this.tenant) - this.messageService.add(`Successfully added account with id ${this.account.id} and tenant with id ${this.tenant.id}`) - } else { - this.messageService.add("about to update existing tenant") + this.router.navigate(['/tenants']) + } finally { + this.submitButton.disabled = false } - this.router.navigate(['/tenants']) } ngOnInit(): void {