From 6b2966b7dc063f22ba24aa8f9e9a09176615b667 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 20 Apr 2025 08:01:03 +0200 Subject: [PATCH] Feature/extend benchmark detail dialog by market price (#4565) * Add current market price * Update changelog --- CHANGELOG.md | 1 + .../benchmark-detail-dialog.component.ts | 18 +++++++++++++++--- .../benchmark-detail-dialog.html | 11 +++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f0057a0c..94f5b12ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Extended the benchmark detail dialog by the current market price - Added `watchlist` to the `User` database schema as a preparation for watching assets ### Fixed diff --git a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts index 96dc6800e..ff309a47a 100644 --- a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts +++ b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts @@ -7,6 +7,7 @@ import { LineChartItem } from '@ghostfolio/common/interfaces'; import { GfLineChartComponent } from '@ghostfolio/ui/line-chart'; +import { GfValueComponent } from '@ghostfolio/ui/value'; import { CUSTOM_ELEMENTS_SCHEMA, @@ -35,6 +36,7 @@ import { BenchmarkDetailDialogParams } from './interfaces/interfaces'; GfDialogFooterModule, GfDialogHeaderModule, GfLineChartComponent, + GfValueComponent, MatDialogModule ], schemas: [CUSTOM_ELEMENTS_SCHEMA], @@ -45,6 +47,7 @@ import { BenchmarkDetailDialogParams } from './interfaces/interfaces'; export class GfBenchmarkDetailDialogComponent implements OnDestroy, OnInit { public assetProfile: AdminMarketDataDetails['assetProfile']; public historicalDataItems: LineChartItem[]; + public value: number; private unsubscribeSubject = new Subject(); @@ -65,9 +68,18 @@ export class GfBenchmarkDetailDialogComponent implements OnDestroy, OnInit { .subscribe(({ assetProfile, marketData }) => { this.assetProfile = assetProfile; - this.historicalDataItems = marketData.map(({ date, marketPrice }) => { - return { date: format(date, DATE_FORMAT), value: marketPrice }; - }); + this.historicalDataItems = marketData.map( + ({ date, marketPrice }, index) => { + if (marketData.length - 1 === index) { + this.value = marketPrice; + } + + return { + date: format(date, DATE_FORMAT), + value: marketPrice + }; + } + ); this.changeDetectorRef.markForCheck(); }); diff --git a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html index 23196f162..032663355 100644 --- a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html +++ b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html @@ -8,6 +8,17 @@
+
+
+ +
+
+