add new pages
This commit is contained in:
3
ui/hv2-ui/src/app/my-tenants/my-tenants.component.css
Normal file
3
ui/hv2-ui/src/app/my-tenants/my-tenants.component.css
Normal file
@ -0,0 +1,3 @@
|
||||
table {
|
||||
width: 75%;
|
||||
}
|
29
ui/hv2-ui/src/app/my-tenants/my-tenants.component.html
Normal file
29
ui/hv2-ui/src/app/my-tenants/my-tenants.component.html
Normal file
@ -0,0 +1,29 @@
|
||||
<section class="mat-typography">
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
Meine Mieter/innen
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div>
|
||||
<table mat-table [dataSource]="dataSource" #zftable>
|
||||
<ng-container matColumnDef="lastname">
|
||||
<th mat-header-cell *matHeaderCellDef>Nachname</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.lastname}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="firstname">
|
||||
<th mat-header-cell *matHeaderCellDef>Vorname</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.firstname}}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="address1">
|
||||
<th mat-header-cell *matHeaderCellDef>Adresse 1</th>
|
||||
<td mat-cell *matCellDef="let element">{{element.address1}}</td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/tenant/', row.id]"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</section>
|
25
ui/hv2-ui/src/app/my-tenants/my-tenants.component.spec.ts
Normal file
25
ui/hv2-ui/src/app/my-tenants/my-tenants.component.spec.ts
Normal file
@ -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<MyTenantsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ MyTenantsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MyTenantsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
37
ui/hv2-ui/src/app/my-tenants/my-tenants.component.ts
Normal file
37
ui/hv2-ui/src/app/my-tenants/my-tenants.component.ts
Normal file
@ -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<Tenant>
|
||||
displayedColumns: string[] = ["lastname", "firstname", "address1"]
|
||||
|
||||
constructor(private tenantService: TenantService, private messageService: MessageService) { }
|
||||
|
||||
async getTenants(): Promise<void> {
|
||||
try {
|
||||
this.messageService.add("Trying to load tenants")
|
||||
this.tenants = await this.tenantService.getTenants()
|
||||
this.messageService.add("Tenants loaded")
|
||||
|
||||
this.dataSource = new MatTableDataSource<Tenant>(this.tenants)
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.messageService.add("MyTenantsComponent.ngOnInit")
|
||||
this.getTenants()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user