From ec438a38296da140bb2e2baabdff279e5da2de6c Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Sun, 14 Jan 2024 21:03:10 +0100 Subject: [PATCH] Cleanup (#2853) --- .../account-detail-dialog.component.ts | 15 ++------------- .../account-detail-dialog.html | 3 ++- .../account-detail-dialog.module.ts | 6 +++--- .../allocations/allocations-page.component.ts | 4 ++-- .../portfolio/holdings/holdings-page.component.ts | 6 +----- apps/client/src/app/services/data.service.ts | 8 ++++++++ 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts index 4f3730ed4..0e7608fd9 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts @@ -28,7 +28,6 @@ import { Observable, Subject } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; import { AccountDetailDialogParams } from './interfaces/interfaces'; -import { translate } from '@ghostfolio/ui/i18n'; @Component({ host: { class: 'd-flex flex-column h-100' }, @@ -47,6 +46,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit { public hasImpersonationId: boolean; public hasPermissionToDeleteAccountBalance: boolean; public historicalDataItems: HistoricalDataItem[]; + public holdings$: Observable; public isLoadingActivities: boolean; public isLoadingChart: boolean; public name: string; @@ -57,7 +57,6 @@ export class AccountDetailDialog implements OnDestroy, OnInit { public transactionCount: number; public user: User; public valueInBaseCurrency: number; - public holdings$: Observable; private unsubscribeSubject = new Subject(); @@ -95,17 +94,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit { } ] }) - .pipe( - map((d) => - Object.values(d.holdings).map(function (x) { - return { - ...x, - assetClassLabel: translate(x.assetClass), - assetSubClassLabel: translate(x.assetSubClass) - }; - }) - ) - ); + .pipe(map((d) => Object.values(d.holdings))); this.dataService .fetchAccount(this.data.accountId) .pipe(takeUntil(this.unsubscribeSubject)) diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html index 988dcc1ca..d55abdefb 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html @@ -73,6 +73,7 @@ Holdings @@ -83,7 +84,7 @@ *ngIf="user?.settings?.isExperimentalFeatures === true" [baseCurrency]="user?.settings?.baseCurrency" [dataSource]="dataSource" - [deviceType]="deviceType" + [deviceType]="data.deviceType" [hasPermissionToCreateActivity]="false" [hasPermissionToExportActivities]="!hasImpersonationId && !user.settings.isRestrictedView" [hasPermissionToFilter]="false" diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.module.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.module.ts index daa319152..d015883df 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.module.ts +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.module.ts @@ -5,6 +5,7 @@ import { MatDialogModule } from '@angular/material/dialog'; import { MatTabsModule } from '@angular/material/tabs'; import { GfDialogFooterModule } from '@ghostfolio/client/components/dialog-footer/dialog-footer.module'; import { GfDialogHeaderModule } from '@ghostfolio/client/components/dialog-header/dialog-header.module'; +import { GfHoldingsTableModule } from '@ghostfolio/ui/holdings-table/holdings-table.module'; import { GfInvestmentChartModule } from '@ghostfolio/client/components/investment-chart/investment-chart.module'; import { GfAccountBalancesModule } from '@ghostfolio/ui/account-balances/account-balances.module'; import { GfActivitiesTableLazyModule } from '@ghostfolio/ui/activities-table-lazy/activities-table-lazy.module'; @@ -13,7 +14,6 @@ import { GfValueModule } from '@ghostfolio/ui/value'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { AccountDetailDialog } from './account-detail-dialog.component'; -import { GfHoldingsTableModule } from '@ghostfolio/ui/holdings-table/holdings-table.module'; @NgModule({ declarations: [AccountDetailDialog], @@ -24,13 +24,13 @@ import { GfHoldingsTableModule } from '@ghostfolio/ui/holdings-table/holdings-ta GfActivitiesTableLazyModule, GfDialogFooterModule, GfDialogHeaderModule, + GfHoldingsTableModule, GfInvestmentChartModule, GfValueModule, MatButtonModule, MatDialogModule, MatTabsModule, - NgxSkeletonLoaderModule, - GfHoldingsTableModule + NgxSkeletonLoaderModule ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }) diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts index 40bb38b8a..9ef2ed9d7 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts @@ -344,9 +344,9 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { this.positions[symbol] = { value, assetClass: position.assetClass, - assetClassLabel: translate(position.assetClass), + assetClassLabel: position.assetClassLabel, assetSubClass: position.assetSubClass, - assetSubClassLabel: translate(position.assetSubClass), + assetSubClassLabel: position.assetSubClassLabel, currency: position.currency, etfProvider: this.extractEtfProvider({ assetSubClass: position.assetSubClass, diff --git a/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts b/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts index d65f20165..ee0b57452 100644 --- a/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts +++ b/apps/client/src/app/pages/portfolio/holdings/holdings-page.component.ts @@ -161,11 +161,7 @@ export class HoldingsPageComponent implements OnDestroy, OnInit { for (const [symbol, position] of Object.entries( this.portfolioDetails.holdings )) { - this.positionsArray.push({ - ...position, - assetClassLabel: translate(position.assetClass), - assetSubClassLabel: translate(position.assetSubClass) - }); + this.positionsArray.push(position); } } diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts index 73dceeb77..5c559b4f8 100644 --- a/apps/client/src/app/services/data.service.ts +++ b/apps/client/src/app/services/data.service.ts @@ -44,6 +44,7 @@ import { format, parseISO } from 'date-fns'; import { cloneDeep, groupBy, isNumber } from 'lodash'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; +import { translate } from '@ghostfolio/ui/i18n'; @Injectable({ providedIn: 'root' @@ -405,6 +406,13 @@ export class DataService { ? parseISO(response.holdings[symbol].dateOfFirstActivity) : undefined; + response.holdings[symbol].assetClassLabel = translate( + response.holdings[symbol].assetClass + ); + response.holdings[symbol].assetSubClassLabel = translate( + response.holdings[symbol].assetSubClass + ); + response.holdings[symbol].value = isNumber( response.holdings[symbol].value )