|
@ -1,16 +1,11 @@ |
|
|
import { |
|
|
import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectorRef, |
|
|
|
|
|
Component, |
|
|
Component, |
|
|
Input, |
|
|
Input, |
|
|
OnChanges |
|
|
OnChanges |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
|
|
|
import { locale } from '@ghostfolio/common/config'; |
|
|
|
|
|
import { resolveMarketCondition } from '@ghostfolio/common/helper'; |
|
|
import { resolveMarketCondition } from '@ghostfolio/common/helper'; |
|
|
import { Benchmark, User } from '@ghostfolio/common/interfaces'; |
|
|
import { Benchmark, User } from '@ghostfolio/common/interfaces'; |
|
|
import { without } from 'lodash'; |
|
|
|
|
|
import { Subject, takeUntil } from 'rxjs'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'gf-benchmark', |
|
|
selector: 'gf-benchmark', |
|
@ -21,23 +16,14 @@ import { Subject, takeUntil } from 'rxjs'; |
|
|
export class BenchmarkComponent implements OnChanges { |
|
|
export class BenchmarkComponent implements OnChanges { |
|
|
@Input() benchmarks: Benchmark[]; |
|
|
@Input() benchmarks: Benchmark[]; |
|
|
@Input() locale: string; |
|
|
@Input() locale: string; |
|
|
|
|
|
@Input() user: User; |
|
|
|
|
|
|
|
|
public displayedColumns = ['name', 'date', 'change', 'marketCondition']; |
|
|
public displayedColumns = ['name', 'date', 'change', 'marketCondition']; |
|
|
public resolveMarketCondition = resolveMarketCondition; |
|
|
public resolveMarketCondition = resolveMarketCondition; |
|
|
public user: User; |
|
|
|
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
public constructor() {} |
|
|
|
|
|
|
|
|
public constructor( |
|
|
|
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
|
|
|
private userService: UserService |
|
|
|
|
|
) { |
|
|
|
|
|
this.userService.stateChanged |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((state) => { |
|
|
|
|
|
if (state?.user) { |
|
|
|
|
|
this.user = state.user; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
if (this.user?.settings?.isExperimentalFeatures) { |
|
|
if (this.user?.settings?.isExperimentalFeatures) { |
|
|
this.displayedColumns = [ |
|
|
this.displayedColumns = [ |
|
|
'name', |
|
|
'name', |
|
@ -48,15 +34,5 @@ export class BenchmarkComponent implements OnChanges { |
|
|
'marketCondition' |
|
|
'marketCondition' |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
|
|
|
if (!this.locale) { |
|
|
|
|
|
this.locale = locale; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|