Improve code quality and add comments
This commit is contained in:
@@ -41,6 +41,12 @@ export class DashboardComponent implements OnInit {
|
||||
depotCost: number = 0;
|
||||
profit: number = 0;
|
||||
|
||||
comment: string = '';
|
||||
isin: string = '';
|
||||
time: Date = new Date();
|
||||
count: number = 0.0;
|
||||
price: number = 0.0;
|
||||
|
||||
getTransactions() {
|
||||
var TRANSACTION_DATA: TransactionData[] = [];
|
||||
this.dataService.getTransactionData().subscribe((response: any) => {
|
||||
@@ -64,6 +70,9 @@ export class DashboardComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
/**
|
||||
* Function gets the stock data and pushes it in the temporary object array
|
||||
*/
|
||||
this.dataService.getStockData().subscribe((response: any) => {
|
||||
var data = JSON.parse(response);
|
||||
console.log(data);
|
||||
@@ -78,11 +87,14 @@ export class DashboardComponent implements OnInit {
|
||||
current_price: data.data[i].current_price,
|
||||
});
|
||||
}
|
||||
console.log(STOCK_DATA);
|
||||
// assign data source
|
||||
this.dataSourceStocks = STOCK_DATA;
|
||||
this.profit += this.depotCurrentValue;
|
||||
});
|
||||
|
||||
/**
|
||||
* Function gets the transaction data and pushes it in the temporary object array
|
||||
*/
|
||||
this.dataService.getTransactionData().subscribe((response: any) => {
|
||||
var data = JSON.parse(response);
|
||||
this.depotCost = 0;
|
||||
@@ -96,19 +108,13 @@ export class DashboardComponent implements OnInit {
|
||||
price: data.data[i].price,
|
||||
});
|
||||
}
|
||||
// assign data source
|
||||
this.dataSourceTransactions = TRANSACTION_DATA;
|
||||
//TODO move to helper service
|
||||
|
||||
this.profit += this.depotCost;
|
||||
});
|
||||
}
|
||||
|
||||
comment: string = '';
|
||||
isin: string = '';
|
||||
time: Date = new Date();
|
||||
count: number = 0.0;
|
||||
price: number = 0.0;
|
||||
|
||||
// function to open the user dialog to create a new transaction
|
||||
openDialog(): void {
|
||||
const dialogRef = this.dialog.open(UserDialogComponent, {
|
||||
width: '50vw',
|
||||
@@ -127,6 +133,7 @@ export class DashboardComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
// assign columns for transactions to display in html, you can change order and add/remove columns
|
||||
displayedColumns: string[] = [
|
||||
'comment',
|
||||
'weight',
|
||||
@@ -134,6 +141,8 @@ export class DashboardComponent implements OnInit {
|
||||
'name',
|
||||
'symbol',
|
||||
];
|
||||
|
||||
// assign columns to display in html, you can change order and add/remove columns
|
||||
displayedColumnsStocks: string[] = [
|
||||
'count',
|
||||
'comment',
|
||||
|
||||
Reference in New Issue
Block a user