add new pages

This commit is contained in:
2021-08-30 15:55:08 +02:00
parent 083badeacc
commit 829aefc514
28 changed files with 538 additions and 40 deletions

View File

@ -0,0 +1,3 @@
table {
width: 75%;
}

View File

@ -0,0 +1,33 @@
<section class="mat-typography">
<mat-card class="defaultCard">
<mat-card-header>
<mat-card-title>
Meine Wohnungen
</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="premise">
<th mat-header-cell *matHeaderCellDef>Haus</th>
<td mat-cell *matCellDef="let element">{{element.premise}}</td>
</ng-container>
<ng-container matColumnDef="area">
<th mat-header-cell *matHeaderCellDef>Wohnfläche</th>
<td mat-cell *matCellDef="let element">{{element.area}}</td>
</ng-container>
<ng-container matColumnDef="flat_no">
<th mat-header-cell *matHeaderCellDef>Wohnungsnummer</th>
<td mat-cell *matCellDef="let element">{{element.flat_no}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/flat/', 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 { MyFlatsComponent } from './my-flats.component';
describe('MyFlatsComponent', () => {
let component: MyFlatsComponent;
let fixture: ComponentFixture<MyFlatsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ MyFlatsComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(MyFlatsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,37 @@
import { Component, OnInit } from '@angular/core';
import { MessageService } from '../message.service';
import { FlatService } from '../data-object-service';
import { Flat } from '../data-objects';
import { MatTableDataSource } from '@angular/material/table'
@Component({
selector: 'app-my-flats',
templateUrl: './my-flats.component.html',
styleUrls: ['./my-flats.component.css']
})
export class MyFlatsComponent implements OnInit {
flats: Flat[]
dataSource: MatTableDataSource<Flat>
displayedColumns: string[] = ["description", "premise", "area", "flat_no"]
constructor(private flatService: FlatService, private messageService: MessageService) { }
async getFlats(): Promise<void> {
try {
this.messageService.add("Trying to load flats")
this.flats = await this.flatService.getFlats()
this.messageService.add("Flats loaded")
this.dataSource = new MatTableDataSource<Flat>(this.flats)
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))
}
}
ngOnInit(): void {
this.messageService.add("MyFlatsComponent.ngOnInit")
this.getFlats()
}
}