AW-3128 Taalinstellingen profiel gebruiken voor FarmMaps ipv browser instelling
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
5c8fd64521
commit
4c106ebff3
@ -83,6 +83,8 @@ export const SETPAGEMODE = '[AppCommon] SetPageMode';
|
||||
|
||||
export const SETUNREADNOTIFICATIONS = '[AppCommon] SetUnreadNotifications';
|
||||
|
||||
export const SWITCHLANGUAGE = '[AppCommon] SwitchLanguage';
|
||||
|
||||
export class InitUser implements Action {
|
||||
readonly type = INITUSER;
|
||||
|
||||
@ -371,6 +373,12 @@ export class SetUnreadNotifications implements Action {
|
||||
|
||||
}
|
||||
|
||||
export class SwitchLanguage implements Action {
|
||||
readonly type = SWITCHLANGUAGE;
|
||||
|
||||
constructor(public locale:string) { }
|
||||
}
|
||||
|
||||
|
||||
export type Actions = OpenModal
|
||||
| InitRoot
|
||||
@ -418,6 +426,7 @@ export type Actions = OpenModal
|
||||
| ToggleHelpMenu
|
||||
| ToggleSettingMenu
|
||||
| NotificationEvent
|
||||
| SetUnreadNotifications;
|
||||
| SetUnreadNotifications
|
||||
| SwitchLanguage;
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, Inject, LOCALE_ID } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { OAuthService,UserInfo } from 'angular-oauth2-oidc';
|
||||
import { Store } from '@ngrx/store';
|
||||
@ -16,6 +16,7 @@ import {StateSerializerService} from '../services/state-serializer.service';
|
||||
|
||||
@Injectable()
|
||||
export class AppCommonEffects {
|
||||
locale: string;
|
||||
|
||||
login$ = createEffect(() => this.actions$.pipe(
|
||||
ofType(appCommonActions.LOGIN),
|
||||
@ -47,11 +48,24 @@ export class AppCommonEffects {
|
||||
first(),
|
||||
switchMap((action) => {
|
||||
return zip(this.userService$.getCurrentUser(),from(this.oauthService$.loadUserProfile())).pipe(
|
||||
switchMap(([user,userInfo]) => {return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))} ),
|
||||
switchMap(([user,userInfo]) => {
|
||||
if (location.hostname === 'localhost' || user.language === undefined || user.language === this.locale)
|
||||
{
|
||||
return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))
|
||||
}
|
||||
return of(new appCommonActions.SwitchLanguage(user.language))
|
||||
}),
|
||||
catchError(error => of(new appCommonActions.Fail(error))))
|
||||
}
|
||||
)));
|
||||
|
||||
switchLanguage$ = createEffect(() => this.actions$.pipe(
|
||||
ofType(appCommonActions.SWITCHLANGUAGE),
|
||||
switchMap((action) => {
|
||||
const a = action as appCommonActions.SwitchLanguage;
|
||||
location.replace(`/${a.locale}/`);
|
||||
return of(undefined);
|
||||
})),{ dispatch:false});
|
||||
|
||||
initUserPackages$ = createEffect(() => this.actions$.pipe(
|
||||
ofType(appCommonActions.INITUSERPACKAGES),
|
||||
@ -208,7 +222,12 @@ export class AppCommonEffects {
|
||||
|
||||
|
||||
|
||||
constructor(private actions$: Actions, private store$: Store<appCommonReducers.State>, private oauthService$: OAuthService, private itemService$: ItemService, private folderService$:FolderService, private userService$: UserService, private router$: Router, private stateSerializerService$:StateSerializerService) {
|
||||
constructor(private actions$: Actions, private store$: Store<appCommonReducers.State>, private oauthService$: OAuthService, private itemService$: ItemService, private folderService$:FolderService, private userService$: UserService, private router$: Router, private stateSerializerService$:StateSerializerService, @Inject(LOCALE_ID) locale: string) {
|
||||
this.locale = locale;
|
||||
store$.dispatch(new appCommonActions.LoadItemTypes());
|
||||
}
|
||||
}
|
||||
function tap(arg0: () => any): any {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user