|
|
@ -13,14 +13,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 { MatCardModule } from '@angular/material/card'; |
|
|
import { MatCardModule } from '@angular/material/card'; |
|
|
import { MatSnackBarRef, TextOnlySnackBar } from '@angular/material/snack-bar'; |
|
|
import { MatSnackBarRef, TextOnlySnackBar } from '@angular/material/snack-bar'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject } from 'rxjs'; |
|
|
|
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
imports: [GfPortfolioSummaryComponent, MatCardModule], |
|
|
imports: [GfPortfolioSummaryComponent, MatCardModule], |
|
|
@ -29,7 +28,7 @@ import { takeUntil } from 'rxjs/operators'; |
|
|
styleUrls: ['./home-summary.scss'], |
|
|
styleUrls: ['./home-summary.scss'], |
|
|
templateUrl: './home-summary.html' |
|
|
templateUrl: './home-summary.html' |
|
|
}) |
|
|
}) |
|
|
export class GfHomeSummaryComponent implements OnDestroy, OnInit { |
|
|
export class GfHomeSummaryComponent implements OnInit { |
|
|
public deviceType: string; |
|
|
public deviceType: string; |
|
|
public hasImpersonationId: boolean; |
|
|
public hasImpersonationId: boolean; |
|
|
public hasPermissionForSubscription: boolean; |
|
|
public hasPermissionForSubscription: boolean; |
|
|
@ -40,11 +39,10 @@ export class GfHomeSummaryComponent implements OnDestroy, OnInit { |
|
|
public summary: PortfolioSummary; |
|
|
public summary: PortfolioSummary; |
|
|
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 userService: UserService |
|
|
private userService: UserService |
|
|
@ -57,7 +55,7 @@ export class GfHomeSummaryComponent implements OnDestroy, OnInit { |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
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; |
|
|
@ -77,7 +75,7 @@ export class GfHomeSummaryComponent 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; |
|
|
}); |
|
|
}); |
|
|
@ -86,11 +84,11 @@ export class GfHomeSummaryComponent implements OnDestroy, OnInit { |
|
|
public onChangeEmergencyFund(emergencyFund: number) { |
|
|
public onChangeEmergencyFund(emergencyFund: number) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.putUserSetting({ emergencyFund }) |
|
|
.putUserSetting({ emergencyFund }) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.userService |
|
|
this.userService |
|
|
.get(true) |
|
|
.get(true) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((user) => { |
|
|
.subscribe((user) => { |
|
|
this.user = user; |
|
|
this.user = user; |
|
|
|
|
|
|
|
|
@ -99,17 +97,12 @@ export class GfHomeSummaryComponent implements OnDestroy, OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private update() { |
|
|
private update() { |
|
|
this.isLoading = true; |
|
|
this.isLoading = true; |
|
|
|
|
|
|
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchPortfolioDetails() |
|
|
.fetchPortfolioDetails() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ summary }) => { |
|
|
.subscribe(({ summary }) => { |
|
|
this.summary = summary; |
|
|
this.summary = summary; |
|
|
this.isLoading = false; |
|
|
this.isLoading = false; |
|
|
|