From 3325f845511bfdea477b27903ae2bd731241f9ef Mon Sep 17 00:00:00 2001 From: Daniel Idem Date: Thu, 15 Aug 2024 14:49:47 +0100 Subject: [PATCH] Feature/update confirmation dialog --- .../access-table/access-table.component.ts | 18 +++++++------ .../admin-market-data.service.ts | 26 +++++++------------ .../admin-overview.component.ts | 1 + .../admin-platform.component.ts | 4 +-- .../admin-tag/admin-tag.component.ts | 4 +-- .../admin-users/admin-users.component.ts | 4 +-- .../user-account-settings.component.ts | 19 +++----------- 7 files changed, 29 insertions(+), 47 deletions(-) diff --git a/apps/client/src/app/components/access-table/access-table.component.ts b/apps/client/src/app/components/access-table/access-table.component.ts index 12412a3c2..7772451d4 100644 --- a/apps/client/src/app/components/access-table/access-table.component.ts +++ b/apps/client/src/app/components/access-table/access-table.component.ts @@ -1,3 +1,5 @@ +import { ConfirmationDialogType } from '@ghostfolio/client/core/notification/confirmation-dialog/confirmation-dialog.type'; +import { NotificationService } from '@ghostfolio/client/core/notification/notification.service'; import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; import { Access } from '@ghostfolio/common/interfaces'; @@ -29,7 +31,7 @@ export class AccessTableComponent implements OnChanges, OnInit { public defaultLanguageCode = DEFAULT_LANGUAGE_CODE; public displayedColumns = []; - public constructor() {} + public constructor(private notificationService: NotificationService) {} public ngOnInit() {} @@ -46,12 +48,12 @@ export class AccessTableComponent implements OnChanges, OnInit { } public onDeleteAccess(aId: string) { - const confirmation = confirm( - $localize`Do you really want to revoke this granted access?` - ); - - if (confirmation) { - this.accessDeleted.emit(aId); - } + this.notificationService.confirm({ + confirmFn: () => { + this.accessDeleted.emit(aId); + }, + confirmType: ConfirmationDialogType.Warn, + title: $localize`Do you really want to revoke this granted access?` + }); } } diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts index f1bd9e826..d952467a5 100644 --- a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts +++ b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts @@ -50,27 +50,19 @@ export class AdminMarketDataService { .pipe( catchError(() => { this.notificationService.alert({ - title: '', - message: $localize`Oops! Could not delete profiles.` + title: $localize`Oops! Could not delete profiles.` }); - forkJoin(deleteRequests) - .pipe( - catchError(() => { - this.notificationService.alert({ - title: $localize`Oops! Could not delete profiles.` - }); - - return EMPTY; - }), - finalize(() => { + return EMPTY; + }), + finalize(() => { window.location.reload(); - setTimeout(() => { - }, 300); - }) - ) - .subscribe(() => {}); + setTimeout(() => {}, 300); + }) + ) + .subscribe(() => {}); }, + confirmType: ConfirmationDialogType.Warn, title: $localize`Do you really want to delete these profiles?` }); diff --git a/apps/client/src/app/components/admin-overview/admin-overview.component.ts b/apps/client/src/app/components/admin-overview/admin-overview.component.ts index 6ea955873..9763f960f 100644 --- a/apps/client/src/app/components/admin-overview/admin-overview.component.ts +++ b/apps/client/src/app/components/admin-overview/admin-overview.component.ts @@ -1,3 +1,4 @@ +import { ConfirmationDialogType } from '@ghostfolio/client/core/notification/confirmation-dialog/confirmation-dialog.type'; import { NotificationService } from '@ghostfolio/client/core/notification/notification.service'; import { AdminService } from '@ghostfolio/client/services/admin.service'; import { CacheService } from '@ghostfolio/client/services/cache.service'; diff --git a/apps/client/src/app/components/admin-platform/admin-platform.component.ts b/apps/client/src/app/components/admin-platform/admin-platform.component.ts index 177c08e7e..bef4bc9b0 100644 --- a/apps/client/src/app/components/admin-platform/admin-platform.component.ts +++ b/apps/client/src/app/components/admin-platform/admin-platform.component.ts @@ -47,10 +47,10 @@ export class AdminPlatformComponent implements OnInit, OnDestroy { private dataService: DataService, private deviceService: DeviceDetectorService, private dialog: MatDialog, + private notificationService: NotificationService, private route: ActivatedRoute, private router: Router, - private userService: UserService, - private notificationService: NotificationService + private userService: UserService ) { this.route.queryParams .pipe(takeUntil(this.unsubscribeSubject)) diff --git a/apps/client/src/app/components/admin-tag/admin-tag.component.ts b/apps/client/src/app/components/admin-tag/admin-tag.component.ts index d53c74b5e..bd501eaa6 100644 --- a/apps/client/src/app/components/admin-tag/admin-tag.component.ts +++ b/apps/client/src/app/components/admin-tag/admin-tag.component.ts @@ -47,10 +47,10 @@ export class AdminTagComponent implements OnInit, OnDestroy { private dataService: DataService, private deviceService: DeviceDetectorService, private dialog: MatDialog, + private notificationService: NotificationService, private route: ActivatedRoute, private router: Router, - private userService: UserService, - private notificationService: NotificationService + private userService: UserService ) { this.route.queryParams .pipe(takeUntil(this.unsubscribeSubject)) diff --git a/apps/client/src/app/components/admin-users/admin-users.component.ts b/apps/client/src/app/components/admin-users/admin-users.component.ts index dd74565a3..08395fded 100644 --- a/apps/client/src/app/components/admin-users/admin-users.component.ts +++ b/apps/client/src/app/components/admin-users/admin-users.component.ts @@ -41,8 +41,8 @@ export class AdminUsersComponent implements OnDestroy, OnInit { private changeDetectorRef: ChangeDetectorRef, private dataService: DataService, private impersonationStorageService: ImpersonationStorageService, - private userService: UserService, - private notificationService: NotificationService + private notificationService: NotificationService, + private userService: UserService ) { this.info = this.dataService.fetchInfo(); diff --git a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts index eef5fe143..3795a49ca 100644 --- a/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts +++ b/apps/client/src/app/components/user-account-settings/user-account-settings.component.ts @@ -1,5 +1,5 @@ -import { NotificationService } from '@ghostfolio/client/core/notification/notification.service'; import { ConfirmationDialogType } from '@ghostfolio/client/core/notification/confirmation-dialog/confirmation-dialog.type'; +import { NotificationService } from '@ghostfolio/client/core/notification/notification.service'; import { DataService } from '@ghostfolio/client/services/data.service'; import { KEY_STAY_SIGNED_IN, @@ -76,8 +76,7 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { private snackBar: MatSnackBar, private tokenStorageService: TokenStorageService, private userService: UserService, - public webAuthnService: WebAuthnService, - private notificationService: NotificationService + public webAuthnService: WebAuthnService ) { const { baseCurrency, currencies } = this.dataService.fetchInfo(); @@ -157,21 +156,9 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { .pipe( catchError(() => { this.notificationService.alert({ - title: '', - message: $localize`Oops! Incorrect Security Token.` + title: $localize`Oops! Incorrect Security Token.` }); - if (confirmation) { - this.dataService - .deleteOwnUser({ - accessToken: this.deleteOwnUserForm.get('accessToken').value - }) - .pipe( - catchError(() => { - this.notificationService.alert({ - title: $localize`Oops! Incorrect Security Token.` - }); - return EMPTY; }), takeUntil(this.unsubscribeSubject)