|
@ -4,6 +4,7 @@ import { |
|
|
KEY_TOKEN, |
|
|
KEY_TOKEN, |
|
|
SettingsStorageService |
|
|
SettingsStorageService |
|
|
} from '@ghostfolio/client/services/settings-storage.service'; |
|
|
} from '@ghostfolio/client/services/settings-storage.service'; |
|
|
|
|
|
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; |
|
|
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; |
|
|
import { downloadAsFile } from '@ghostfolio/common/helper'; |
|
|
import { downloadAsFile } from '@ghostfolio/common/helper'; |
|
@ -17,6 +18,7 @@ import { |
|
|
OnDestroy, |
|
|
OnDestroy, |
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { FormBuilder, Validators } from '@angular/forms'; |
|
|
import { MatSlideToggleChange } from '@angular/material/slide-toggle'; |
|
|
import { MatSlideToggleChange } from '@angular/material/slide-toggle'; |
|
|
import { format, parseISO } from 'date-fns'; |
|
|
import { format, parseISO } from 'date-fns'; |
|
|
import { uniq } from 'lodash'; |
|
|
import { uniq } from 'lodash'; |
|
@ -33,8 +35,13 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
public appearancePlaceholder = $localize`Auto`; |
|
|
public appearancePlaceholder = $localize`Auto`; |
|
|
public baseCurrency: string; |
|
|
public baseCurrency: string; |
|
|
public currencies: string[] = []; |
|
|
public currencies: string[] = []; |
|
|
|
|
|
public deleteOwnUserForm = this.formBuilder.group({ |
|
|
|
|
|
accessToken: ['', Validators.required] |
|
|
|
|
|
}); |
|
|
|
|
|
public hasPermissionToDeleteOwnUser: boolean; |
|
|
public hasPermissionToUpdateViewMode: boolean; |
|
|
public hasPermissionToUpdateViewMode: boolean; |
|
|
public hasPermissionToUpdateUserSettings: boolean; |
|
|
public hasPermissionToUpdateUserSettings: boolean; |
|
|
|
|
|
public isAccessTokenHidden = true; |
|
|
public isWebAuthnEnabled: boolean; |
|
|
public isWebAuthnEnabled: boolean; |
|
|
public language = document.documentElement.lang; |
|
|
public language = document.documentElement.lang; |
|
|
public locales = [ |
|
|
public locales = [ |
|
@ -58,7 +65,9 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
|
|
|
private formBuilder: FormBuilder, |
|
|
private settingsStorageService: SettingsStorageService, |
|
|
private settingsStorageService: SettingsStorageService, |
|
|
|
|
|
private tokenStorageService: TokenStorageService, |
|
|
private userService: UserService, |
|
|
private userService: UserService, |
|
|
public webAuthnService: WebAuthnService |
|
|
public webAuthnService: WebAuthnService |
|
|
) { |
|
|
) { |
|
@ -83,6 +92,11 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
permissions.updateViewMode |
|
|
permissions.updateViewMode |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToDeleteOwnUser = hasPermission( |
|
|
|
|
|
this.user.permissions, |
|
|
|
|
|
permissions.deleteOwnUser |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
this.locales.push(this.user.settings.locale); |
|
|
this.locales.push(this.user.settings.locale); |
|
|
this.locales = uniq(this.locales.sort()); |
|
|
this.locales = uniq(this.locales.sort()); |
|
|
|
|
|
|
|
@ -99,6 +113,31 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
return !(this.language === 'de' || this.language === 'en'); |
|
|
return !(this.language === 'de' || this.language === 'en'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public onCloseAccount() { |
|
|
|
|
|
const confirmation = confirm( |
|
|
|
|
|
$localize`Do you really want to close your account?` |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const accessToken = this.deleteOwnUserForm.get('accessToken').value; |
|
|
|
|
|
|
|
|
|
|
|
if (confirmation) { |
|
|
|
|
|
this.dataService |
|
|
|
|
|
.deleteOwnUser(accessToken) |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe({ |
|
|
|
|
|
next: () => { |
|
|
|
|
|
this.tokenStorageService.signOut(); |
|
|
|
|
|
this.userService.remove(); |
|
|
|
|
|
|
|
|
|
|
|
document.location.href = `/${document.documentElement.lang}`; |
|
|
|
|
|
}, |
|
|
|
|
|
error: () => { |
|
|
|
|
|
alert($localize`Oops! Incorrect Security Token.`); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public onChangeUserSetting(aKey: string, aValue: string) { |
|
|
public onChangeUserSetting(aKey: string, aValue: string) { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.putUserSetting({ [aKey]: aValue }) |
|
|
.putUserSetting({ [aKey]: aValue }) |
|
|