Add depot mechanics2
This commit is contained in:
parent
e592a0805a
commit
7ada44ea23
@ -3,7 +3,7 @@
|
|||||||
<mat-grid-tile colspan="1" rowspan="2">
|
<mat-grid-tile colspan="1" rowspan="2">
|
||||||
<div class="stockOverview">
|
<div class="stockOverview">
|
||||||
<div class="heading">
|
<div class="heading">
|
||||||
<div class="vertical-center">Aktienübersicht</div>
|
<div class="vertical-center">Stocks</div>
|
||||||
</div>
|
</div>
|
||||||
<mat-card class="placeholder">
|
<mat-card class="placeholder">
|
||||||
<div class="stockTableLHS">
|
<div class="stockTableLHS">
|
||||||
@ -51,16 +51,55 @@
|
|||||||
<mat-grid-tile colspan="1" rowspan="1" class="right-side">
|
<mat-grid-tile colspan="1" rowspan="1" class="right-side">
|
||||||
<div class="depotOverview">
|
<div class="depotOverview">
|
||||||
<div class="heading fix-right-side">
|
<div class="heading fix-right-side">
|
||||||
<div class="vertical-center">Depotübersicht</div>
|
<div class="vertical-center">Depot</div>
|
||||||
</div>
|
</div>
|
||||||
<mat-card class="placeholderRHS"></mat-card>
|
<mat-card class="placeholderRHS content-container">
|
||||||
|
<div class="content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="value-set">
|
||||||
|
<h3>Portfolio Value</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="value-set">
|
||||||
|
<h3>Portfolio Cost</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="value-set">
|
||||||
|
<h3>Portfolio Profit</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6 col-sm-4">
|
||||||
|
<mat-icon>savings</mat-icon
|
||||||
|
><span class="money">{{ depotCurrentValue.toFixed(2) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 col-sm-4">
|
||||||
|
<mat-icon>paid</mat-icon
|
||||||
|
><span class="money">{{ depotCost.toFixed(2) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 col-sm-4">
|
||||||
|
<mat-icon>account_balance</mat-icon
|
||||||
|
><span
|
||||||
|
class="money"
|
||||||
|
[ngClass]="{ green: profit >= 0, red: profit < 0 }"
|
||||||
|
>{{ profit.toFixed(2) }}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
</mat-grid-tile>
|
</mat-grid-tile>
|
||||||
<!-- Transaktions -->
|
<!-- Transaktions -->
|
||||||
<mat-grid-tile colspan="1" rowspan="1" class="right-side">
|
<mat-grid-tile colspan="1" rowspan="1" class="right-side">
|
||||||
<div class="depotOverviewDown">
|
<div class="depotOverviewDown">
|
||||||
<div class="heading fix-right-side">
|
<div class="heading fix-right-side">
|
||||||
<div class="vertical-center">Transaktionen</div>
|
<div class="vertical-center">Transactions</div>
|
||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
margin-top: 10%;
|
margin-top: 10%;
|
||||||
margin-left: 5%;
|
margin-left: 5%;
|
||||||
margin-right: 10%;
|
margin-right: 10%;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.depotOverviewDown {
|
.depotOverviewDown {
|
||||||
@ -40,6 +41,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fix-right-side {
|
.fix-right-side {
|
||||||
@ -60,7 +63,6 @@
|
|||||||
|
|
||||||
.add-icon {
|
.add-icon {
|
||||||
transform: scale(2);
|
transform: scale(2);
|
||||||
margin-top: 2%;
|
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,10 +82,32 @@ table {
|
|||||||
height: 80%;
|
height: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
side-heading {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-ripple-element {
|
.mat-ripple-element {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.money {
|
||||||
|
margin-left: 2vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.green {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.red {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
height: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
height: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-container {
|
||||||
|
width: 100%;
|
||||||
|
display: grid;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { DataService } from 'src/app/Services/data.service';
|
import { DataService } from 'src/app/Services/data.service';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { UserDialogComponent } from './user-dialog/user-dialog.component';
|
import { UserDialogComponent } from './user-dialog/user-dialog.component';
|
||||||
|
import { C } from '@angular/cdk/keycodes';
|
||||||
|
import { HelperService } from 'src/app/Helpers/helper.service';
|
||||||
|
|
||||||
export interface PeriodicElement {
|
export interface PeriodicElement {
|
||||||
name: string;
|
name: string;
|
||||||
@ -41,16 +43,23 @@ export interface TransactionData {
|
|||||||
styleUrls: ['./dashboard.component.scss'],
|
styleUrls: ['./dashboard.component.scss'],
|
||||||
})
|
})
|
||||||
export class DashboardComponent implements OnInit {
|
export class DashboardComponent implements OnInit {
|
||||||
constructor(private dataService: DataService, public dialog: MatDialog) {}
|
constructor(
|
||||||
|
private helper: HelperService,
|
||||||
|
private dataService: DataService,
|
||||||
|
public dialog: MatDialog
|
||||||
|
) {}
|
||||||
|
|
||||||
dataSourceTransactions: TransactionData[] = [];
|
dataSourceTransactions: TransactionData[] = [];
|
||||||
dataSourceStocks: Stock[] = [];
|
dataSourceStocks: Stock[] = [];
|
||||||
|
depotCurrentValue: number = 0;
|
||||||
|
depotCost: number = 0;
|
||||||
|
profit: number = 0;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.dataService.getStockData().subscribe((response: any) => {
|
this.dataService.getStockData().subscribe((response: any) => {
|
||||||
console.log('PORTFOLIO:' + response);
|
|
||||||
var data = JSON.parse(response);
|
var data = JSON.parse(response);
|
||||||
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;
|
||||||
STOCK_DATA.push({
|
STOCK_DATA.push({
|
||||||
count: data.data[i].count,
|
count: data.data[i].count,
|
||||||
currentPrice: data.data[i].current_price,
|
currentPrice: data.data[i].current_price,
|
||||||
@ -58,14 +67,16 @@ export class DashboardComponent implements OnInit {
|
|||||||
time: data.data[i].last_transaction,
|
time: data.data[i].last_transaction,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(STOCK_DATA);
|
|
||||||
this.dataSourceStocks = STOCK_DATA;
|
this.dataSourceStocks = STOCK_DATA;
|
||||||
//TODO move to helper service
|
//TODO move to helper service
|
||||||
|
|
||||||
|
this.profit += this.depotCurrentValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dataService.getTransactionData().subscribe((response: any) => {
|
this.dataService.getTransactionData().subscribe((response: any) => {
|
||||||
console.log('TRANSACTIONS:' + response);
|
|
||||||
var data = JSON.parse(response);
|
var data = JSON.parse(response);
|
||||||
for (let i = 0; i < data.data.length; i++) {
|
for (let i = 0; i < data.data.length; i++) {
|
||||||
|
this.depotCost += data.data[i].price;
|
||||||
TRANSACTION_DATA.push({
|
TRANSACTION_DATA.push({
|
||||||
symbol: data.data[i].symbol,
|
symbol: data.data[i].symbol,
|
||||||
time: data.data[i].time,
|
time: data.data[i].time,
|
||||||
@ -73,9 +84,10 @@ export class DashboardComponent implements OnInit {
|
|||||||
price: data.data[i].price,
|
price: data.data[i].price,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(TRANSACTION_DATA);
|
|
||||||
this.dataSourceTransactions = TRANSACTION_DATA;
|
this.dataSourceTransactions = TRANSACTION_DATA;
|
||||||
//TODO move to helper service
|
//TODO move to helper service
|
||||||
|
|
||||||
|
this.profit -= this.depotCost;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user