44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
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'
|
|
import { Tenant_with_Saldo } from '../ext-data-objects';
|
|
import { ExtApiService } from '../ext-data-object-service';
|
|
|
|
|
|
@Component({
|
|
selector: 'app-my-tenants',
|
|
templateUrl: './my-tenants.component.html',
|
|
styleUrls: ['./my-tenants.component.css']
|
|
})
|
|
export class MyTenantsComponent implements OnInit {
|
|
|
|
tenants: Tenant_with_Saldo[]
|
|
dataSource: MatTableDataSource<Tenant_with_Saldo>
|
|
displayedColumns: string[] = ["lastname", "firstname", "address1", "saldo"]
|
|
|
|
constructor(
|
|
private extApiService: ExtApiService,
|
|
private messageService: MessageService
|
|
) { }
|
|
|
|
async getTenants(): Promise<void> {
|
|
try {
|
|
this.messageService.add("Trying to load tenants")
|
|
this.tenants = await this.extApiService.getTenantsWithSaldo()
|
|
this.messageService.add("Tenants loaded")
|
|
|
|
this.dataSource = new MatTableDataSource<Tenant_with_Saldo>(this.tenants)
|
|
} catch (err) {
|
|
this.messageService.add(JSON.stringify(err, undefined, 4))
|
|
}
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.messageService.add("MyTenantsComponent.ngOnInit")
|
|
this.getTenants()
|
|
}
|
|
|
|
}
|