42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
import { OverheadAdvanceService } from '../data-object-service';
|
|
import { OverheadAdvance } from '../data-objects';
|
|
import { MessageService } from '../message.service';
|
|
|
|
@Component({
|
|
selector: 'app-overhead-advance-list',
|
|
templateUrl: './overhead-advance-list.component.html',
|
|
styleUrls: ['./overhead-advance-list.component.css']
|
|
})
|
|
export class OverheadAdvanceListComponent implements OnInit {
|
|
|
|
overheadAdvances: OverheadAdvance[]
|
|
dataSource: MatTableDataSource<OverheadAdvance>
|
|
displayedColumns: string[] = [ "description", "amount", "startdate", "enddate" ]
|
|
|
|
constructor(
|
|
private overheadAdvanceService: OverheadAdvanceService,
|
|
private messageService: MessageService
|
|
) { }
|
|
|
|
async getOverheadAdvances(): Promise<void> {
|
|
try {
|
|
this.messageService.add("Trying to load overheadAdvances")
|
|
this.overheadAdvances = await this.overheadAdvanceService.getOverheadAdvances()
|
|
this.messageService.add("OverheadAdvances loaded")
|
|
|
|
this.dataSource = new MatTableDataSource<OverheadAdvance>(this.overheadAdvances)
|
|
} catch (err) {
|
|
this.messageService.add(`Error in getOverheadAdvances: ${ JSON.stringify(err, undefined, 4) }`)
|
|
}
|
|
}
|
|
|
|
|
|
ngOnInit(): void {
|
|
this.messageService.add("OverheadAdvanceListComponent.ngOnInit")
|
|
this.getOverheadAdvances()
|
|
}
|
|
|
|
}
|