Implement canactivatechild also
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2020-05-06 14:13:10 +02:00
parent 24eef611d4
commit 62887e8089
2 changed files with 60 additions and 44 deletions

View File

@ -1,22 +1,30 @@
import { Injectable } from '@angular/core';
import { CanLoad, Route, CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import { Store } from '@ngrx/store';
import * as appCommonReducer from '../reducers/app-common.reducer'
import * as appCommonActions from '../actions/app-common.actions';
@Injectable({
providedIn: 'root',
})
export class FullScreenGuard implements CanActivate {
private loginDispatched = false;
constructor(private store: Store<appCommonReducer.State> ) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
this.store.dispatch(new appCommonActions.FullScreen());
return true;
}
}
import { Injectable } from '@angular/core';
import { CanActivate, CanActivateChild, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import { Store } from '@ngrx/store';
import * as appCommonReducer from '../reducers/app-common.reducer'
import * as appCommonActions from '../actions/app-common.actions';
@Injectable({
providedIn: 'root',
})
export class FullScreenGuard implements CanActivate,CanActivateChild {
private loginDispatched = false;
constructor(private store: Store<appCommonReducer.State> ) { }
setFullScreen():boolean {
this.store.dispatch(new appCommonActions.FullScreen());
return true;
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.setFullScreen();
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.setFullScreen();
}
}

View File

@ -1,22 +1,30 @@
import { Injectable } from '@angular/core';
import { CanLoad, Route, CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Store } from '@ngrx/store';
import * as appCommonReducer from '../reducers/app-common.reducer'
import * as appCommonActions from '../actions/app-common.actions';
@Injectable({
providedIn: 'root',
})
export class NavBarGuard implements CanActivate {
private loginDispatched = false;
constructor(private store: Store<appCommonReducer.State>) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
this.store.dispatch(new appCommonActions.ShowNavBar());
return true;
}
}
import { Injectable } from '@angular/core';
import { CanLoad, Route, CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Store } from '@ngrx/store';
import * as appCommonReducer from '../reducers/app-common.reducer'
import * as appCommonActions from '../actions/app-common.actions';
@Injectable({
providedIn: 'root',
})
export class NavBarGuard implements CanActivate {
private loginDispatched = false;
constructor(private store: Store<appCommonReducer.State>) { }
setNavBar():boolean {
this.store.dispatch(new appCommonActions.ShowNavBar());
return true;
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.setNavBar();
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.setNavBar();
}
}