Browse Source

Refactoring

pull/6689/head
Thomas Kaul 2 months ago
parent
commit
267e9431b0
  1. 15
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
  2. 30
      apps/client/src/app/pages/portfolio/allocations/allocations-page.html

15
apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

@ -159,8 +159,7 @@ export class GfAllocationsPageComponent implements OnInit {
if (state?.user) {
this.user = state.user;
this.worldMapChartFormat =
this.hasImpersonationId || this.user.settings.isRestrictedView
this.worldMapChartFormat = this.showValuesInPercentage()
? `{0}%`
: `{0} ${this.user?.settings?.baseCurrency}`;
@ -310,7 +309,7 @@ export class GfAllocationsPageComponent implements OnInit {
] of Object.entries(this.portfolioDetails.accounts)) {
let value = 0;
if (this.hasImpersonationId || this.user?.settings?.isRestrictedView) {
if (this.showValuesInPercentage()) {
value = valueInPercentage;
} else {
value = valueInBaseCurrency;
@ -328,7 +327,7 @@ export class GfAllocationsPageComponent implements OnInit {
)) {
let value = 0;
if (this.hasImpersonationId || this.user?.settings?.isRestrictedView) {
if (this.showValuesInPercentage()) {
value = position.allocationInPercentage;
} else {
value = position.valueInBaseCurrency;
@ -491,7 +490,7 @@ export class GfAllocationsPageComponent implements OnInit {
] of Object.entries(this.portfolioDetails.platforms)) {
let value = 0;
if (this.hasImpersonationId || this.user?.settings?.isRestrictedView) {
if (this.showValuesInPercentage()) {
value = valueInPercentage;
} else {
value = valueInBaseCurrency;
@ -506,7 +505,7 @@ export class GfAllocationsPageComponent implements OnInit {
this.topHoldings = Object.values(this.topHoldingsMap)
.map(({ name, value }) => {
if (this.hasImpersonationId || this.user.settings.isRestrictedView) {
if (this.showValuesInPercentage()) {
return {
name,
allocationInPercentage: value,
@ -597,4 +596,8 @@ export class GfAllocationsPageComponent implements OnInit {
this.router.navigate(['.'], { relativeTo: this.route });
});
}
public showValuesInPercentage() {
return this.hasImpersonationId || this.user?.settings?.isRestrictedView;
}
}

30
apps/client/src/app/pages/portfolio/allocations/allocations-page.html

@ -25,11 +25,9 @@
<mat-card-content>
<mat-progress-bar
mode="determinate"
[title]="
`${(
[title]="`${(
portfolioDetails?.summary?.filteredValueInPercentage * 100
).toFixed(2)}%`
"
).toFixed(2)}%`"
[value]="portfolioDetails?.summary?.filteredValueInPercentage * 100"
/>
</mat-card-content>
@ -49,7 +47,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="platforms"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['id']"
[locale]="user?.settings?.locale"
/>
@ -71,7 +69,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="holdings"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['currency']"
[locale]="user?.settings?.locale"
/>
@ -93,7 +91,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="holdings"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['assetClassLabel', 'assetSubClassLabel']"
[locale]="user?.settings?.locale"
/>
@ -114,7 +112,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="symbols"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['symbol']"
[locale]="user?.settings?.locale"
[showLabels]="deviceType !== 'mobile'"
@ -138,7 +136,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="sectors"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['name']"
[locale]="user?.settings?.locale"
[maxItems]="10"
@ -161,7 +159,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="continents"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['name']"
[locale]="user?.settings?.locale"
/>
@ -183,7 +181,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="marketsAdvanced"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[locale]="user?.settings?.locale"
/>
</mat-card-content>
@ -206,9 +204,7 @@
<gf-world-map-chart
[countries]="countries"
[format]="worldMapChartFormat"
[isInPercent]="
hasImpersonationId || user.settings.isRestrictedView
"
[isInPercent]="showValuesInPercentage()"
[locale]="user?.settings?.locale"
/>
</div>
@ -272,7 +268,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="countries"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['name']"
[locale]="user?.settings?.locale"
[maxItems]="10"
@ -291,7 +287,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="accounts"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['id']"
[locale]="user?.settings?.locale"
(proportionChartClicked)="onAccountChartClicked($event)"
@ -314,7 +310,7 @@
[baseCurrency]="user?.settings?.baseCurrency"
[colorScheme]="user?.settings?.colorScheme"
[data]="holdings"
[isInPercent]="hasImpersonationId || user.settings.isRestrictedView"
[isInPercent]="showValuesInPercentage()"
[keys]="['etfProvider']"
[locale]="user?.settings?.locale"
/>

Loading…
Cancel
Save