From 428068d786aaf742292199a6a0ac19d91eea8314 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 27 Jan 2024 19:52:49 +0100 Subject: [PATCH] Refactoring --- .../allocations/allocations-page.component.ts | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) 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 01c0fb13f..eb87c21ca 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 @@ -157,7 +157,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { this.portfolioDetails = portfolioDetails; - this.initializeAnalysisData(); + this.initializeAllocationsData(); this.isLoading = false; @@ -220,7 +220,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { this.portfolioDetails = portfolioDetails; - this.initializeAnalysisData(); + this.initializeAllocationsData(); this.isLoading = false; @@ -235,7 +235,52 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { this.initialize(); } - public initialize() { + public onAccountChartClicked({ symbol }: UniqueAsset) { + if (symbol && symbol !== UNKNOWN_KEY) { + this.router.navigate([], { + queryParams: { accountId: symbol, accountDetailDialog: true } + }); + } + } + + public onSymbolChartClicked({ dataSource, symbol }: UniqueAsset) { + if (dataSource && symbol) { + this.router.navigate([], { + queryParams: { dataSource, symbol, positionDetailDialog: true } + }); + } + } + + public ngOnDestroy() { + this.unsubscribeSubject.next(); + this.unsubscribeSubject.complete(); + } + + private extractEtfProvider({ + assetSubClass, + name + }: { + assetSubClass: PortfolioPosition['assetSubClass']; + name: string; + }) { + if (assetSubClass === 'ETF') { + const [firstWord] = name.split(' '); + return firstWord; + } + + return UNKNOWN_KEY; + } + + private fetchPortfolioDetails() { + return this.dataService.fetchPortfolioDetails({ + filters: + this.activeFilters.length > 0 + ? this.activeFilters + : this.userService.getFilters() + }); + } + + private initialize() { this.accounts = {}; this.continents = { [UNKNOWN_KEY]: { @@ -328,7 +373,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { }; } - public initializeAnalysisData() { + private initializeAllocationsData() { for (const [ id, { name, valueInBaseCurrency, valueInPercentage } @@ -558,36 +603,6 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { this.markets[UNKNOWN_KEY].value / marketsTotal; } - public onAccountChartClicked({ symbol }: UniqueAsset) { - if (symbol && symbol !== UNKNOWN_KEY) { - this.router.navigate([], { - queryParams: { accountId: symbol, accountDetailDialog: true } - }); - } - } - - public onSymbolChartClicked({ dataSource, symbol }: UniqueAsset) { - if (dataSource && symbol) { - this.router.navigate([], { - queryParams: { dataSource, symbol, positionDetailDialog: true } - }); - } - } - - public ngOnDestroy() { - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); - } - - private fetchPortfolioDetails() { - return this.dataService.fetchPortfolioDetails({ - filters: - this.activeFilters.length > 0 - ? this.activeFilters - : this.userService.getFilters() - }); - } - private openAccountDetailDialog(aAccountId: string) { const dialogRef = this.dialog.open(AccountDetailDialog, { autoFocus: false, @@ -648,19 +663,4 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { }); }); } - - private extractEtfProvider({ - assetSubClass, - name - }: { - assetSubClass: PortfolioPosition['assetSubClass']; - name: string; - }) { - if (assetSubClass === 'ETF') { - const [firstWord] = name.split(' '); - return firstWord; - } - - return UNKNOWN_KEY; - } }