Fix wrong dataSource

This commit is contained in:
kevinpauer 2022-04-05 19:43:35 +02:00
parent 4c7506d8b2
commit 7c5c993d2f
2 changed files with 20 additions and 6 deletions

View File

@ -7,28 +7,36 @@
</div> </div>
<mat-card class="placeholder"> <mat-card class="placeholder">
<div class="stockTable"> <div class="stockTable">
<table mat-table [dataSource]="dataSourceTransactions"> <table mat-table [dataSource]="dataSourceStocks">
<!--- Note that these columns can be defined in any order. <!--- Note that these columns can be defined in any order.
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" -->
<!-- Position Column --> <!-- Symbol Column -->
<ng-container matColumnDef="position"> <ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef>Symbol</th> <th mat-header-cell *matHeaderCellDef>Symbol</th>
<td mat-cell *matCellDef="let element">{{ element.symbol }}</td> <td mat-cell *matCellDef="let element">{{ element.symbol }}</td>
</ng-container> </ng-container>
<!-- Name Column --> <!-- Count Column -->
<ng-container matColumnDef="name"> <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>
<!-- Weight Column --> <!-- Time Column -->
<ng-container matColumnDef="weight"> <ng-container matColumnDef="weight">
<th mat-header-cell *matHeaderCellDef>Time</th> <th mat-header-cell *matHeaderCellDef>Time</th>
<td mat-cell *matCellDef="let element">{{ element.time }}</td> <td mat-cell *matCellDef="let element">{{ element.time }}</td>
</ng-container> </ng-container>
<!-- Time Column -->
<ng-container matColumnDef="current-price">
<th mat-header-cell *matHeaderCellDef>Current Price</th>
<td mat-cell *matCellDef="let element">
{{ element.currentPrice }}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumnsStocks"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumnsStocks"></tr>
<tr <tr
mat-row mat-row

View File

@ -12,7 +12,7 @@ export interface PeriodicElement {
export interface Stock { export interface Stock {
count: number; count: number;
// price: number; currentPrice: number;
symbol: string; symbol: string;
time: string; time: string;
} }
@ -53,6 +53,7 @@ export class DashboardComponent implements OnInit {
for (let i = 0; i < data.data.length; i++) { for (let i = 0; i < data.data.length; i++) {
STOCK_DATA.push({ STOCK_DATA.push({
count: data.data[i].count, count: data.data[i].count,
currentPrice: data.data[i].current_price,
symbol: data.data[i].symbol, symbol: data.data[i].symbol,
time: data.data[i].last_transaction, time: data.data[i].last_transaction,
}); });
@ -101,6 +102,11 @@ export class DashboardComponent implements OnInit {
} }
displayedColumns: string[] = ['weight', 'position', 'name', 'symbol']; displayedColumns: string[] = ['weight', 'position', 'name', 'symbol'];
displayedColumnsStocks: string[] = ['position', 'name', 'weight']; displayedColumnsStocks: string[] = [
'position',
'name',
'weight',
'current-price',
];
dataSource = ELEMENT_DATA; dataSource = ELEMENT_DATA;
} }