From 10499a532f0100e5b986b9305ebe2f0890cc0689 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:55:01 +0100 Subject: [PATCH] Prettify scraper symbol in chart --- .../portfolio/allocations/allocations-page.component.ts | 5 +++-- apps/client/src/app/pages/public/public-page.component.ts | 5 +++-- apps/client/src/app/pipes/symbol/symbol.pipe.ts | 6 +++--- libs/common/src/lib/helper.ts | 4 ++++ 4 files changed, 13 insertions(+), 7 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 ac816e8a4..af3c35c58 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 @@ -4,6 +4,7 @@ import { DataService } from '@ghostfolio/client/services/data.service'; import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UNKNOWN_KEY } from '@ghostfolio/common/config'; +import { prettifySymbol } from '@ghostfolio/common/helper'; import { PortfolioDetails, PortfolioPosition, @@ -246,9 +247,9 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { } if (position.assetClass === AssetClass.EQUITY) { - this.symbols[symbol] = { - symbol, + this.symbols[prettifySymbol(symbol)] = { name: position.name, + symbol: prettifySymbol(symbol), value: aPeriod === 'original' ? position.investment : position.value }; } diff --git a/apps/client/src/app/pages/public/public-page.component.ts b/apps/client/src/app/pages/public/public-page.component.ts index d63b1699c..3a9ad920f 100644 --- a/apps/client/src/app/pages/public/public-page.component.ts +++ b/apps/client/src/app/pages/public/public-page.component.ts @@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { DataService } from '@ghostfolio/client/services/data.service'; import { UNKNOWN_KEY } from '@ghostfolio/common/config'; +import { prettifySymbol } from '@ghostfolio/common/helper'; import { PortfolioPosition, PortfolioPublicDetails @@ -169,9 +170,9 @@ export class PublicPageComponent implements OnInit { this.portfolioPublicDetails.holdings[symbol].value; } - this.symbols[symbol] = { - symbol, + this.symbols[prettifySymbol(symbol)] = { name: position.name, + symbol: prettifySymbol(symbol), value: position.value }; } diff --git a/apps/client/src/app/pipes/symbol/symbol.pipe.ts b/apps/client/src/app/pipes/symbol/symbol.pipe.ts index 940ec18e5..525829afb 100644 --- a/apps/client/src/app/pipes/symbol/symbol.pipe.ts +++ b/apps/client/src/app/pipes/symbol/symbol.pipe.ts @@ -1,11 +1,11 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config'; +import { prettifySymbol } from '@ghostfolio/common/helper'; @Pipe({ name: 'gfSymbol' }) export class SymbolPipe implements PipeTransform { public constructor() {} - public transform(aSymbol: string): string { - return aSymbol?.replace(ghostfolioScraperApiSymbolPrefix, ''); + public transform(aSymbol: string) { + return prettifySymbol(aSymbol); } } diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts index 02ce9b84b..e00568df4 100644 --- a/libs/common/src/lib/helper.ts +++ b/libs/common/src/lib/helper.ts @@ -116,3 +116,7 @@ export const DATE_FORMAT = 'yyyy-MM-dd'; export function parseDate(date: string) { return parse(date, DATE_FORMAT, new Date()); } + +export function prettifySymbol(aSymbol: string): string { + return aSymbol?.replace(ghostfolioScraperApiSymbolPrefix, ''); +}