in all in one
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { AuthenticationService } from '../user-services';
|
||||
import { Subscription } from 'rxjs'
|
||||
import { Component, EventEmitter, Output, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Utils } from '../shares';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-toolbar',
|
||||
templateUrl: './nav-toolbar.component.html',
|
||||
styleUrls: ['./nav-toolbar.component.css']
|
||||
})
|
||||
export class NavToolarComponent implements OnInit, OnDestroy {
|
||||
isExpanded = false;
|
||||
isAuth = false;
|
||||
isAdmin = false;
|
||||
currentUserName = "";
|
||||
authSubscription: Subscription = new Subscription;
|
||||
@Output() toggleEvent: EventEmitter<boolean> = new EventEmitter();
|
||||
constructor(private authService: AuthenticationService,
|
||||
private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.authSubscription = this.authService.authChange.subscribe(currentUser => {
|
||||
this.isAuth = Utils.getIsAuth();
|
||||
this.isAdmin = Utils.getIsAdmin();
|
||||
this.currentUserName = currentUser;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.authSubscription) {
|
||||
this.authSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
onHome() {
|
||||
this.router.navigate(['/home/concessionvalidation']);
|
||||
}
|
||||
onToggle() {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
this.toggleEvent.emit(this.isExpanded);
|
||||
}
|
||||
onLogout() {
|
||||
this.authService.logout();
|
||||
this.router.navigate(['/login']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user