Feature/migrate setting Ghostfolio API key prompt dialog (#4151)

* Migrate setting Ghostfolio API key prompt dialog
pull/4135/head^2
Thomas Kaul 6 days ago committed by GitHub
parent 74bc8222d6
commit 3f84caa9f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,3 +1,4 @@
import { NotificationService } from '@ghostfolio/client/core/notification/notification.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { PROPERTY_API_KEY_GHOSTFOLIO } from '@ghostfolio/common/config'; import { PROPERTY_API_KEY_GHOSTFOLIO } from '@ghostfolio/common/config';
import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator';
@ -32,7 +33,8 @@ export class GfGhostfolioPremiumApiDialogComponent {
public constructor( public constructor(
@Inject(MAT_DIALOG_DATA) public data: GhostfolioPremiumApiDialogParams, @Inject(MAT_DIALOG_DATA) public data: GhostfolioPremiumApiDialogParams,
private dataService: DataService, private dataService: DataService,
public dialogRef: MatDialogRef<GfGhostfolioPremiumApiDialogComponent> public dialogRef: MatDialogRef<GfGhostfolioPremiumApiDialogComponent>,
private notificationService: NotificationService
) {} ) {}
public onCancel() { public onCancel() {
@ -40,19 +42,21 @@ export class GfGhostfolioPremiumApiDialogComponent {
} }
public onSetGhostfolioApiKey() { public onSetGhostfolioApiKey() {
let ghostfolioApiKey = prompt( this.notificationService.prompt({
$localize`Please enter your Ghostfolio API key:` confirmFn: (value) => {
); const ghostfolioApiKey = value?.trim();
ghostfolioApiKey = ghostfolioApiKey?.trim();
if (ghostfolioApiKey) { if (ghostfolioApiKey) {
this.dataService this.dataService
.putAdminSetting(PROPERTY_API_KEY_GHOSTFOLIO, { .putAdminSetting(PROPERTY_API_KEY_GHOSTFOLIO, {
value: ghostfolioApiKey value: ghostfolioApiKey
}) })
.subscribe(() => { .subscribe(() => {
this.dialogRef.close(); this.dialogRef.close();
}); });
} }
},
title: $localize`Please enter your Ghostfolio API key.`
});
} }
} }

Loading…
Cancel
Save