|
|
@ -1,4 +1,4 @@ |
|
|
|
import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; |
|
|
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; |
|
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
|
import { ActivatedRoute, Router } from '@angular/router'; |
|
|
|
import { CreateAccountDto } from '@ghostfolio/api/app/account/create-account.dto'; |
|
|
@ -20,7 +20,7 @@ import { CreateOrUpdateAccountDialog } from './create-or-update-account-dialog/c |
|
|
|
templateUrl: './accounts-page.html', |
|
|
|
styleUrls: ['./accounts-page.scss'] |
|
|
|
}) |
|
|
|
export class AccountsPageComponent implements OnInit { |
|
|
|
export class AccountsPageComponent implements OnDestroy, OnInit { |
|
|
|
public accounts: AccountModel[]; |
|
|
|
public deviceType: string; |
|
|
|
public hasImpersonationId: boolean; |
|
|
@ -71,6 +71,7 @@ export class AccountsPageComponent implements OnInit { |
|
|
|
|
|
|
|
this.impersonationStorageService |
|
|
|
.onChangeHasImpersonation() |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe((aId) => { |
|
|
|
this.hasImpersonationId = !!aId; |
|
|
|
}); |
|
|
@ -98,7 +99,10 @@ export class AccountsPageComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
public fetchAccounts() { |
|
|
|
this.dataService.fetchAccounts().subscribe((response) => { |
|
|
|
this.dataService |
|
|
|
.fetchAccounts() |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe((response) => { |
|
|
|
this.accounts = response; |
|
|
|
|
|
|
|
if (this.accounts?.length <= 0) { |
|
|
@ -110,7 +114,10 @@ export class AccountsPageComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
public onDeleteAccount(aId: string) { |
|
|
|
this.dataService.deleteAccount(aId).subscribe({ |
|
|
|
this.dataService |
|
|
|
.deleteAccount(aId) |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe({ |
|
|
|
next: () => { |
|
|
|
this.fetchAccounts(); |
|
|
|
} |
|
|
@ -146,11 +153,17 @@ export class AccountsPageComponent implements OnInit { |
|
|
|
width: this.deviceType === 'mobile' ? '100vw' : '50rem' |
|
|
|
}); |
|
|
|
|
|
|
|
dialogRef.afterClosed().subscribe((data: any) => { |
|
|
|
dialogRef |
|
|
|
.afterClosed() |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe((data: any) => { |
|
|
|
const account: UpdateAccountDto = data?.account; |
|
|
|
|
|
|
|
if (account) { |
|
|
|
this.dataService.putAccount(account).subscribe({ |
|
|
|
this.dataService |
|
|
|
.putAccount(account) |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe({ |
|
|
|
next: () => { |
|
|
|
this.fetchAccounts(); |
|
|
|
} |
|
|
@ -181,11 +194,17 @@ export class AccountsPageComponent implements OnInit { |
|
|
|
width: this.deviceType === 'mobile' ? '100vw' : '50rem' |
|
|
|
}); |
|
|
|
|
|
|
|
dialogRef.afterClosed().subscribe((data: any) => { |
|
|
|
dialogRef |
|
|
|
.afterClosed() |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe((data: any) => { |
|
|
|
const account: CreateAccountDto = data?.account; |
|
|
|
|
|
|
|
if (account) { |
|
|
|
this.dataService.postAccount(account).subscribe({ |
|
|
|
this.dataService |
|
|
|
.postAccount(account) |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe({ |
|
|
|
next: () => { |
|
|
|
this.fetchAccounts(); |
|
|
|
} |
|
|
|