Feature/add value to position detail dialog (#492)

* Add value to position detail dialog

* Update changelog
pull/493/head
Thomas Kaul 3 years ago committed by GitHub
parent 705441ecf8
commit 72067459d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Added
- Added the value to the position detail dialog
### Changed ### Changed
- Upgraded `angular` from version `12.2.4` to `13.0.2` - Upgraded `angular` from version `12.2.4` to `13.0.2`

@ -19,6 +19,7 @@ export interface PortfolioPositionDetail {
quantity: number; quantity: number;
symbol: string; symbol: string;
transactionCount: number; transactionCount: number;
value: number;
} }
export interface HistoricalDataContainer { export interface HistoricalDataContainer {

@ -370,7 +370,8 @@ export class PortfolioController {
'grossPerformance', 'grossPerformance',
'investment', 'investment',
'netPerformance', 'netPerformance',
'quantity' 'quantity',
'value'
]); ]);
} }

@ -391,7 +391,8 @@ export class PortfolioService {
netPerformancePercent: undefined, netPerformancePercent: undefined,
quantity: undefined, quantity: undefined,
symbol: aSymbol, symbol: aSymbol,
transactionCount: undefined transactionCount: undefined,
value: undefined
}; };
} }
@ -527,7 +528,12 @@ export class PortfolioService {
historicalData: historicalDataArray, historicalData: historicalDataArray,
netPerformancePercent: position.netPerformancePercentage.toNumber(), netPerformancePercent: position.netPerformancePercentage.toNumber(),
quantity: quantity.toNumber(), quantity: quantity.toNumber(),
symbol: aSymbol symbol: aSymbol,
value: this.exchangeRateDataService.toCurrency(
quantity.mul(marketPrice).toNumber(),
currency,
userCurrency
)
}; };
} else { } else {
const currentData = await this.dataProviderService.get([ const currentData = await this.dataProviderService.get([
@ -584,7 +590,8 @@ export class PortfolioService {
netPerformancePercent: undefined, netPerformancePercent: undefined,
quantity: 0, quantity: 0,
symbol: aSymbol, symbol: aSymbol,
transactionCount: undefined transactionCount: undefined,
value: 0
}; };
} }
} }

@ -1,4 +1,8 @@
<span class="flex-grow-1 text-truncate">{{ title }}</span> <span
class="flex-grow-1 text-truncate"
[ngClass]="{ 'text-center': position === 'center' }"
>{{ title }}</span
>
<button <button
*ngIf="deviceType !== 'mobile'" *ngIf="deviceType !== 'mobile'"
class="no-min-width px-0" class="no-min-width px-0"

@ -16,6 +16,7 @@ import {
}) })
export class DialogHeaderComponent implements OnInit { export class DialogHeaderComponent implements OnInit {
@Input() deviceType: string; @Input() deviceType: string;
@Input() position: 'center' | 'left' = 'left';
@Input() title: string; @Input() title: string;
@Output() closeButtonClicked = new EventEmitter<void>(); @Output() closeButtonClicked = new EventEmitter<void>();

@ -43,6 +43,7 @@ export class PositionDetailDialog implements OnDestroy {
public quantityPrecision = 2; public quantityPrecision = 2;
public symbol: string; public symbol: string;
public transactionCount: number; public transactionCount: number;
public value: number;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -73,7 +74,8 @@ export class PositionDetailDialog implements OnDestroy {
netPerformancePercent, netPerformancePercent,
quantity, quantity,
symbol, symbol,
transactionCount transactionCount,
value
}) => { }) => {
this.assetSubClass = assetSubClass; this.assetSubClass = assetSubClass;
this.averagePrice = averagePrice; this.averagePrice = averagePrice;
@ -105,6 +107,7 @@ export class PositionDetailDialog implements OnDestroy {
this.quantity = quantity; this.quantity = quantity;
this.symbol = symbol; this.symbol = symbol;
this.transactionCount = transactionCount; this.transactionCount = transactionCount;
this.value = value;
if (isToday(parseISO(this.firstBuyDate))) { if (isToday(parseISO(this.firstBuyDate))) {
// Add average price // Add average price

@ -1,5 +1,6 @@
<gf-dialog-header <gf-dialog-header
mat-dialog-title mat-dialog-title
position="center"
[deviceType]="data.deviceType" [deviceType]="data.deviceType"
[title]="name ?? symbol" [title]="name ?? symbol"
(closeButtonClicked)="onClose()" (closeButtonClicked)="onClose()"
@ -7,6 +8,17 @@
<div class="flex-grow-1" mat-dialog-content> <div class="flex-grow-1" mat-dialog-content>
<div class="container p-0"> <div class="container p-0">
<div class="row">
<div class="col-12 d-flex justify-content-center mb-3">
<gf-value
size="large"
[currency]="data.baseCurrency"
[locale]="data.locale"
[value]="value"
></gf-value>
</div>
</div>
<gf-line-chart <gf-line-chart
class="mb-4" class="mb-4"
benchmarkLabel="Buy Price" benchmarkLabel="Buy Price"

@ -8,10 +8,18 @@
<div *ngIf="value > 0" class="mr-1 text-success">+</div> <div *ngIf="value > 0" class="mr-1 text-success">+</div>
<div *ngIf="value < 0" class="mr-1 text-danger">-</div> <div *ngIf="value < 0" class="mr-1 text-danger">-</div>
</ng-container> </ng-container>
<div *ngIf="isPercent" [ngClass]="size === 'medium' ? 'h4 mb-0' : ''"> <div
*ngIf="isPercent"
class="mb-0"
[ngClass]="{ h2: size === 'large', h4: size === 'medium' }"
>
{{ formattedValue }}% {{ formattedValue }}%
</div> </div>
<div *ngIf="!isPercent" [ngClass]="size === 'medium' ? 'h4 mb-0' : ''"> <div
*ngIf="!isPercent"
class="mb-0"
[ngClass]="{ h2: size === 'large', h4: size === 'medium' }"
>
<ng-container *ngIf="value === null"> <ng-container *ngIf="value === null">
<span class="text-monospace text-muted">***</span> <span class="text-monospace text-muted">***</span>
</ng-container> </ng-container>
@ -27,7 +35,10 @@
</div> </div>
</ng-container> </ng-container>
<ng-container *ngIf="isDate"> <ng-container *ngIf="isDate">
<div [ngClass]="size === 'medium' ? 'h4 mb-0' : ''"> <div
class="mb-0"
[ngClass]="{ h2: size === 'large', h4: size === 'medium' }"
>
{{ formattedDate }} {{ formattedDate }}
</div> </div>
</ng-container> </ng-container>
@ -41,7 +52,7 @@
*ngIf="value === undefined" *ngIf="value === undefined"
animation="pulse" animation="pulse"
[theme]="{ [theme]="{
height: '1.5rem', height: size === 'large' ? '2.5rem' : '1.5rem',
width: '5rem' width: '5rem'
}" }"
></ngx-skeleton-loader> ></ngx-skeleton-loader>

@ -24,7 +24,7 @@ export class ValueComponent implements OnChanges {
@Input() locale = ''; @Input() locale = '';
@Input() position = ''; @Input() position = '';
@Input() precision: number | undefined; @Input() precision: number | undefined;
@Input() size = ''; @Input() size: 'large' | 'medium' | 'small' = 'small';
@Input() value: number | string = ''; @Input() value: number | string = '';
public absoluteValue = 0; public absoluteValue = 0;

Loading…
Cancel
Save