Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/prettify scraper symbol in chart (#448)

Thomas Kaul54bbc8446b79
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1de833bb42..75e670973e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Changed
+
+- Prettified the generic scraper symbols in the portfolio proportion chart component
+
## 1.67.0 - 31.10.2021
### Added
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 ac816e8a43..af3c35c58a 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 d63b1699c8..3a9ad920fc 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 940ec18e52..525829afb4 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 02ce9b84bf..e00568df49 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, '');
+}