Thomas Kaul
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
22 additions and
6 deletions
-
apps/api/src/app/user/update-user-setting.dto.ts
-
apps/client/src/app/core/auth.guard.ts
-
apps/client/src/app/pages/account/account-page.component.ts
-
apps/client/src/app/pages/account/account-page.html
-
libs/common/src/lib/interfaces/user-settings.interface.ts
|
|
@ -9,6 +9,10 @@ export class UpdateUserSettingDto { |
|
|
|
@IsOptional() |
|
|
|
isRestrictedView?: boolean; |
|
|
|
|
|
|
|
@IsString() |
|
|
|
@IsOptional() |
|
|
|
language?: string; |
|
|
|
|
|
|
|
@IsString() |
|
|
|
@IsOptional() |
|
|
|
locale?: string; |
|
|
|
|
|
@ -72,7 +72,13 @@ export class AuthGuard implements CanActivate { |
|
|
|
}) |
|
|
|
) |
|
|
|
.subscribe((user) => { |
|
|
|
if ( |
|
|
|
const userLanguage = user?.settings?.language; |
|
|
|
|
|
|
|
if (userLanguage && document.documentElement.lang !== userLanguage) { |
|
|
|
window.location.href = `../${userLanguage}`; |
|
|
|
resolve(false); |
|
|
|
return; |
|
|
|
} else if ( |
|
|
|
state.url.startsWith('/home') && |
|
|
|
user.settings.viewMode === ViewMode.ZEN |
|
|
|
) { |
|
|
|
|
|
@ -149,10 +149,6 @@ export class AccountPageComponent implements OnDestroy, OnInit { |
|
|
|
this.update(); |
|
|
|
} |
|
|
|
|
|
|
|
public onChangeLanguage(aLanguage: string) { |
|
|
|
window.location.href = `../${aLanguage}/account`; |
|
|
|
} |
|
|
|
|
|
|
|
public onChangeUserSetting(aKey: string, aValue: string) { |
|
|
|
this.dataService |
|
|
|
.putUserSetting({ [aKey]: aValue }) |
|
|
@ -167,6 +163,14 @@ export class AccountPageComponent implements OnDestroy, OnInit { |
|
|
|
this.user = user; |
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
|
|
|
|
if (aKey === 'language') { |
|
|
|
if (aValue) { |
|
|
|
window.location.href = `../${aValue}/account`; |
|
|
|
} else { |
|
|
|
window.location.href = `../`; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
@ -120,8 +120,9 @@ |
|
|
|
<mat-select |
|
|
|
name="language" |
|
|
|
[value]="language" |
|
|
|
(selectionChange)="onChangeLanguage($event.value)" |
|
|
|
(selectionChange)="onChangeUserSetting('language', $event.value)" |
|
|
|
> |
|
|
|
<mat-option [value]="null"></mat-option> |
|
|
|
<mat-option value="de">Deutsch</mat-option> |
|
|
|
<mat-option value="en">English</mat-option> |
|
|
|
</mat-select> |
|
|
|
|
|
@ -3,6 +3,7 @@ import { ViewMode } from '@prisma/client'; |
|
|
|
export interface UserSettings { |
|
|
|
baseCurrency?: string; |
|
|
|
isRestrictedView?: boolean; |
|
|
|
language?: string; |
|
|
|
locale: string; |
|
|
|
viewMode?: ViewMode; |
|
|
|
} |
|
|
|