diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ea4df671..fbc6d827e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added a prettifier (pipe) for generic scraper symbols + ### Fixed - Fixed the text truncation in buttons of the admin control panel diff --git a/apps/client/src/app/components/position/position.component.html b/apps/client/src/app/components/position/position.component.html index 1c3be1b31..75b33610c 100644 --- a/apps/client/src/app/components/position/position.component.html +++ b/apps/client/src/app/components/position/position.component.html @@ -34,7 +34,7 @@
{{ position?.name }}
- {{ position?.symbol }} + {{ position?.symbol | gfSymbol }} Symbol - {{ element.symbol }} + {{ element.symbol | gfSymbol }} diff --git a/apps/client/src/app/components/positions-table/positions-table.module.ts b/apps/client/src/app/components/positions-table/positions-table.module.ts index 677658034..29812f91a 100644 --- a/apps/client/src/app/components/positions-table/positions-table.module.ts +++ b/apps/client/src/app/components/positions-table/positions-table.module.ts @@ -7,6 +7,7 @@ import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; import { MatTableModule } from '@angular/material/table'; import { RouterModule } from '@angular/router'; +import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { GfNoTransactionsInfoModule } from '../no-transactions-info/no-transactions-info.module'; @@ -23,6 +24,7 @@ import { PositionsTableComponent } from './positions-table.component'; GfNoTransactionsInfoModule, GfPositionDetailDialogModule, GfSymbolIconModule, + GfSymbolModule, GfValueModule, MatButtonModule, MatDialogModule, diff --git a/apps/client/src/app/components/transactions-table/transactions-table.component.html b/apps/client/src/app/components/transactions-table/transactions-table.component.html index 46c135e1c..c0aa40c18 100644 --- a/apps/client/src/app/components/transactions-table/transactions-table.component.html +++ b/apps/client/src/app/components/transactions-table/transactions-table.component.html @@ -83,7 +83,7 @@ Symbol - {{ element.symbol }} + {{ element.symbol | gfSymbol }} @@ -192,7 +192,7 @@ diff --git a/apps/client/src/app/components/transactions-table/transactions-table.component.ts b/apps/client/src/app/components/transactions-table/transactions-table.component.ts index 05b695200..c0cfe05af 100644 --- a/apps/client/src/app/components/transactions-table/transactions-table.component.ts +++ b/apps/client/src/app/components/transactions-table/transactions-table.component.ts @@ -55,11 +55,7 @@ export class TransactionsTableComponent this.routeQueryParams = route.queryParams .pipe(takeUntil(this.unsubscribeSubject)) .subscribe((params) => { - if ( - params['positionDetailDialog'] && - params['symbol'] && - params['title'] - ) { + if (params['positionDetailDialog'] && params['symbol']) { this.openPositionDialog({ symbol: params['symbol'], title: params['title'] diff --git a/apps/client/src/app/components/transactions-table/transactions-table.module.ts b/apps/client/src/app/components/transactions-table/transactions-table.module.ts index 0623ccd1b..34d66e84a 100644 --- a/apps/client/src/app/components/transactions-table/transactions-table.module.ts +++ b/apps/client/src/app/components/transactions-table/transactions-table.module.ts @@ -6,6 +6,7 @@ import { MatMenuModule } from '@angular/material/menu'; import { MatSortModule } from '@angular/material/sort'; import { MatTableModule } from '@angular/material/table'; import { RouterModule } from '@angular/router'; +import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { GfPositionDetailDialogModule } from '../position/position-detail-dialog/position-detail-dialog.module'; @@ -20,6 +21,7 @@ import { TransactionsTableComponent } from './transactions-table.component'; CommonModule, GfPositionDetailDialogModule, GfSymbolIconModule, + GfSymbolModule, GfValueModule, MatButtonModule, MatInputModule, diff --git a/apps/client/src/app/pipes/symbol/symbol.module.ts b/apps/client/src/app/pipes/symbol/symbol.module.ts new file mode 100644 index 000000000..8868583d4 --- /dev/null +++ b/apps/client/src/app/pipes/symbol/symbol.module.ts @@ -0,0 +1,11 @@ +import { NgModule } from '@angular/core'; + +import { SymbolPipe } from './symbol.pipe'; + +@NgModule({ + imports: [], + declarations: [SymbolPipe], + exports: [SymbolPipe], + providers: [] +}) +export class GfSymbolModule {} diff --git a/apps/client/src/app/pipes/symbol/symbol.pipe.ts b/apps/client/src/app/pipes/symbol/symbol.pipe.ts new file mode 100644 index 000000000..0c4c4a390 --- /dev/null +++ b/apps/client/src/app/pipes/symbol/symbol.pipe.ts @@ -0,0 +1,11 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/helper'; + +@Pipe({ name: 'gfSymbol' }) +export class SymbolPipe implements PipeTransform { + public constructor() {} + + public transform(aSymbol: string): string { + return aSymbol?.replace(ghostfolioScraperApiSymbolPrefix, ''); + } +} diff --git a/libs/helper/src/lib/config.ts b/libs/helper/src/lib/config.ts index 83fd2b6db..2684c6e1f 100644 --- a/libs/helper/src/lib/config.ts +++ b/libs/helper/src/lib/config.ts @@ -10,6 +10,8 @@ export const currencyPairs = [ `${Currency.USD}${Currency.CHF}` ]; +export const ghostfolioScraperApiSymbolPrefix = '_GF_'; + export const locale = 'de-CH'; export const primaryColorHex = '#36cfcc'; diff --git a/libs/helper/src/lib/helper.ts b/libs/helper/src/lib/helper.ts index ba0966f09..0e8123fc6 100644 --- a/libs/helper/src/lib/helper.ts +++ b/libs/helper/src/lib/helper.ts @@ -1,6 +1,8 @@ import { Currency } from '@prisma/client'; import { getDate, getMonth, getYear, subDays } from 'date-fns'; +import { ghostfolioScraperApiSymbolPrefix } from './config'; + const cryptocurrencies = require('cryptocurrencies'); export const DEMO_USER_ID = '9b112b4d-3b7d-4bad-9bdd-3b0f7b4dac2f'; @@ -67,7 +69,7 @@ export function isCurrency(aSymbol = '') { } export function isGhostfolioScraperApiSymbol(aSymbol = '') { - return aSymbol.startsWith('[GF]'); + return aSymbol.startsWith(ghostfolioScraperApiSymbolPrefix); } export function isRakutenRapidApiSymbol(aSymbol = '') {