diff --git a/projects/common/src/fm/components/app/app.component.ts b/projects/common/src/fm/components/app/app.component.ts index 8dd79a5..835c852 100644 --- a/projects/common/src/fm/components/app/app.component.ts +++ b/projects/common/src/fm/components/app/app.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, OnDestroy, Inject, Optional,ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core'; +import { Component, OnInit, OnDestroy, Inject, Optional, ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core'; import { Router, NavigationStart, NavigationEnd, RouteConfigLoadStart, RouteConfigLoadEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router'; import { Meta, Title, MetaDefinition } from '@angular/platform-browser'; import { DOCUMENT } from "@angular/common"; import { Subscription, Observable } from 'rxjs'; @@ -6,7 +6,7 @@ import { distinctUntilChanged } from 'rxjs/operators'; import { Store, Action } from '@ngrx/store'; import { IUser } from '../../models/user'; import { OAuthService, OAuthErrorEvent } from 'angular-oauth2-oidc'; -import { FM_COMMON_STARTPAGE} from '../../common.module'; +import { FM_COMMON_STARTPAGE } from '../../common.module'; //AppCommon import { IEventMessage } from '../../models/event.message'; @@ -48,7 +48,7 @@ export class AppComponent implements OnInit, OnDestroy { public helpMenuVisible: Observable = this.store$.select(appReducers.SelectGetHelpMenuVisible); public unreadNotifications: Observable = this.store$.select(appReducers.SelectgetUnreadNotifications); public user: Observable = this.store$.select(appReducers.SelectGetUser); - public isPageMode: Observable = this.store$.select(appReducers.SelectGetIsPageMode); + public isPageMode: Observable = this.store$.select(appReducers.SelectGetIsPageMode); @Input() showUploadProgress = true; constructor( @@ -106,17 +106,17 @@ export class AppComponent implements OnInit, OnDestroy { case "notification": { action = new commonActions.NotificationEvent(event.attributes); break; - } + } case "DeleteUser": { action = new commonActions.Logout(); break; - } + } } return action; } async loadItemTypes() { - await this.itemTypeService$.load(this.appConfig$) + await this.itemTypeService$.load(this.appConfig$) } ngOnInit() { @@ -155,14 +155,15 @@ export class AppComponent implements OnInit, OnDestroy { this.router.navigate(['loggedout'], { queryParams: { redirectTo: this.router.url } }); } } - if(event.type == 'token_received') { + if (event.type == 'token_received') { + this.oauthService$.loadUserProfile(); this.store$.dispatch(new commonActions.InitUser()); } }); - if(this.oauthService$.hasValidAccessToken()) { - this.store$.dispatch(new commonActions.InitUser()); + if (this.oauthService$.hasValidAccessToken()) { + this.store$.dispatch(new commonActions.InitUser()); } else { - if(this.oauthService$.getRefreshToken() !=null) { + if (this.oauthService$.getRefreshToken() != null) { this.oauthService$.refreshToken(); } } @@ -174,7 +175,7 @@ export class AppComponent implements OnInit, OnDestroy { if (event instanceof RouteConfigLoadStart) { other.store$.dispatch(new commonActions.StartRouteLoading()); } - if (event instanceof NavigationEnd && (event.url == "/" || event.url.startsWith("/content") )) { + if (event instanceof NavigationEnd && (event.url == "/" || event.url.startsWith("/content"))) { other.store$.dispatch(new commonActions.SetPageMode(true)); } else if (event instanceof NavigationEnd) { other.store$.dispatch(new commonActions.SetPageMode(false)); @@ -197,8 +198,8 @@ export class AppComponent implements OnInit, OnDestroy { } private InstallHealthCheck() { - //check health every 30 seconds - this.healthCheckService$.check(30000).pipe(distinctUntilChanged()).subscribe((online) => { + //check health every 30 seconds + this.healthCheckService$.check(30000).pipe(distinctUntilChanged()).subscribe((online) => { if (online) { this.store$.dispatch(new commonActions.Online()); } else {