Fix last few bugs

This commit is contained in:
Kevin Pauer 2022-05-10 21:41:59 +02:00
parent bed97bb3d6
commit bf99a78d44
3 changed files with 9 additions and 10 deletions

View File

@ -33,7 +33,7 @@
<ng-container matColumnDef="current_price"> <ng-container matColumnDef="current_price">
<th mat-header-cell *matHeaderCellDef>Price</th> <th mat-header-cell *matHeaderCellDef>Price</th>
<td mat-cell *matCellDef="let element"> <td mat-cell *matCellDef="let element">
{{ element.current_price }}$ {{ element.current_price }}
</td> </td>
</ng-container> </ng-container>
@ -84,18 +84,18 @@
<div class="row"> <div class="row">
<div class="col-6 col-sm-4"> <div class="col-6 col-sm-4">
<mat-icon>savings</mat-icon <mat-icon>savings</mat-icon
><span class="money">{{ depotCurrentValue.toFixed(2) }}$</span> ><span class="money">{{ depotCurrentValue.toFixed(2) }}</span>
</div> </div>
<div class="col-6 col-sm-4"> <div class="col-6 col-sm-4">
<mat-icon>paid</mat-icon <mat-icon>paid</mat-icon
><span class="money">{{ depotCost.toFixed(2) }}$</span> ><span class="money">{{ depotCost.toFixed(2) }}</span>
</div> </div>
<div class="col-6 col-sm-4"> <div class="col-6 col-sm-4">
<mat-icon>account_balance</mat-icon <mat-icon>account_balance</mat-icon
><span ><span
class="money" class="money"
[ngClass]="{ green: profit >= 0, red: profit < 0 }" [ngClass]="{ green: profit >= 0, red: profit < 0 }"
>{{ profit.toFixed(2) }}$</span >{{ profit.toFixed(2) }}</span
> >
</div> </div>
</div> </div>

View File

@ -63,8 +63,6 @@ export class DashboardComponent implements OnInit {
}); });
} }
this.dataSourceTransactions = TRANSACTION_DATA; this.dataSourceTransactions = TRANSACTION_DATA;
//TODO move to helper service
this.profit = this.depotCurrentValue - this.depotCost; this.profit = this.depotCurrentValue - this.depotCost;
}); });
} }
@ -78,7 +76,8 @@ export class DashboardComponent implements OnInit {
console.log(data); 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 * data.data[i].count;
STOCK_DATA.push({ STOCK_DATA.push({
count: data.data[i].count, count: data.data[i].count,
comment: data.data[i].comment, comment: data.data[i].comment,

View File

@ -20,7 +20,7 @@
/> />
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="isin">isin</label> <label for="isin">ISIN/Symbol</label>
<input <input
type="text" type="text"
class="form-control" class="form-control"
@ -29,7 +29,7 @@
required required
isin isin
#isin="ngModel" #isin="ngModel"
placeholder="ex. US02079K3059" placeholder="ex. US02079K3059 / AAPL"
/> />
</div> </div>
<div class="form-group"> <div class="form-group">
@ -61,7 +61,7 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="price">Price in $</label> <label for="price">Price in </label>
<input <input
class="form-control" class="form-control"
name="price" name="price"