Files
hv2-all-in-one/ui/hv2-ui/src/app/fee-list/fee-list.component.ts

43 lines
1.1 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { FeeService } from '../data-object-service';
import { Fee } from '../data-objects';
import { MessageService } from '../message.service';
@Component({
selector: 'app-fee-list',
templateUrl: './fee-list.component.html',
styleUrls: ['./fee-list.component.css']
})
export class FeeListComponent implements OnInit {
fees: Fee[]
dataSource: MatTableDataSource<Fee>
displayedColumns: string[] = [ "description", "amount", "fee_type", "startdate", "enddate" ]
constructor(
private feeService: FeeService,
private messageService: MessageService
) { }
async getFees(): Promise<void> {
try {
this.messageService.add("Trying to load fees")
this.fees = await this.feeService.getFees()
this.messageService.add("Fees loaded")
this.dataSource = new MatTableDataSource<Fee>(this.fees)
} catch (err) {
this.messageService.add(`Error in getFees: ${ JSON.stringify(err, undefined, 4) }`)
}
}
ngOnInit(): void {
this.messageService.add("FeeListComponent.ngOnInit")
this.getFees()
}
}