Browse Source

Merge 23406cd545 into ed364fc25f

pull/5570/merge
Batwam 2 weeks ago
committed by GitHub
parent
commit
ac9b4a2651
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 38
      apps/client/src/app/components/home-overview/home-overview.component.ts
  2. 3
      apps/client/src/app/components/home-overview/home-overview.html
  3. 17
      apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html
  4. 7
      apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

38
apps/client/src/app/components/home-overview/home-overview.component.ts

@ -61,6 +61,8 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
public showDetails = false; public showDetails = false;
public unit: string; public unit: string;
public user: User; public user: User;
private graph_type: string;
public graph_unit: string;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
@ -97,6 +99,11 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
this.unit = this.showDetails ? this.user.settings.baseCurrency : '%'; this.unit = this.showDetails ? this.user.settings.baseCurrency : '%';
this.graph_type = !this.showDetails
? 'netPerformanceInPercentageWithCurrencyEffect'
: (localStorage.getItem('home_overview_graph_type') ??
'netPerformanceInPercentageWithCurrencyEffect');
this.impersonationStorageService this.impersonationStorageService
.onChangeHasImpersonation() .onChangeHasImpersonation()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -131,14 +138,21 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
this.errors = errors; this.errors = errors;
this.performance = performance; this.performance = performance;
this.historicalDataItems = chart.map( const graph_multiplier =
({ date, netPerformanceInPercentageWithCurrencyEffect }) => { this.graph_type === 'netPerformanceInPercentageWithCurrencyEffect'
return { ? 100
date, : 1;
value: netPerformanceInPercentageWithCurrencyEffect * 100 this.graph_unit =
}; this.graph_type === 'netPerformanceInPercentageWithCurrencyEffect'
} ? '%'
); : this.unit;
this.historicalDataItems = chart.map((item) => {
return {
date: item.date,
value: item[this.graph_type] * graph_multiplier
};
});
if ( if (
this.deviceType === 'mobile' && this.deviceType === 'mobile' &&
@ -155,4 +169,12 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
public onMetricClick(selectedgraph_type: string): void {
if (this.graph_type !== selectedgraph_type) {
this.graph_type = selectedgraph_type;
localStorage.setItem('home_overview_graph_type', this.graph_type);
this.update();
}
}
} }

3
apps/client/src/app/components/home-overview/home-overview.html

@ -69,7 +69,6 @@
<div class="chart-container mx-auto position-relative"> <div class="chart-container mx-auto position-relative">
<gf-line-chart <gf-line-chart
class="position-absolute" class="position-absolute"
unit="%"
[colorScheme]="user?.settings?.colorScheme" [colorScheme]="user?.settings?.colorScheme"
[hidden]="historicalDataItems?.length === 0" [hidden]="historicalDataItems?.length === 0"
[historicalDataItems]="historicalDataItems" [historicalDataItems]="historicalDataItems"
@ -81,6 +80,7 @@
[showLoader]="false" [showLoader]="false"
[showXAxis]="false" [showXAxis]="false"
[showYAxis]="false" [showYAxis]="false"
[unit]="graph_unit"
/> />
</div> </div>
</div> </div>
@ -99,6 +99,7 @@
[precision]="precision" [precision]="precision"
[showDetails]="showDetails" [showDetails]="showDetails"
[unit]="unit" [unit]="unit"
(metricClick)="onMetricClick($event)"
/> />
</div> </div>
</div> </div>

17
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html

@ -30,7 +30,12 @@
'text-success': isAllTimeHigh 'text-success': isAllTimeHigh
}" }"
> >
<span #value id="value"></span> @if (!showDetails) {
<span #value id="value"></span>
}
@if (showDetails) {
<span #value id="value" (click)="onMetricClick('value')"></span>
}
</div> </div>
<div class="currency-container flex-grow-1 px-1"> <div class="currency-container flex-grow-1 px-1">
{{ unit }} {{ unit }}
@ -38,7 +43,10 @@
</div> </div>
@if (showDetails) { @if (showDetails) {
<div class="row"> <div class="row">
<div class="d-flex col justify-content-end"> <div
class="d-flex col justify-content-end"
(click)="onMetricClick('netPerformanceWithCurrencyEffect')"
>
<gf-value <gf-value
[colorizeSign]="true" [colorizeSign]="true"
[isCurrency]="true" [isCurrency]="true"
@ -50,7 +58,10 @@
" "
/> />
</div> </div>
<div class="col"> <div
class="col"
(click)="onMetricClick('netPerformanceInPercentageWithCurrencyEffect')"
>
<gf-value <gf-value
[colorizeSign]="true" [colorizeSign]="true"
[isPercent]="true" [isPercent]="true"

7
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

@ -17,6 +17,8 @@ import {
ElementRef, ElementRef,
Input, Input,
OnChanges, OnChanges,
Output,
EventEmitter,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { IonIcon } from '@ionic/angular/standalone'; import { IonIcon } from '@ionic/angular/standalone';
@ -44,6 +46,7 @@ export class GfPortfolioPerformanceComponent implements OnChanges {
@Input() precision: number; @Input() precision: number;
@Input() showDetails: boolean; @Input() showDetails: boolean;
@Input() unit: string; @Input() unit: string;
@Output() metricClick = new EventEmitter<string>();
@ViewChild('value') value: ElementRef; @ViewChild('value') value: ElementRef;
@ -95,4 +98,8 @@ export class GfPortfolioPerformanceComponent implements OnChanges {
title: $localize`Market data is delayed for` title: $localize`Market data is delayed for`
}); });
} }
public onMetricClick(selectedChoice: string): void {
this.metricClick.emit(selectedChoice); // notify parent
}
} }

Loading…
Cancel
Save