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,
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,
public dialogRef: MatDialogRef<
GfBenchmarkDetailDialogComponent,
BenchmarkDetailDialogResult
>,
private destroyRef: DestroyRef,
public dialogRef: MatDialogRef<GfBenchmarkDetailDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: BenchmarkDetailDialogParams
) {}
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

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

@ -32,6 +32,27 @@
[showXAxis]="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>

5
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;
}

19
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 });
});
}

Loading…
Cancel
Save