account at tenant
This commit is contained in:
54
ui/hv2-ui/src/app/account/account.component.ts
Normal file
54
ui/hv2-ui/src/app/account/account.component.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { AccountEntryService, AccountService } from '../data-object-service';
|
||||
import { Account, AccountEntry, NULL_AccountEntry } from '../data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-account',
|
||||
templateUrl: './account.component.html',
|
||||
styleUrls: ['./account.component.css']
|
||||
})
|
||||
export class AccountComponent implements OnInit {
|
||||
|
||||
@Input() selectedAccountId: number
|
||||
|
||||
account: Account
|
||||
accountEntries: AccountEntry[]
|
||||
accountEntriesDataSource: MatTableDataSource<AccountEntry>
|
||||
accountEntriesDisplayedColumns: string[] = [ "description", "amount", "createdAt" ]
|
||||
|
||||
newAccountEntry: AccountEntry = NULL_AccountEntry
|
||||
|
||||
|
||||
constructor(
|
||||
private accountService: AccountService,
|
||||
private accountEntryService: AccountEntryService,
|
||||
private messageService: MessageService
|
||||
) { }
|
||||
|
||||
async getAccountAndEntries(): Promise<void> {
|
||||
try {
|
||||
if (this.selectedAccountId) {
|
||||
this.messageService.add(`Trying to load account ${this.selectedAccountId} and entries`)
|
||||
this.account = await this.accountService.getAccount(this.selectedAccountId)
|
||||
this.messageService.add(`Account: ${JSON.stringify(this.account, undefined, 4)}`)
|
||||
this.accountEntries = await this.accountEntryService.getAccountEntrysByAccount(this.selectedAccountId)
|
||||
this.messageService.add(`AccountEntries: ${JSON.stringify(this.accountEntries, undefined, 4)}`)
|
||||
this.accountEntriesDataSource = new MatTableDataSource<AccountEntry>(this.accountEntries)
|
||||
}
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in getAccountAndEntries: ${JSON.stringify(err, undefined, 4)}`)
|
||||
}
|
||||
}
|
||||
|
||||
addAccountEntry() {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.messageService.add(`AccountComponent.ngOnInit, account: ${this.selectedAccountId}`)
|
||||
this.getAccountAndEntries()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user