moved to single project
This commit is contained in:
38
ui/hv2-ui/src/app/navigation/navigation.component.ts
Normal file
38
ui/hv2-ui/src/app/navigation/navigation.component.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, shareReplay } from 'rxjs/operators';
|
||||
import { TokenService } from '../token.service';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-navigation',
|
||||
templateUrl: './navigation.component.html',
|
||||
styleUrls: ['./navigation.component.css']
|
||||
})
|
||||
export class NavigationComponent {
|
||||
|
||||
public authenticated: boolean
|
||||
|
||||
isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
|
||||
.pipe(
|
||||
map(result => result.matches),
|
||||
shareReplay()
|
||||
);
|
||||
|
||||
constructor(
|
||||
private breakpointObserver: BreakpointObserver,
|
||||
private tokenService: TokenService,
|
||||
private router: Router) {
|
||||
this.router.events.subscribe((e: any) => {
|
||||
if (e instanceof NavigationEnd) {
|
||||
this.authenticated = this.tokenService.checkAuthenticated()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.authenticated = this.tokenService.checkAuthenticated()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user