add new pages
This commit is contained in:
3
ui/hv2-ui/src/app/my-premises/my-premises.component.css
Normal file
3
ui/hv2-ui/src/app/my-premises/my-premises.component.css
Normal file
@ -0,0 +1,3 @@
|
||||
table {
|
||||
width: 75%;
|
||||
}
|
33
ui/hv2-ui/src/app/my-premises/my-premises.component.html
Normal file
33
ui/hv2-ui/src/app/my-premises/my-premises.component.html
Normal file
@ -0,0 +1,33 @@
|
||||
<section class="mat-typography">
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
Meine Häuser
|
||||
</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="street">
|
||||
<th mat-header-cell *matHeaderCellDef>Strasse</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.street}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="zip">
|
||||
<th mat-header-cell *matHeaderCellDef>PLZ</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.zip}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="city">
|
||||
<th mat-header-cell *matHeaderCellDef>Ort</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.city}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/premise/', row.id]"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</section>
|
25
ui/hv2-ui/src/app/my-premises/my-premises.component.spec.ts
Normal file
25
ui/hv2-ui/src/app/my-premises/my-premises.component.spec.ts
Normal file
@ -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<MyPremisesComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ MyPremisesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MyPremisesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
37
ui/hv2-ui/src/app/my-premises/my-premises.component.ts
Normal file
37
ui/hv2-ui/src/app/my-premises/my-premises.component.ts
Normal file
@ -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<Premise>
|
||||
displayedColumns: string[] = [ "description", "street", "zip", "city" ]
|
||||
|
||||
constructor(private premiseService: PremiseService, private messageService: MessageService) { }
|
||||
|
||||
async getPremises(): Promise<void> {
|
||||
try {
|
||||
this.messageService.add("Trying to load premises")
|
||||
this.premises = await this.premiseService.getPremises()
|
||||
this.messageService.add("Premises loaded")
|
||||
|
||||
this.dataSource = new MatTableDataSource<Premise>(this.premises)
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.messageService.add("MyPremisesComponent.ngOnInit")
|
||||
this.getPremises()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user