|
|
@ -26,11 +26,12 @@ import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectorRef, |
|
|
ChangeDetectorRef, |
|
|
Component, |
|
|
Component, |
|
|
|
|
|
DestroyRef, |
|
|
Inject, |
|
|
Inject, |
|
|
OnDestroy, |
|
|
|
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; |
|
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|
|
import { MatDialogModule } from '@angular/material/dialog'; |
|
|
import { MatDialogModule } from '@angular/material/dialog'; |
|
|
@ -49,8 +50,7 @@ import { |
|
|
} from 'ionicons/icons'; |
|
|
} from 'ionicons/icons'; |
|
|
import { isNumber } from 'lodash'; |
|
|
import { isNumber } from 'lodash'; |
|
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; |
|
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; |
|
|
import { forkJoin, Subject } from 'rxjs'; |
|
|
import { forkJoin } from 'rxjs'; |
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
import { AccountDetailDialogParams } from './interfaces/interfaces'; |
|
|
import { AccountDetailDialogParams } from './interfaces/interfaces'; |
|
|
|
|
|
|
|
|
@ -77,7 +77,7 @@ import { AccountDetailDialogParams } from './interfaces/interfaces'; |
|
|
styleUrls: ['./account-detail-dialog.component.scss'], |
|
|
styleUrls: ['./account-detail-dialog.component.scss'], |
|
|
templateUrl: 'account-detail-dialog.html' |
|
|
templateUrl: 'account-detail-dialog.html' |
|
|
}) |
|
|
}) |
|
|
export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
export class GfAccountDetailDialogComponent implements OnInit { |
|
|
public accountBalances: AccountBalancesResponse['balances']; |
|
|
public accountBalances: AccountBalancesResponse['balances']; |
|
|
public activities: OrderWithAccount[]; |
|
|
public activities: OrderWithAccount[]; |
|
|
public activitiesCount: number; |
|
|
public activitiesCount: number; |
|
|
@ -104,18 +104,17 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
public user: User; |
|
|
public user: User; |
|
|
public valueInBaseCurrency: number; |
|
|
public valueInBaseCurrency: number; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
@Inject(MAT_DIALOG_DATA) public data: AccountDetailDialogParams, |
|
|
@Inject(MAT_DIALOG_DATA) public data: AccountDetailDialogParams, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
|
|
|
private destroyRef: DestroyRef, |
|
|
public dialogRef: MatDialogRef<GfAccountDetailDialogComponent>, |
|
|
public dialogRef: MatDialogRef<GfAccountDetailDialogComponent>, |
|
|
private router: Router, |
|
|
private router: Router, |
|
|
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; |
|
|
@ -154,7 +153,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
public onAddAccountBalance(accountBalance: CreateAccountBalanceDto) { |
|
|
public onAddAccountBalance(accountBalance: CreateAccountBalanceDto) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.postAccountBalance(accountBalance) |
|
|
.postAccountBalance(accountBalance) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.initialize(); |
|
|
this.initialize(); |
|
|
}); |
|
|
}); |
|
|
@ -163,7 +162,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
public onDeleteAccountBalance(aId: string) { |
|
|
public onDeleteAccountBalance(aId: string) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.deleteAccountBalance(aId) |
|
|
.deleteAccountBalance(aId) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.initialize(); |
|
|
this.initialize(); |
|
|
}); |
|
|
}); |
|
|
@ -176,7 +175,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchExport({ activityIds }) |
|
|
.fetchExport({ activityIds }) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((data) => { |
|
|
.subscribe((data) => { |
|
|
downloadAsFile({ |
|
|
downloadAsFile({ |
|
|
content: data, |
|
|
content: data, |
|
|
@ -212,7 +211,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
private fetchAccount() { |
|
|
private fetchAccount() { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchAccount(this.data.accountId) |
|
|
.fetchAccount(this.data.accountId) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe( |
|
|
.subscribe( |
|
|
({ |
|
|
({ |
|
|
activitiesCount, |
|
|
activitiesCount, |
|
|
@ -287,7 +286,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
sortColumn: this.sortColumn, |
|
|
sortColumn: this.sortColumn, |
|
|
sortDirection: this.sortDirection |
|
|
sortDirection: this.sortDirection |
|
|
}) |
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ activities, count }) => { |
|
|
.subscribe(({ activities, count }) => { |
|
|
this.dataSource = new MatTableDataSource(activities); |
|
|
this.dataSource = new MatTableDataSource(activities); |
|
|
this.totalItems = count; |
|
|
this.totalItems = count; |
|
|
@ -304,7 +303,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
forkJoin({ |
|
|
forkJoin({ |
|
|
accountBalances: this.dataService |
|
|
accountBalances: this.dataService |
|
|
.fetchAccountBalances(this.data.accountId) |
|
|
.fetchAccountBalances(this.data.accountId) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)), |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)), |
|
|
portfolioPerformance: this.dataService |
|
|
portfolioPerformance: this.dataService |
|
|
.fetchPortfolioPerformance({ |
|
|
.fetchPortfolioPerformance({ |
|
|
filters: [ |
|
|
filters: [ |
|
|
@ -317,7 +316,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
withExcludedAccounts: true, |
|
|
withExcludedAccounts: true, |
|
|
withItems: true |
|
|
withItems: true |
|
|
}) |
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
}).subscribe({ |
|
|
}).subscribe({ |
|
|
error: () => { |
|
|
error: () => { |
|
|
this.isLoadingChart = false; |
|
|
this.isLoadingChart = false; |
|
|
@ -360,7 +359,7 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}) |
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ holdings }) => { |
|
|
.subscribe(({ holdings }) => { |
|
|
this.holdings = holdings; |
|
|
this.holdings = holdings; |
|
|
|
|
|
|
|
|
@ -374,9 +373,4 @@ export class GfAccountDetailDialogComponent implements OnDestroy, OnInit { |
|
|
this.fetchChart(); |
|
|
this.fetchChart(); |
|
|
this.fetchPortfolioHoldings(); |
|
|
this.fetchPortfolioHoldings(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|