Browse Source

Add Manage Asset Profile button to benchmark detail dialog

pull/8487/head
Thomas Kaul 18 hours ago
parent
commit
24fb0889e0
  1. 45
      libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts
  2. 21
      libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html
  3. 5
      libs/ui/src/lib/benchmark/benchmark-detail-dialog/interfaces/interfaces.ts
  4. 19
      libs/ui/src/lib/benchmark/benchmark.component.ts

45
libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts

@ -4,6 +4,7 @@ import {
AdminMarketDataDetails, AdminMarketDataDetails,
LineChartItem LineChartItem
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { internalRoutes } from '@ghostfolio/common/routes/routes';
import { GfDialogFooterComponent } from '@ghostfolio/ui/dialog-footer'; import { GfDialogFooterComponent } from '@ghostfolio/ui/dialog-footer';
import { GfDialogHeaderComponent } from '@ghostfolio/ui/dialog-header'; import { GfDialogHeaderComponent } from '@ghostfolio/ui/dialog-header';
import { DataService } from '@ghostfolio/ui/services'; import { DataService } from '@ghostfolio/ui/services';
@ -18,16 +19,25 @@ import {
OnInit OnInit
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatButtonModule } from '@angular/material/button';
import { import {
MAT_DIALOG_DATA, MAT_DIALOG_DATA,
MatDialogModule, MatDialogModule,
MatDialogRef MatDialogRef
} from '@angular/material/dialog'; } from '@angular/material/dialog';
import { NavigationStart, Router, RouterModule } from '@angular/router';
import { IonIcon } from '@ionic/angular/standalone';
import { format } from 'date-fns'; 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 { GfLineChartComponent } from '../../line-chart/line-chart.component';
import { GfValueComponent } from '../../value/value.component'; import { GfValueComponent } from '../../value/value.component';
import { BenchmarkDetailDialogParams } from './interfaces/interfaces'; import {
BenchmarkDetailDialogParams,
BenchmarkDetailDialogResult
} from './interfaces/interfaces';
@Component({ @Component({
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -37,7 +47,10 @@ import { BenchmarkDetailDialogParams } from './interfaces/interfaces';
GfDialogHeaderComponent, GfDialogHeaderComponent,
GfLineChartComponent, GfLineChartComponent,
GfValueComponent, GfValueComponent,
MatDialogModule IonIcon,
MatButtonModule,
MatDialogModule,
RouterModule
], ],
schemas: [CUSTOM_ELEMENTS_SCHEMA], schemas: [CUSTOM_ELEMENTS_SCHEMA],
selector: 'gf-benchmark-detail-dialog', selector: 'gf-benchmark-detail-dialog',
@ -49,15 +62,37 @@ export class GfBenchmarkDetailDialogComponent implements OnInit {
public historicalDataItems: LineChartItem[]; public historicalDataItems: LineChartItem[];
public isLoading = true; public isLoading = true;
public precision = 2; public precision = 2;
public readonly routerLinkAdminControlMarketDataUpdate =
internalRoutes.adminControl.subRoutes.marketData.subRoutes.update
.routerLink;
public value: number; public value: number;
public constructor( public constructor(
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
@Inject(MAT_DIALOG_DATA) public data: BenchmarkDetailDialogParams,
private dataService: DataService, private dataService: DataService,
public dialogRef: MatDialogRef<
GfBenchmarkDetailDialogComponent,
BenchmarkDetailDialogResult
>,
private destroyRef: DestroyRef, private destroyRef: DestroyRef,
public dialogRef: MatDialogRef<GfBenchmarkDetailDialogComponent>, private router: Router
@Inject(MAT_DIALOG_DATA) public data: BenchmarkDetailDialogParams ) {
) {} this.router.events
.pipe(
filter((event) => {
return event instanceof NavigationStart;
}),
takeUntilDestroyed(this.destroyRef)
)
.subscribe(() => {
this.dialogRef.close({ isNavigating: true });
});
addIcons({ createOutline });
}
public ngOnInit() { public ngOnInit() {
this.dataService this.dataService

21
libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html

@ -32,6 +32,27 @@
[showXAxis]="true" [showXAxis]="true"
[showYAxis]="true" [showYAxis]="true"
/> />
@if (data.hasPermissionToAccessAdminControl) {
<hr />
<div class="row">
<div class="col">
<a
mat-stroked-button
[routerLink]="
routerLinkAdminControlMarketDataUpdate(
data.dataSource,
data.symbol
)
"
(click)="onClose()"
><ion-icon class="me-1" name="create-outline" /><span i18n
>Manage Asset Profile</span
>...</a
>
</div>
</div>
}
</div> </div>
</div> </div>

5
libs/ui/src/lib/benchmark/benchmark-detail-dialog/interfaces/interfaces.ts

@ -5,6 +5,11 @@ export interface BenchmarkDetailDialogParams {
colorScheme?: ColorScheme; colorScheme?: ColorScheme;
dataSource: DataSource; dataSource: DataSource;
deviceType: string; deviceType: string;
hasPermissionToAccessAdminControl: boolean;
locale: string; locale: string;
symbol: string; symbol: string;
} }
export interface BenchmarkDetailDialogResult {
isNavigating?: boolean;
}

19
libs/ui/src/lib/benchmark/benchmark.component.ts

@ -9,6 +9,7 @@ import {
Benchmark, Benchmark,
User User
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { NotificationService } from '@ghostfolio/ui/notifications'; import { NotificationService } from '@ghostfolio/ui/notifications';
import { import {
@ -42,7 +43,10 @@ import { translate } from '../i18n';
import { GfTrendIndicatorComponent } from '../trend-indicator/trend-indicator.component'; import { GfTrendIndicatorComponent } from '../trend-indicator/trend-indicator.component';
import { GfValueComponent } from '../value/value.component'; import { GfValueComponent } from '../value/value.component';
import { GfBenchmarkDetailDialogComponent } from './benchmark-detail-dialog/benchmark-detail-dialog.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({ @Component({
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -170,13 +174,18 @@ export class GfBenchmarkComponent implements OnInit {
}: AssetProfileIdentifier) { }: AssetProfileIdentifier) {
const dialogRef = this.dialog.open< const dialogRef = this.dialog.open<
GfBenchmarkDetailDialogComponent, GfBenchmarkDetailDialogComponent,
BenchmarkDetailDialogParams BenchmarkDetailDialogParams,
BenchmarkDetailDialogResult
>(GfBenchmarkDetailDialogComponent, { >(GfBenchmarkDetailDialogComponent, {
data: { data: {
dataSource, dataSource,
symbol, symbol,
colorScheme: this.user()?.settings?.colorScheme, colorScheme: this.user()?.settings?.colorScheme,
deviceType: this.deviceType(), deviceType: this.deviceType(),
hasPermissionToAccessAdminControl: hasPermission(
this.user()?.permissions,
permissions.accessAdminControl
),
locale: this.locale() locale: this.locale()
}, },
height: this.deviceType() === 'mobile' ? '98dvh' : undefined, height: this.deviceType() === 'mobile' ? '98dvh' : undefined,
@ -188,7 +197,11 @@ export class GfBenchmarkComponent implements OnInit {
dialogRef dialogRef
.afterClosed() .afterClosed()
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe((result) => {
if (result?.isNavigating) {
return;
}
this.router.navigate(['.'], { relativeTo: this.route }); this.router.navigate(['.'], { relativeTo: this.route });
}); });
} }

Loading…
Cancel
Save