|
|
@ -19,14 +19,13 @@ import { |
|
|
ChangeDetectorRef, |
|
|
ChangeDetectorRef, |
|
|
Component, |
|
|
Component, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
OnDestroy, |
|
|
DestroyRef, |
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { RouterModule } from '@angular/router'; |
|
|
import { RouterModule } from '@angular/router'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject } from 'rxjs'; |
|
|
|
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
imports: [ |
|
|
imports: [ |
|
|
@ -41,7 +40,7 @@ import { takeUntil } from 'rxjs/operators'; |
|
|
styleUrls: ['./home-overview.scss'], |
|
|
styleUrls: ['./home-overview.scss'], |
|
|
templateUrl: './home-overview.html' |
|
|
templateUrl: './home-overview.html' |
|
|
}) |
|
|
}) |
|
|
export class GfHomeOverviewComponent implements OnDestroy, OnInit { |
|
|
export class GfHomeOverviewComponent implements OnInit { |
|
|
public deviceType: string; |
|
|
public deviceType: string; |
|
|
public errors: AssetProfileIdentifier[]; |
|
|
public errors: AssetProfileIdentifier[]; |
|
|
public hasError: boolean; |
|
|
public hasError: boolean; |
|
|
@ -62,18 +61,17 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit { |
|
|
public unit: string; |
|
|
public unit: string; |
|
|
public user: User; |
|
|
public user: User; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
|
|
|
private destroyRef: DestroyRef, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private impersonationStorageService: ImpersonationStorageService, |
|
|
private impersonationStorageService: ImpersonationStorageService, |
|
|
private layoutService: LayoutService, |
|
|
private layoutService: LayoutService, |
|
|
private userService: UserService |
|
|
private userService: UserService |
|
|
) { |
|
|
) { |
|
|
this.userService.stateChanged |
|
|
this.userService.stateChanged |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((state) => { |
|
|
.subscribe((state) => { |
|
|
if (state?.user) { |
|
|
if (state?.user) { |
|
|
this.user = state.user; |
|
|
this.user = state.user; |
|
|
@ -99,7 +97,7 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
this.impersonationStorageService |
|
|
this.impersonationStorageService |
|
|
.onChangeHasImpersonation() |
|
|
.onChangeHasImpersonation() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((impersonationId) => { |
|
|
.subscribe((impersonationId) => { |
|
|
this.hasImpersonationId = !!impersonationId; |
|
|
this.hasImpersonationId = !!impersonationId; |
|
|
|
|
|
|
|
|
@ -107,17 +105,12 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.layoutService.shouldReloadContent$ |
|
|
this.layoutService.shouldReloadContent$ |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.update(); |
|
|
this.update(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private update() { |
|
|
private update() { |
|
|
this.historicalDataItems = null; |
|
|
this.historicalDataItems = null; |
|
|
this.isLoadingPerformance = true; |
|
|
this.isLoadingPerformance = true; |
|
|
@ -126,7 +119,7 @@ export class GfHomeOverviewComponent implements OnDestroy, OnInit { |
|
|
.fetchPortfolioPerformance({ |
|
|
.fetchPortfolioPerformance({ |
|
|
range: this.user?.settings?.dateRange |
|
|
range: this.user?.settings?.dateRange |
|
|
}) |
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ chart, errors, performance }) => { |
|
|
.subscribe(({ chart, errors, performance }) => { |
|
|
this.errors = errors; |
|
|
this.errors = errors; |
|
|
this.performance = performance; |
|
|
this.performance = performance; |
|
|
|