overhead stuff

This commit is contained in:
Wolfgang Hottgenroth 2021-09-02 18:26:55 +02:00
parent 7c180f0986
commit 1ce54cf9cf
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
11 changed files with 257 additions and 6 deletions

View File

@ -13,6 +13,8 @@ import { PremiseDetailsComponent } from './premise-details/premise-details.compo
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';
import { OverheadAdvanceListComponent } from './overhead-advance-list/overhead-advance-list.component';
import { OverheadAdvanceDetailsComponent } from './overhead-advance-details/overhead-advance-details.component';
const routes: Routes = [
@ -31,6 +33,9 @@ const routes: Routes = [
{ path: 'parking', component: ParkingDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'commercialunit/:id', component: CommercialUnitDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'commercialunit', component: CommercialUnitDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'overheadadvances', component: OverheadAdvanceListComponent, canActivate: [ AuthGuardService ] },
{ path: 'overheadadvance/:id', component: OverheadAdvanceDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'overheadadvance', component: OverheadAdvanceDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'logout', component: LogoutComponent },
{ path: 'login', component: LoginComponent }
]

View File

@ -33,7 +33,13 @@ import { PremiseDetailsComponent } from './premise-details/premise-details.compo
import { FlatDetailsComponent } from './flat-details/flat-details.component';
import { MatSelectModule } from '@angular/material/select';
import { ParkingDetailsComponent } from './parking-details/parking-details.component';
import { CommercialUnitDetailsComponent } from './commercial-unit-details/commercial-unit-details.component'
import { CommercialUnitDetailsComponent } from './commercial-unit-details/commercial-unit-details.component';
import { OverheadAdvanceListComponent } from './overhead-advance-list/overhead-advance-list.component';
import { OverheadAdvanceDetailsComponent } from './overhead-advance-details/overhead-advance-details.component'
import { MatDatepickerModule } from '@angular/material/datepicker'
import { MatNativeDateModule } from '@angular/material/core';
@NgModule({
declarations: [
AppComponent,
@ -51,7 +57,9 @@ import { CommercialUnitDetailsComponent } from './commercial-unit-details/commer
PremiseDetailsComponent,
FlatDetailsComponent,
ParkingDetailsComponent,
CommercialUnitDetailsComponent
CommercialUnitDetailsComponent,
OverheadAdvanceListComponent,
OverheadAdvanceDetailsComponent
],
imports: [
BrowserModule,
@ -70,11 +78,14 @@ import { CommercialUnitDetailsComponent } from './commercial-unit-details/commer
MatTableModule,
MatInputModule,
MatFormFieldModule,
MatSelectModule
MatSelectModule,
MatDatepickerModule,
MatNativeDateModule
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: ErrorHandlerInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: AuthHandlerInterceptor, multi: true }
{ provide: HTTP_INTERCEPTORS, useClass: AuthHandlerInterceptor, multi: true },
MatNativeDateModule
],
bootstrap: [AppComponent]
})

View File

@ -5,11 +5,15 @@
[opened]="(isHandset$ | async) === false">
<mat-toolbar>Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item href="/premises">Meine Häuser</a>
<a mat-list-item href="/tenants">Meine Mieter/innen</a>
</mat-nav-list><hr/><mat-nav-list>
<a mat-list-item href="/flats">Meine Wohnungen</a>
<a mat-list-item href="/parkings">Meine Garagen</a>
<a mat-list-item href="/commercialunits">Meine Büros</a>
<a mat-list-item href="/tenants">Meine Mieter/innen</a>
</mat-nav-list><hr/><mat-nav-list>
<a mat-list-item href="/overheadadvances">Betriebskostensätze</a>
</mat-nav-list><hr/><mat-nav-list>
<a mat-list-item href="/premises">Meine Häuser</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>

View File

