From 9218150a094a3b14bc16956414b7bdedeac5a7c7 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Sat, 13 Jan 2024 15:47:08 +0100 Subject: [PATCH] Feature/Add holdings tab to account detail dialog (#2853) --- .../account-detail-dialog.component.ts | 27 +++++++++++++++++-- .../account-detail-dialog.html | 8 ++++++ .../account-detail-dialog.module.ts | 4 ++- 3 files changed, 36 insertions(+), 3 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 d37defe2f..4f3730ed4 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 @@ -16,6 +16,7 @@ import { downloadAsFile } from '@ghostfolio/common/helper'; import { AccountBalancesResponse, HistoricalDataItem, + PortfolioPosition, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; @@ -23,10 +24,11 @@ import { OrderWithAccount } from '@ghostfolio/common/types'; import Big from 'big.js'; import { format, parseISO } from 'date-fns'; import { isNumber } from 'lodash'; -import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; +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' }, @@ -55,6 +57,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit { public transactionCount: number; public user: User; public valueInBaseCurrency: number; + public holdings$: Observable; private unsubscribeSubject = new Subject(); @@ -83,6 +86,26 @@ export class AccountDetailDialog implements OnDestroy, OnInit { } public ngOnInit() { + this.holdings$ = this.dataService + .fetchPortfolioDetails({ + filters: [ + { + type: 'ACCOUNT', + id: this.data.accountId + } + ] + }) + .pipe( + map((d) => + Object.values(d.holdings).map(function (x) { + return { + ...x, + assetClassLabel: translate(x.assetClass), + assetSubClassLabel: translate(x.assetSubClass) + }; + }) + ) + ); 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 1b9ba761b..988dcc1ca 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 @@ -69,6 +69,14 @@ [mat-stretch-tabs]="false" [ngClass]="{ 'd-none': isLoadingActivities }" > + + Holdings + + Activities