Browse Source

Feature/update confirmation dialog

pull/3671/head
Daniel Idem 1 year ago
parent
commit
bf4dca3aac
  1. 37
      apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
  2. 58
      apps/client/src/app/components/admin-overview/admin-overview.component.ts
  3. 17
      apps/client/src/app/components/admin-platform/admin-platform.component.ts
  4. 17
      apps/client/src/app/components/admin-tag/admin-tag.component.ts
  5. 17
      apps/client/src/app/components/admin-users/admin-users.component.ts
  6. 37
      apps/client/src/app/components/user-account-settings/user-account-settings.component.ts
  7. 19
      libs/ui/src/lib/account-balances/account-balances.component.ts
  8. 31
      libs/ui/src/lib/activities-table/activities-table.component.ts

37
apps/client/src/app/components/admin-market-data/admin-market-data.service.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 { AdminService } from '@ghostfolio/client/services/admin.service'; import { AdminService } from '@ghostfolio/client/services/admin.service';
import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config'; import { ghostfolioScraperApiSymbolPrefix } from '@ghostfolio/common/config';
import { getCurrencyFromSymbol, isCurrency } from '@ghostfolio/common/helper'; import { getCurrencyFromSymbol, isCurrency } from '@ghostfolio/common/helper';
@ -7,18 +9,19 @@ import {
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { title } from 'process';
import { EMPTY, catchError, finalize, forkJoin, takeUntil } from 'rxjs'; import { EMPTY, catchError, finalize, forkJoin, takeUntil } from 'rxjs';
@Injectable() @Injectable()
export class AdminMarketDataService { export class AdminMarketDataService {
public constructor(private adminService: AdminService) {} public constructor(
private adminService: AdminService,
private notificationService: NotificationService
) {}
public deleteAssetProfile({ dataSource, symbol }: AssetProfileIdentifier) { public deleteAssetProfile({ dataSource, symbol }: AssetProfileIdentifier) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this asset profile?` confirmFn: () => {
);
if (confirmation) {
this.adminService this.adminService
.deleteProfileData({ dataSource, symbol }) .deleteProfileData({ dataSource, symbol })
.subscribe(() => { .subscribe(() => {
@ -26,17 +29,17 @@ export class AdminMarketDataService {
window.location.reload(); window.location.reload();
}, 300); }, 300);
}); });
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this asset profile?`
});
} }
public deleteAssetProfiles( public deleteAssetProfiles(
aAssetProfileIdentifiers: AssetProfileIdentifier[] aAssetProfileIdentifiers: AssetProfileIdentifier[]
) { ) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete these profiles?` confirmFn: () => {
);
if (confirmation) {
const deleteRequests = aAssetProfileIdentifiers.map( const deleteRequests = aAssetProfileIdentifiers.map(
({ dataSource, symbol }) => { ({ dataSource, symbol }) => {
return this.adminService.deleteProfileData({ dataSource, symbol }); return this.adminService.deleteProfileData({ dataSource, symbol });
@ -46,7 +49,10 @@ export class AdminMarketDataService {
forkJoin(deleteRequests) forkJoin(deleteRequests)
.pipe( .pipe(
catchError(() => { catchError(() => {
alert($localize`Oops! Could not delete profiles.`); this.notificationService.alert({
title: '',
message: $localize`Oops! Could not delete profiles.`
});
return EMPTY; return EMPTY;
}), }),
@ -57,7 +63,10 @@ export class AdminMarketDataService {
}) })
) )
.subscribe(() => {}); .subscribe(() => {});
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete these profiles?`
});
} }
public hasPermissionToDeleteAssetProfile({ public hasPermissionToDeleteAssetProfile({

58
apps/client/src/app/components/admin-overview/admin-overview.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 { AdminService } from '@ghostfolio/client/services/admin.service'; import { AdminService } from '@ghostfolio/client/services/admin.service';
import { CacheService } from '@ghostfolio/client/services/cache.service'; import { CacheService } from '@ghostfolio/client/services/cache.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
@ -60,7 +62,8 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
private cacheService: CacheService, private cacheService: CacheService,
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService, private dataService: DataService,
private userService: UserService private userService: UserService,
private notificationService: NotificationService
) { ) {
this.info = this.dataService.fetchInfo(); this.info = this.dataService.fetchInfo();
@ -136,39 +139,42 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
} }
public onDeleteCoupon(aCouponCode: string) { public onDeleteCoupon(aCouponCode: string) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this coupon?` confirmFn: () => {
);
if (confirmation === true) {
const coupons = this.coupons.filter((coupon) => { const coupons = this.coupons.filter((coupon) => {
return coupon.code !== aCouponCode; return coupon.code !== aCouponCode;
}); });
this.putAdminSetting({ key: PROPERTY_COUPONS, value: coupons }); this.putAdminSetting({ key: PROPERTY_COUPONS, value: coupons });
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this coupon?`
});
} }
public onDeleteCurrency(aCurrency: string) { public onDeleteCurrency(aCurrency: string) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this currency?` confirmFn: () => {
);
if (confirmation === true) {
const currencies = this.customCurrencies.filter((currency) => { const currencies = this.customCurrencies.filter((currency) => {
return currency !== aCurrency; return currency !== aCurrency;
}); });
this.putAdminSetting({ key: PROPERTY_CURRENCIES, value: currencies }); this.putAdminSetting({ key: PROPERTY_CURRENCIES, value: currencies });
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this currency?`
});
} }
public onDeleteSystemMessage() { public onDeleteSystemMessage() {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this system message?` confirmFn: () => {
); this.putAdminSetting({
key: PROPERTY_SYSTEM_MESSAGE,
if (confirmation === true) { value: undefined
this.putAdminSetting({ key: PROPERTY_SYSTEM_MESSAGE, value: undefined }); });
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this system message?`
});
} }
public onEnableDataGatheringChange(aEvent: MatSlideToggleChange) { public onEnableDataGatheringChange(aEvent: MatSlideToggleChange) {
@ -179,11 +185,8 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
} }
public onFlushCache() { public onFlushCache() {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to flush the cache?` confirmFn: () => {
);
if (confirmation === true) {
this.cacheService this.cacheService
.flush() .flush()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -192,7 +195,10 @@ export class AdminOverviewComponent implements OnDestroy, OnInit {
window.location.reload(); window.location.reload();
}, 300); }, 300);
}); });
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to flush the cache?`
});
} }
public onEnableUserSignupModeChange(aEvent: MatSlideToggleChange) { public onEnableUserSignupModeChange(aEvent: MatSlideToggleChange) {

17
apps/client/src/app/components/admin-platform/admin-platform.component.ts

@ -1,5 +1,7 @@
import { CreatePlatformDto } from '@ghostfolio/api/app/platform/create-platform.dto'; import { CreatePlatformDto } from '@ghostfolio/api/app/platform/create-platform.dto';
import { UpdatePlatformDto } from '@ghostfolio/api/app/platform/update-platform.dto'; import { UpdatePlatformDto } from '@ghostfolio/api/app/platform/update-platform.dto';
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 { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
@ -47,7 +49,8 @@ export class AdminPlatformComponent implements OnInit, OnDestroy {
private dialog: MatDialog, private dialog: MatDialog,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private userService: UserService private userService: UserService,
private notificationService: NotificationService
) { ) {
this.route.queryParams this.route.queryParams
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -75,13 +78,13 @@ export class AdminPlatformComponent implements OnInit, OnDestroy {
} }
public onDeletePlatform(aId: string) { public onDeletePlatform(aId: string) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this platform?` confirmFn: () => {
);
if (confirmation) {
this.deletePlatform(aId); this.deletePlatform(aId);
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this platform?`
});
} }
public onUpdatePlatform({ id }: Platform) { public onUpdatePlatform({ id }: Platform) {

17
apps/client/src/app/components/admin-tag/admin-tag.component.ts

@ -1,5 +1,7 @@
import { CreateTagDto } from '@ghostfolio/api/app/tag/create-tag.dto'; import { CreateTagDto } from '@ghostfolio/api/app/tag/create-tag.dto';
import { UpdateTagDto } from '@ghostfolio/api/app/tag/update-tag.dto'; import { UpdateTagDto } from '@ghostfolio/api/app/tag/update-tag.dto';
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 { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
@ -47,7 +49,8 @@ export class AdminTagComponent implements OnInit, OnDestroy {
private dialog: MatDialog, private dialog: MatDialog,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private userService: UserService private userService: UserService,
private notificationService: NotificationService
) { ) {
this.route.queryParams this.route.queryParams
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -75,13 +78,13 @@ export class AdminTagComponent implements OnInit, OnDestroy {
} }
public onDeleteTag(aId: string) { public onDeleteTag(aId: string) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this tag?` confirmFn: () => {
);
if (confirmation) {
this.deleteTag(aId); this.deleteTag(aId);
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this tag?`
});
} }
public onUpdateTag({ id }: Tag) { public onUpdateTag({ id }: Tag) {

17
apps/client/src/app/components/admin-users/admin-users.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 { AdminService } from '@ghostfolio/client/services/admin.service'; import { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
@ -39,7 +41,8 @@ export class AdminUsersComponent implements OnDestroy, OnInit {
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService, private dataService: DataService,
private impersonationStorageService: ImpersonationStorageService, private impersonationStorageService: ImpersonationStorageService,
private userService: UserService private userService: UserService,
private notificationService: NotificationService
) { ) {
this.info = this.dataService.fetchInfo(); this.info = this.dataService.fetchInfo();
@ -109,11 +112,8 @@ export class AdminUsersComponent implements OnDestroy, OnInit {
} }
public onDeleteUser(aId: string) { public onDeleteUser(aId: string) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this user?` confirmFn: () => {
);
if (confirmation) {
this.dataService this.dataService
.deleteUser(aId) .deleteUser(aId)
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -122,7 +122,10 @@ export class AdminUsersComponent implements OnDestroy, OnInit {
this.fetchAdminData(); this.fetchAdminData();
} }
}); });
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this user?`
});
} }
public onImpersonateUser(aId: string) { public onImpersonateUser(aId: string) {

37
apps/client/src/app/components/user-account-settings/user-account-settings.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 { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { import {
KEY_STAY_SIGNED_IN, KEY_STAY_SIGNED_IN,
@ -73,7 +75,8 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit {
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private tokenStorageService: TokenStorageService, private tokenStorageService: TokenStorageService,
private userService: UserService, private userService: UserService,
public webAuthnService: WebAuthnService public webAuthnService: WebAuthnService,
private notificationService: NotificationService
) { ) {
const { baseCurrency, currencies } = this.dataService.fetchInfo(); const { baseCurrency, currencies } = this.dataService.fetchInfo();
@ -144,18 +147,18 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit {
} }
public onCloseAccount() { public onCloseAccount() {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to close your Ghostfolio account?` confirmFn: () => {
);
if (confirmation) {
this.dataService this.dataService
.deleteOwnUser({ .deleteOwnUser({
accessToken: this.deleteOwnUserForm.get('accessToken').value accessToken: this.deleteOwnUserForm.get('accessToken').value
}) })
.pipe( .pipe(
catchError(() => { catchError(() => {
alert($localize`Oops! Incorrect Security Token.`); this.notificationService.alert({
title: '',
message: $localize`Oops! Incorrect Security Token.`
});
return EMPTY; return EMPTY;
}), }),
@ -167,7 +170,10 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit {
document.location.href = `/${document.documentElement.lang}`; document.location.href = `/${document.documentElement.lang}`;
}); });
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to close your Ghostfolio account?`
});
} }
public onExperimentalFeaturesChange(aEvent: MatSlideToggleChange) { public onExperimentalFeaturesChange(aEvent: MatSlideToggleChange) {
@ -236,15 +242,16 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
} else { } else {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to remove this sign in method?` confirmFn: () => {
);
if (confirmation) {
this.deregisterDevice(); this.deregisterDevice();
} else { },
discardFn: () => {
this.update(); this.update();
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to remove this sign in method?`
});
} }
} }

