From 3f84caa9f653fa578398fee368356443d7fb65cb Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:48:28 +0100 Subject: [PATCH] Feature/migrate setting Ghostfolio API key prompt dialog (#4151) * Migrate setting Ghostfolio API key prompt dialog --- ...ghostfolio-premium-api-dialog.component.ts | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/apps/client/src/app/components/admin-settings/ghostfolio-premium-api-dialog/ghostfolio-premium-api-dialog.component.ts b/apps/client/src/app/components/admin-settings/ghostfolio-premium-api-dialog/ghostfolio-premium-api-dialog.component.ts index a8bb29571..8c2907064 100644 --- a/apps/client/src/app/components/admin-settings/ghostfolio-premium-api-dialog/ghostfolio-premium-api-dialog.component.ts +++ b/apps/client/src/app/components/admin-settings/ghostfolio-premium-api-dialog/ghostfolio-premium-api-dialog.component.ts @@ -1,3 +1,4 @@ +import { NotificationService } from '@ghostfolio/client/core/notification/notification.service'; import { DataService } from '@ghostfolio/client/services/data.service'; import { PROPERTY_API_KEY_GHOSTFOLIO } from '@ghostfolio/common/config'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; @@ -32,7 +33,8 @@ export class GfGhostfolioPremiumApiDialogComponent { public constructor( @Inject(MAT_DIALOG_DATA) public data: GhostfolioPremiumApiDialogParams, private dataService: DataService, - public dialogRef: MatDialogRef + public dialogRef: MatDialogRef, + private notificationService: NotificationService ) {} public onCancel() { @@ -40,19 +42,21 @@ export class GfGhostfolioPremiumApiDialogComponent { } public onSetGhostfolioApiKey() { - let ghostfolioApiKey = prompt( - $localize`Please enter your Ghostfolio API key:` - ); - ghostfolioApiKey = ghostfolioApiKey?.trim(); + this.notificationService.prompt({ + confirmFn: (value) => { + const ghostfolioApiKey = value?.trim(); - if (ghostfolioApiKey) { - this.dataService - .putAdminSetting(PROPERTY_API_KEY_GHOSTFOLIO, { - value: ghostfolioApiKey - }) - .subscribe(() => { - this.dialogRef.close(); - }); - } + if (ghostfolioApiKey) { + this.dataService + .putAdminSetting(PROPERTY_API_KEY_GHOSTFOLIO, { + value: ghostfolioApiKey + }) + .subscribe(() => { + this.dialogRef.close(); + }); + } + }, + title: $localize`Please enter your Ghostfolio API key.` + }); } }