add new pages
This commit is contained in:
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