19
libs/ui/src/lib/account-balances/account-balances.component.ts

@ -1,4 +1,6 @@
import { CreateAccountBalanceDto } from '@ghostfolio/api/app/account-balance/create-account-balance.dto'; import { CreateAccountBalanceDto } from '@ghostfolio/api/app/account-balance/create-account-balance.dto';
import { ConfirmationDialogType } from '@ghostfolio/client/core/notification/confirmation-dialog/confirmation-dialog.type';
import { NotificationService } from '@ghostfolio/client/core/notification/notification.service';
import { validateObjectForForm } from '@ghostfolio/client/util/form.util'; import { validateObjectForForm } from '@ghostfolio/client/util/form.util';
import { getLocale } from '@ghostfolio/common/helper'; import { getLocale } from '@ghostfolio/common/helper';
import { AccountBalancesResponse } from '@ghostfolio/common/interfaces'; import { AccountBalancesResponse } from '@ghostfolio/common/interfaces';
@ -81,7 +83,10 @@ export class GfAccountBalancesComponent
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
public constructor(private dateAdapter: DateAdapter<any>) {} public constructor(
private dateAdapter: DateAdapter<any>,
private notificationService: NotificationService
) {}
public ngOnInit() { public ngOnInit() {
this.dateAdapter.setLocale(this.locale); this.dateAdapter.setLocale(this.locale);
@ -97,13 +102,13 @@ export class GfAccountBalancesComponent
} }
public onDeleteAccountBalance(aId: string) { public onDeleteAccountBalance(aId: string) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this account balance?` confirmFn: () => {
);
if (confirmation) {
this.accountBalanceDeleted.emit(aId); this.accountBalanceDeleted.emit(aId);
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this account balance?`
});
} }
public async onSubmitAccountBalance() { public async onSubmitAccountBalance() {

31
libs/ui/src/lib/activities-table/activities-table.component.ts

@ -1,5 +1,7 @@
import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface'; import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface';
import { GfAssetProfileIconComponent } from '@ghostfolio/client/components/asset-profile-icon/asset-profile-icon.component'; import { GfAssetProfileIconComponent } from '@ghostfolio/client/components/asset-profile-icon/asset-profile-icon.component';
import { ConfirmationDialogType } from '@ghostfolio/client/core/notification/confirmation-dialog/confirmation-dialog.type';
import { NotificationService } from '@ghostfolio/client/core/notification/notification.service';
import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module'; import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module';
import { DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config'; import { DEFAULT_PAGE_SIZE } from '@ghostfolio/common/config';
import { getDateFormatString, getLocale } from '@ghostfolio/common/helper'; import { getDateFormatString, getLocale } from '@ghostfolio/common/helper';
@ -120,7 +122,10 @@ export class GfActivitiesTableComponent
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
public constructor(private router: Router) {} public constructor(
private router: Router,
private notificationService: NotificationService
) {}
public ngOnInit() { public ngOnInit() {
if (this.showCheckbox) { if (this.showCheckbox) {
@ -212,23 +217,23 @@ export class GfActivitiesTableComponent
} }
public onDeleteActivities() { public onDeleteActivities() {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete these activities?` confirmFn: () => {
);
if (confirmation) {
this.activitiesDeleted.emit(); this.activitiesDeleted.emit();
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete these activities?`
});
} }
public onDeleteActivity(aId: string) { public onDeleteActivity(aId: string) {
const confirmation = confirm( this.notificationService.confirm({
$localize`Do you really want to delete this activity?` confirmFn: () => {
);
if (confirmation) {
this.activityDeleted.emit(aId); this.activityDeleted.emit(aId);
} },
confirmType: ConfirmationDialogType.Warn,
title: $localize`Do you really want to delete this activity?`
});
} }
public onExport() { public onExport() {

Loading…
Cancel
Save