add new pages
This commit is contained in:
37
ui/hv2-ui/src/app/my-flats/my-flats.component.ts
Normal file
37
ui/hv2-ui/src/app/my-flats/my-flats.component.ts
Normal 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()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user