|
|
@ -20,11 +20,12 @@ import { |
|
|
Component, |
|
|
Component, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
DestroyRef, |
|
|
DestroyRef, |
|
|
|
|
|
inject, |
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { |
|
|
import { |
|
|
FormBuilder, |
|
|
NonNullableFormBuilder, |
|
|
FormsModule, |
|
|
FormsModule, |
|
|
ReactiveFormsModule, |
|
|
ReactiveFormsModule, |
|
|
Validators |
|
|
Validators |
|
|
@ -69,22 +70,22 @@ import { catchError } from 'rxjs/operators'; |
|
|
templateUrl: './user-account-settings.html' |
|
|
templateUrl: './user-account-settings.html' |
|
|
}) |
|
|
}) |
|
|
export class GfUserAccountSettingsComponent implements OnInit { |
|
|
export class GfUserAccountSettingsComponent implements OnInit { |
|
|
public appearancePlaceholder = $localize`Auto`; |
|
|
protected readonly appearancePlaceholder = $localize`Auto`; |
|
|
public baseCurrency: string; |
|
|
protected readonly baseCurrency: string; |
|
|
public closeUserAccountMail: string; |
|
|
protected closeUserAccountMail: string; |
|
|
public currencies: string[] = []; |
|
|
protected readonly currencies: string[] = []; |
|
|
public deleteOwnUserForm = this.formBuilder.group({ |
|
|
protected readonly deleteOwnUserForm = inject(NonNullableFormBuilder).group({ |
|
|
accessToken: ['', Validators.required] |
|
|
accessToken: ['', Validators.required] |
|
|
}); |
|
|
}); |
|
|
public hasPermissionToDeleteOwnUser: boolean; |
|
|
protected hasPermissionToDeleteOwnUser: boolean; |
|
|
public hasPermissionToRequestOwnUserDeletion: boolean; |
|
|
protected hasPermissionToRequestOwnUserDeletion: boolean; |
|
|
public hasPermissionToUpdateViewMode: boolean; |
|
|
protected hasPermissionToUpdateViewMode: boolean; |
|
|
public hasPermissionToUpdateUserSettings: boolean; |
|
|
protected hasPermissionToUpdateUserSettings: boolean; |
|
|
public isAccessTokenHidden = true; |
|
|
protected isAccessTokenHidden = true; |
|
|
public isFingerprintSupported = this.doesBrowserSupportAuthn(); |
|
|
protected readonly isFingerprintSupported = this.doesBrowserSupportAuthn(); |
|
|
public isWebAuthnEnabled: boolean; |
|
|
protected isWebAuthnEnabled: boolean; |
|
|
public language = document.documentElement.lang; |
|
|
protected readonly language = document.documentElement.lang; |
|
|
public locales = [ |
|
|
protected locales = [ |
|
|
'ca', |
|
|
'ca', |
|
|
'de', |
|
|
'de', |
|
|
'de-CH', |
|
|
'de-CH', |
|
|
@ -102,19 +103,18 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
'uk', |
|
|
'uk', |
|
|
'zh' |
|
|
'zh' |
|
|
]; |
|
|
]; |
|
|
public user: User; |
|
|
protected user: User; |
|
|
|
|
|
|
|
|
public constructor( |
|
|
private readonly changeDetectorRef = inject(ChangeDetectorRef); |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private readonly dataService = inject(DataService); |
|
|
private dataService: DataService, |
|
|
private readonly destroyRef = inject(DestroyRef); |
|
|
private destroyRef: DestroyRef, |
|
|
private readonly notificationService = inject(NotificationService); |
|
|
private formBuilder: FormBuilder, |
|
|
private readonly settingsStorageService = inject(SettingsStorageService); |
|
|
private notificationService: NotificationService, |
|
|
private readonly snackBar = inject(MatSnackBar); |
|
|
private settingsStorageService: SettingsStorageService, |
|
|
private readonly userService = inject(UserService); |
|
|
private snackBar: MatSnackBar, |
|
|
private readonly webAuthnService = inject(WebAuthnService); |
|
|
private userService: UserService, |
|
|
|
|
|
public webAuthnService: WebAuthnService |
|
|
public constructor() { |
|
|
) { |
|
|
|
|
|
const { baseCurrency, currencies } = this.dataService.fetchInfo(); |
|
|
const { baseCurrency, currencies } = this.dataService.fetchInfo(); |
|
|
|
|
|
|
|
|
this.baseCurrency = baseCurrency; |
|
|
this.baseCurrency = baseCurrency; |
|
|
@ -148,7 +148,10 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
permissions.updateViewMode |
|
|
permissions.updateViewMode |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (this.user.settings.locale) { |
|
|
this.locales.push(this.user.settings.locale); |
|
|
this.locales.push(this.user.settings.locale); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.locales = Array.from(new Set(this.locales)).sort(); |
|
|
this.locales = Array.from(new Set(this.locales)).sort(); |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
@ -162,11 +165,11 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
this.update(); |
|
|
this.update(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public isCommunityLanguage() { |
|
|
protected isCommunityLanguage() { |
|
|
return !['de', 'en'].includes(this.language); |
|
|
return !['de', 'en'].includes(this.language); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onChangeUserSetting(aKey: string, aValue: string) { |
|
|
protected onChangeUserSetting(aKey: string, aValue: string) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.putUserSetting({ [aKey]: aValue }) |
|
|
.putUserSetting({ [aKey]: aValue }) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
@ -190,12 +193,12 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onCloseAccount() { |
|
|
protected onCloseAccount() { |
|
|
this.notificationService.confirm({ |
|
|
this.notificationService.confirm({ |
|
|
confirmFn: () => { |
|
|
confirmFn: () => { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.deleteOwnUser({ |
|
|
.deleteOwnUser({ |
|
|
accessToken: this.deleteOwnUserForm.get('accessToken').value |
|
|
accessToken: this.deleteOwnUserForm.controls.accessToken.value |
|
|
}) |
|
|
}) |
|
|
.pipe( |
|
|
.pipe( |
|
|
catchError(() => { |
|
|
catchError(() => { |
|
|
@ -218,7 +221,7 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onExperimentalFeaturesChange(aEvent: MatSlideToggleChange) { |
|
|
protected onExperimentalFeaturesChange(aEvent: MatSlideToggleChange) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.putUserSetting({ isExperimentalFeatures: aEvent.checked }) |
|
|
.putUserSetting({ isExperimentalFeatures: aEvent.checked }) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
@ -234,13 +237,13 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onExport() { |
|
|
protected onExport() { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchExport() |
|
|
.fetchExport() |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((data) => { |
|
|
.subscribe((data) => { |
|
|
for (const activity of data.activities) { |
|
|
for (const activity of data.activities) { |
|
|
delete activity.id; |
|
|
delete (activity as Omit<typeof activity, 'id'> & { id?: string }).id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
downloadAsFile({ |
|
|
downloadAsFile({ |
|
|
@ -254,7 +257,7 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onRestrictedViewChange(aEvent: MatSlideToggleChange) { |
|
|
protected onRestrictedViewChange(aEvent: MatSlideToggleChange) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.putUserSetting({ isRestrictedView: aEvent.checked }) |
|
|
.putUserSetting({ isRestrictedView: aEvent.checked }) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
@ -270,7 +273,7 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async onSignInWithFingerprintChange(aEvent: MatSlideToggleChange) { |
|
|
protected async onSignInWithFingerprintChange(aEvent: MatSlideToggleChange) { |
|
|
if (aEvent.checked) { |
|
|
if (aEvent.checked) { |
|
|
try { |
|
|
try { |
|
|
await this.registerDevice(); |
|
|
await this.registerDevice(); |
|
|
@ -293,7 +296,7 @@ export class GfUserAccountSettingsComponent implements OnInit { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onViewModeChange(aEvent: MatSlideToggleChange) { |
|
|
protected onViewModeChange(aEvent: MatSlideToggleChange) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.putUserSetting({ viewMode: aEvent.checked === true ? 'ZEN' : 'DEFAULT' }) |
|
|
.putUserSetting({ viewMode: aEvent.checked === true ? 'ZEN' : 'DEFAULT' }) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
|