|
|
@ -17,9 +17,10 @@ import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
Component, |
|
|
Component, |
|
|
DestroyRef, |
|
|
DestroyRef, |
|
|
Input, |
|
|
computed, |
|
|
OnChanges, |
|
|
effect, |
|
|
inject, |
|
|
inject, |
|
|
|
|
|
input, |
|
|
output, |
|
|
output, |
|
|
viewChild |
|
|
viewChild |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
@ -61,26 +62,31 @@ import { BenchmarkDetailDialogParams } from './benchmark-detail-dialog/interface |
|
|
styleUrls: ['./benchmark.component.scss'], |
|
|
styleUrls: ['./benchmark.component.scss'], |
|
|
templateUrl: './benchmark.component.html' |
|
|
templateUrl: './benchmark.component.html' |
|
|
}) |
|
|
}) |
|
|
export class GfBenchmarkComponent implements OnChanges { |
|
|
export class GfBenchmarkComponent { |
|
|
@Input() benchmarks: Benchmark[]; |
|
|
public readonly benchmarks = input.required<Benchmark[]>(); |
|
|
@Input() deviceType: string; |
|
|
public readonly deviceType = input.required<string>(); |
|
|
@Input() hasPermissionToDeleteItem: boolean; |
|
|
public readonly hasPermissionToDeleteItem = input<boolean>(); |
|
|
@Input() locale = getLocale(); |
|
|
public readonly locale = input(getLocale()); |
|
|
@Input() showSymbol = true; |
|
|
public readonly showSymbol = input(true); |
|
|
@Input() user: User; |
|
|
public readonly user = input<User>(); |
|
|
|
|
|
|
|
|
public readonly itemDeleted = output<AssetProfileIdentifier>(); |
|
|
public readonly itemDeleted = output<AssetProfileIdentifier>(); |
|
|
|
|
|
|
|
|
protected readonly sort = viewChild(MatSort); |
|
|
protected readonly sort = viewChild(MatSort); |
|
|
|
|
|
|
|
|
protected readonly dataSource = new MatTableDataSource<Benchmark>([]); |
|
|
protected readonly dataSource = new MatTableDataSource<Benchmark>([]); |
|
|
protected displayedColumns = [ |
|
|
protected readonly displayedColumns = computed(() => { |
|
|
'name', |
|
|
return [ |
|
|
'date', |
|
|
'name', |
|
|
'change', |
|
|
...(this.user()?.settings?.isExperimentalFeatures |
|
|
'marketCondition', |
|
|
? ['trend50d', 'trend200d'] |
|
|
'actions' |
|
|
: []), |
|
|
]; |
|
|
'date', |
|
|
|
|
|
'change', |
|
|
|
|
|
'marketCondition', |
|
|
|
|
|
'actions' |
|
|
|
|
|
]; |
|
|
|
|
|
}); |
|
|
protected isLoading = true; |
|
|
protected isLoading = true; |
|
|
protected readonly isNumber = isNumber; |
|
|
protected readonly isNumber = isNumber; |
|
|
protected readonly resolveMarketCondition = resolveMarketCondition; |
|
|
protected readonly resolveMarketCondition = resolveMarketCondition; |
|
|
@ -93,6 +99,19 @@ export class GfBenchmarkComponent implements OnChanges { |
|
|
private readonly router = inject(Router); |
|
|
private readonly router = inject(Router); |
|
|
|
|
|
|
|
|
public constructor() { |
|
|
public constructor() { |
|
|
|
|
|
effect(() => { |
|
|
|
|
|
const benchmarks = this.benchmarks(); |
|
|
|
|
|
|
|
|
|
|
|
if (benchmarks) { |
|
|
|
|
|
this.dataSource.data = benchmarks; |
|
|
|
|
|
this.dataSource.sortingDataAccessor = getLowercase; |
|
|
|
|
|
|
|
|
|
|
|
this.dataSource.sort = this.sort() ?? null; |
|
|
|
|
|
|
|
|
|
|
|
this.isLoading = false; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.route.queryParams |
|
|
this.route.queryParams |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((params) => { |
|
|
.subscribe((params) => { |
|
|
@ -111,29 +130,6 @@ export class GfBenchmarkComponent implements OnChanges { |
|
|
addIcons({ ellipsisHorizontal, trashOutline }); |
|
|
addIcons({ ellipsisHorizontal, trashOutline }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
|
|
|
if (this.benchmarks) { |
|
|
|
|
|
this.dataSource.data = this.benchmarks; |
|
|
|
|
|
this.dataSource.sortingDataAccessor = getLowercase; |
|
|
|
|
|
|
|
|
|
|
|
this.dataSource.sort = this.sort(); |
|
|
|
|
|
|
|
|
|
|
|
this.isLoading = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.user?.settings?.isExperimentalFeatures) { |
|
|
|
|
|
this.displayedColumns = [ |
|
|
|
|
|
'name', |
|
|
|
|
|
'trend50d', |
|
|
|
|
|
'trend200d', |
|
|
|
|
|
'date', |
|
|
|
|
|
'change', |
|
|
|
|
|
'marketCondition', |
|
|
|
|
|
'actions' |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected onDeleteItem({ dataSource, symbol }: AssetProfileIdentifier) { |
|
|
protected onDeleteItem({ dataSource, symbol }: AssetProfileIdentifier) { |
|
|
this.notificationService.confirm({ |
|
|
this.notificationService.confirm({ |
|
|
confirmFn: () => { |
|
|
confirmFn: () => { |
|
|
@ -164,12 +160,12 @@ export class GfBenchmarkComponent implements OnChanges { |
|
|
data: { |
|
|
data: { |
|
|
dataSource, |
|
|
dataSource, |
|
|
symbol, |
|
|
symbol, |
|
|
colorScheme: this.user?.settings?.colorScheme, |
|
|
colorScheme: this.user()?.settings?.colorScheme, |
|
|
deviceType: this.deviceType, |
|
|
deviceType: this.deviceType(), |
|
|
locale: this.locale |
|
|
locale: this.locale() |
|
|
}, |
|
|
}, |
|
|
height: this.deviceType === 'mobile' ? '98vh' : undefined, |
|
|
height: this.deviceType() === 'mobile' ? '98vh' : undefined, |
|
|
width: this.deviceType === 'mobile' ? '100vw' : '50rem' |
|
|
width: this.deviceType() === 'mobile' ? '100vw' : '50rem' |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
dialogRef |
|
|
dialogRef |
|
|
|