@ -0,0 +1,41 @@
<section class="mat-typography">
<mat-card class="defaultCard">
<mat-card-header>
<mat-card-title>
{{overheadAdvance?.description}}
</mat-card-title>
<mat-card-subtitle>
ID: {{overheadAdvance?.id}}
</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<div>
<form (ngSubmit)="saveOverheadAdvance()">
<div>
<mat-form-field appearance="outline">
<mat-label>Beschreibung</mat-label>
<input matInput name="description" [(ngModel)]="overheadAdvance.description"/>
</mat-form-field>
</div><div>
<mat-form-field appearance="outline">
<mat-label>Betrag (€)</mat-label>
<input matInput type="number" name="amount" [(ngModel)]="overheadAdvance.amount"/>
</mat-form-field>
</div><div>
<mat-form-field appearance="outline">
<mat-label>Beginn</mat-label>
<input matInput name="startdate" [(ngModel)]="overheadAdvance.startdate" [matDatepicker]="startdatepicker"/>
<mat-datepicker-toggle matSuffix [for]="startdatepicker"></mat-datepicker-toggle>
<mat-datepicker #startdatepicker></mat-datepicker>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Ende</mat-label>
<input matInput name="enddate" [(ngModel)]="overheadAdvance.enddate"/>
</mat-form-field>
</div>
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
</form>
</div>
</mat-card-content>
</mat-card>
</section>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OverheadAdvanceDetailsComponent } from './overhead-advance-details.component';
describe('OverheadAdvanceDetailsComponent', () => {
let component: OverheadAdvanceDetailsComponent;
let fixture: ComponentFixture<OverheadAdvanceDetailsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ OverheadAdvanceDetailsComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(OverheadAdvanceDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,56 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatButton } from '@angular/material/button';
import { ActivatedRoute, Router } from '@angular/router';
import { OverheadAdvanceService } from '../data-object-service';
import { NULL_OverheadAdvance, OverheadAdvance } from '../data-objects';
import { MessageService } from '../message.service';
@Component({
selector: 'app-overhead-advance-details',
templateUrl: './overhead-advance-details.component.html',
styleUrls: ['./overhead-advance-details.component.css']
})
export class OverheadAdvanceDetailsComponent implements OnInit {
@ViewChild('submitButton') submitButton: MatButton
overheadAdvance: OverheadAdvance = NULL_OverheadAdvance
constructor(
private overheadAdvanceService: OverheadAdvanceService,
private messageService: MessageService,
private route: ActivatedRoute,
private router: Router
) { }
async getOverheadAdvance(): Promise<void> {
try {
const id = +this.route.snapshot.paramMap.get('id')
if (id != 0) {
this.overheadAdvance = await this.overheadAdvanceService.getOverheadAdvance(id)
}
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))
}
}
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")
}
this.router.navigate(['/overheadadvances'])
// this.submitButton.disabled = false
}
ngOnInit(): void {
}
}

View File

@ -0,0 +1,8 @@
table {
width: 75%;
}
.spacer {
flex: 1 1 auto;
}

View File

@ -0,0 +1,35 @@
<section class="mat-typography">
<mat-card class="defaultCard">
<mat-card-header>
<mat-card-title>
<span>Betriebskostensätze</span>
<span class="spacer"></span>
<a mat-button routerLink="/overheadadvance">Neu anlegen</a>
</mat-card-title>
</mat-card-header>
<mat-card-content>
<div>
<table mat-table [dataSource]="dataSource" #zftable>
<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
<td mat-cell *matCellDef="let element">{{element.description}}</td>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef>Betrag</th>
<td mat-cell *matCellDef="let element">{{element.amount}} €</td>
</ng-container>
<ng-container matColumnDef="startdate">
<th mat-header-cell *matHeaderCellDef>Beginn</th>
<td mat-cell *matCellDef="let element">{{element.startdate}}</td>
</ng-container>
<ng-container matColumnDef="enddate">
<th mat-header-cell *matHeaderCellDef>Ende</th>
<td mat-cell *matCellDef="let element">{{element.enddate}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/overheadadvance/', row.id]"></tr>
</table>
</div>
</mat-card-content>
</mat-card>
</section>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OverheadAdvanceListComponent } from './overhead-advance-list.component';
describe('OverheadAdvanceListComponent', () => {
let component: OverheadAdvanceListComponent;
let fixture: ComponentFixture<OverheadAdvanceListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ OverheadAdvanceListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(OverheadAdvanceListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,41 @@
import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { OverheadAdvanceService } from '../data-object-service';
import { OverheadAdvance } from '../data-objects';
import { MessageService } from '../message.service';
@Component({
selector: 'app-overhead-advance-list',
templateUrl: './overhead-advance-list.component.html',
styleUrls: ['./overhead-advance-list.component.css']
})
export class OverheadAdvanceListComponent implements OnInit {
overheadAdvances: OverheadAdvance[]
dataSource: MatTableDataSource<OverheadAdvance>
displayedColumns: string[] = [ "description", "amount", "startdate", "enddate" ]
constructor(
private overheadAdvanceService: OverheadAdvanceService,
private messageService: MessageService
) { }
async getOverheadAdvances(): Promise<void> {
try {
this.messageService.add("Trying to load overheadAdvances")
this.overheadAdvances = await this.overheadAdvanceService.getOverheadAdvances()
this.messageService.add("OverheadAdvances loaded")
this.dataSource = new MatTableDataSource<OverheadAdvance>(this.overheadAdvances)
} catch (err) {
this.messageService.add(`Error in getOverheadAdvances: ${ JSON.stringify(err, undefined, 4) }`)
}
}
ngOnInit(): void {
this.messageService.add("OverheadAdvanceListComponent.ngOnInit")
this.getOverheadAdvances()
}
}