27 lines
908 B
TypeScript
27 lines
908 B
TypeScript
|
import {Injectable} from '@angular/core';
|
||
|
import {ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot, UrlSegment, UrlTree} from '@angular/router';
|
||
|
import {Observable} from 'rxjs';
|
||
|
|
||
|
import {properties} from "../../../environments/environment";
|
||
|
|
||
|
@Injectable()
|
||
|
export class isDevelopmentGuard implements CanActivate, CanLoad {
|
||
|
constructor(private router: Router) {
|
||
|
}
|
||
|
|
||
|
check(): Observable<boolean> | boolean {
|
||
|
if(properties.environment == 'development') {
|
||
|
return true;
|
||
|
} else {
|
||
|
this.router.navigate([properties.errorLink]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree{
|
||
|
return this.check();
|
||
|
}
|
||
|
|
||
|
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||
|
return this.check()
|
||
|
}
|
||
|
}
|