Fix Stock pannel and data

This commit is contained in:
kevinpauer 2022-05-03 11:29:55 +02:00
parent 7f671c96ce
commit 653762545e
2 changed files with 37 additions and 26 deletions

View File

@ -12,28 +12,36 @@
The actual rendered columns are set as a property on the row definition" --> The actual rendered columns are set as a property on the row definition" -->
<!-- Symbol Column --> <!-- Symbol Column -->
<ng-container matColumnDef="position"> <ng-container matColumnDef="count">
<th mat-header-cell *matHeaderCellDef>Symbol</th>
<td mat-cell *matCellDef="let element">{{ element.symbol }}</td>
</ng-container>
<!-- Count Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Count</th> <th mat-header-cell *matHeaderCellDef>Count</th>
<td mat-cell *matCellDef="let element">{{ element.count }}</td> <td mat-cell *matCellDef="let element">{{ element.count }}</td>
</ng-container> </ng-container>
<!-- Time Column --> <!-- Count Column -->
<ng-container matColumnDef="weight"> <ng-container matColumnDef="comment">
<th mat-header-cell *matHeaderCellDef>Time</th> <th mat-header-cell *matHeaderCellDef>Comment</th>
<td mat-cell *matCellDef="let element">{{ element.time }}</td> <td mat-cell *matCellDef="let element">{{ element.comment }}</td>
</ng-container> </ng-container>
<!-- Time Column --> <!-- Time Column -->
<ng-container matColumnDef="current-price"> <ng-container matColumnDef="isin">
<th mat-header-cell *matHeaderCellDef>Current Price</th> <th mat-header-cell *matHeaderCellDef>ISIN</th>
<td mat-cell *matCellDef="let element">{{ element.isin }}</td>
</ng-container>
<!-- Symbol Column -->
<ng-container matColumnDef="current_price">
<th mat-header-cell *matHeaderCellDef>Price</th>
<td mat-cell *matCellDef="let element"> <td mat-cell *matCellDef="let element">
{{ element.currentPrice }} {{ element.current_price }}
</td>
</ng-container>
<!-- Time Column -->
<ng-container matColumnDef="last_transaction">
<th mat-header-cell *matHeaderCellDef>Last Transaction</th>
<td mat-cell *matCellDef="let element">
{{ element.last_transaction }}
</td> </td>
</ng-container> </ng-container>

View File

@ -6,9 +6,10 @@ import { HelperService } from 'src/app/Helpers/helper.service';
export interface Stock { export interface Stock {
count: number; count: number;
currentPrice: number; comment: string;
symbol: string; isin: string;
time: string; last_transaction: string;
current_price: number;
} }
var TRANSACTION_DATA: TransactionData[] = []; var TRANSACTION_DATA: TransactionData[] = [];
@ -65,19 +66,20 @@ export class DashboardComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.dataService.getStockData().subscribe((response: any) => { this.dataService.getStockData().subscribe((response: any) => {
var data = JSON.parse(response); var data = JSON.parse(response);
console.log(data);
this.depotCurrentValue = 0; this.depotCurrentValue = 0;
for (let i = 0; i < data.data.length; i++) { for (let i = 0; i < data.data.length; i++) {
this.depotCurrentValue = data.data[i].current_price; this.depotCurrentValue = data.data[i].current_price;
STOCK_DATA.push({ STOCK_DATA.push({
count: data.data[i].count, count: data.data[i].count,
currentPrice: data.data[i].current_price, comment: data.data[i].comment,
symbol: data.data[i].symbol, isin: data.data[i].isin,
time: data.data[i].last_transaction, last_transaction: data.data[i].last_transaction,
current_price: data.data[i].current_price,
}); });
} }
console.log(STOCK_DATA);
this.dataSourceStocks = STOCK_DATA; this.dataSourceStocks = STOCK_DATA;
//TODO move to helper service
this.profit += this.depotCurrentValue; this.profit += this.depotCurrentValue;
}); });
@ -133,9 +135,10 @@ export class DashboardComponent implements OnInit {
'symbol', 'symbol',
]; ];
displayedColumnsStocks: string[] = [ displayedColumnsStocks: string[] = [
'position', 'count',
'name', 'comment',
'weight', 'isin',
'current-price', 'current_price',
'last_transaction',
]; ];
} }