Consider language from user settings (#1179)
This commit is contained in:
@ -9,6 +9,10 @@ export class UpdateUserSettingDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
isRestrictedView?: boolean;
|
isRestrictedView?: boolean;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
language?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
locale?: string;
|
locale?: string;
|
||||||
|
@ -72,7 +72,13 @@ export class AuthGuard implements CanActivate {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe((user) => {
|
.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') &&
|
state.url.startsWith('/home') &&
|
||||||
user.settings.viewMode === ViewMode.ZEN
|
user.settings.viewMode === ViewMode.ZEN
|
||||||
) {
|
) {
|
||||||
|
@ -149,10 +149,6 @@ export class AccountPageComponent implements OnDestroy, OnInit {
|
|||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onChangeLanguage(aLanguage: string) {
|
|
||||||
window.location.href = `../${aLanguage}/account`;
|
|
||||||
}
|
|
||||||
|
|
||||||
public onChangeUserSetting(aKey: string, aValue: string) {
|
public onChangeUserSetting(aKey: string, aValue: string) {
|
||||||
this.dataService
|
this.dataService
|
||||||
.putUserSetting({ [aKey]: aValue })
|
.putUserSetting({ [aKey]: aValue })
|
||||||
@ -167,6 +163,14 @@ export class AccountPageComponent implements OnDestroy, OnInit {
|
|||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
|
|
||||||
|
if (aKey === 'language') {
|
||||||
|
if (aValue) {
|
||||||
|
window.location.href = `../${aValue}/account`;
|
||||||
|
} else {
|
||||||
|
window.location.href = `../`;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -120,8 +120,9 @@
|
|||||||
<mat-select
|
<mat-select
|
||||||
name="language"
|
name="language"
|
||||||
[value]="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="de">Deutsch</mat-option>
|
||||||
<mat-option value="en">English</mat-option>
|
<mat-option value="en">English</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
|
@ -3,6 +3,7 @@ import { ViewMode } from '@prisma/client';
|
|||||||
export interface UserSettings {
|
export interface UserSettings {
|
||||||
baseCurrency?: string;
|
baseCurrency?: string;
|
||||||
isRestrictedView?: boolean;
|
isRestrictedView?: boolean;
|
||||||
|
language?: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
viewMode?: ViewMode;
|
viewMode?: ViewMode;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user