diff --git a/CHANGELOG.md b/CHANGELOG.md index 90c33287ee..1ecf25a445 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 + +### Added + +- Added a _Manage Asset Profile_ button for administrators to the benchmark detail dialog + ## 3.101.0 - 2026-11-28 ### Changed 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 09069734a8..e6411ec96a 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 @@ -4,6 +4,7 @@ import { AdminMarketDataDetails, LineChartItem } from '@ghostfolio/common/interfaces'; +import { internalRoutes } from '@ghostfolio/common/routes/routes'; import { GfDialogFooterComponent } from '@ghostfolio/ui/dialog-footer'; import { GfDialogHeaderComponent } from '@ghostfolio/ui/dialog-header'; import { DataService } from '@ghostfolio/ui/services'; @@ -18,16 +19,25 @@ import { OnInit } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; +import { NavigationStart, Router, RouterModule } from '@angular/router'; +import { IonIcon } from '@ionic/angular/standalone'; import { format } from 'date-fns'; +import { addIcons } from 'ionicons'; +import { createOutline } from 'ionicons/icons'; +import { filter } from 'rxjs/operators'; import { GfLineChartComponent } from '../../line-chart/line-chart.component'; import { GfValueComponent } from '../../value/value.component'; -import { BenchmarkDetailDialogParams } from './interfaces/interfaces'; +import { + BenchmarkDetailDialogParams, + BenchmarkDetailDialogResult +} from './interfaces/interfaces'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -37,7 +47,10 @@ import { BenchmarkDetailDialogParams } from './interfaces/interfaces'; GfDialogHeaderComponent, GfLineChartComponent, GfValueComponent, - MatDialogModule + IonIcon, + MatButtonModule, + MatDialogModule, + RouterModule ], schemas: [CUSTOM_ELEMENTS_SCHEMA], selector: 'gf-benchmark-detail-dialog', @@ -49,15 +62,37 @@ export class GfBenchmarkDetailDialogComponent implements OnInit { public historicalDataItems: LineChartItem[]; public isLoading = true; public precision = 2; + + public readonly routerLinkAdminControlMarketDataUpdate = + internalRoutes.adminControl.subRoutes.marketData.subRoutes.update + .routerLink; + public value: number; public constructor( private changeDetectorRef: ChangeDetectorRef, + @Inject(MAT_DIALOG_DATA) public data: BenchmarkDetailDialogParams, private dataService: DataService, private destroyRef: DestroyRef, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: BenchmarkDetailDialogParams - ) {} + public dialogRef: MatDialogRef< + GfBenchmarkDetailDialogComponent, + BenchmarkDetailDialogResult + >, + private router: Router + ) { + this.router.events + .pipe( + filter((event) => { + return event instanceof NavigationStart; + }), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(() => { + this.dialogRef.close({ isNavigating: true }); + }); + + addIcons({ createOutline }); + } public ngOnInit() { this.dataService 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 f2291e7d1d..d74b9b478f 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 @@ -32,6 +32,26 @@ [showXAxis]="true" [showYAxis]="true" /> + + @if (data.hasPermissionToAccessAdminControl) { +
+
+ +
+ } diff --git a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/interfaces/interfaces.ts b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/interfaces/interfaces.ts index 80d09148c9..38c91d03ee 100644 --- a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/interfaces/interfaces.ts +++ b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/interfaces/interfaces.ts @@ -5,6 +5,11 @@ export interface BenchmarkDetailDialogParams { colorScheme?: ColorScheme; dataSource: DataSource; deviceType: string; + hasPermissionToAccessAdminControl: boolean; locale: string; symbol: string; } + +export interface BenchmarkDetailDialogResult { + isNavigating?: boolean; +} diff --git a/libs/ui/src/lib/benchmark/benchmark.component.ts b/libs/ui/src/lib/benchmark/benchmark.component.ts index d0749e20d5..e30391e385 100644 --- a/libs/ui/src/lib/benchmark/benchmark.component.ts +++ b/libs/ui/src/lib/benchmark/benchmark.component.ts @@ -9,6 +9,7 @@ import { Benchmark, User } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { NotificationService } from '@ghostfolio/ui/notifications'; import { @@ -42,7 +43,10 @@ import { translate } from '../i18n'; import { GfTrendIndicatorComponent } from '../trend-indicator/trend-indicator.component'; import { GfValueComponent } from '../value/value.component'; import { GfBenchmarkDetailDialogComponent } from './benchmark-detail-dialog/benchmark-detail-dialog.component'; -import { BenchmarkDetailDialogParams } from './benchmark-detail-dialog/interfaces/interfaces'; +import { + BenchmarkDetailDialogParams, + BenchmarkDetailDialogResult +} from './benchmark-detail-dialog/interfaces/interfaces'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -170,13 +174,18 @@ export class GfBenchmarkComponent implements OnInit { }: AssetProfileIdentifier) { const dialogRef = this.dialog.open< GfBenchmarkDetailDialogComponent, - BenchmarkDetailDialogParams + BenchmarkDetailDialogParams, + BenchmarkDetailDialogResult >(GfBenchmarkDetailDialogComponent, { data: { dataSource, symbol, colorScheme: this.user()?.settings?.colorScheme, deviceType: this.deviceType(), + hasPermissionToAccessAdminControl: hasPermission( + this.user()?.permissions, + permissions.accessAdminControl + ), locale: this.locale() }, height: this.deviceType() === 'mobile' ? '98dvh' : undefined, @@ -188,7 +197,11 @@ export class GfBenchmarkComponent implements OnInit { dialogRef .afterClosed() .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => { + .subscribe((result) => { + if (result?.isNavigating) { + return; + } + this.router.navigate(['.'], { relativeTo: this.route }); }); }