in all in one
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { Component, EventEmitter, Output, OnInit, OnDestroy } from '@angular/core';
|
||||
import { AuthenticationService } from '../user-services';
|
||||
import { Subscription } from 'rxjs'
|
||||
import { Router } from '@angular/router';
|
||||
import { Utils } from '../shares';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-menu',
|
||||
templateUrl: './nav-menu.component.html',
|
||||
styleUrls: ['./nav-menu.component.css']
|
||||
})
|
||||
export class NavMenuComponent implements OnInit, OnDestroy{
|
||||
|
||||
isAuth = false;
|
||||
isAdmin = false;
|
||||
panelOpenState = false;
|
||||
authSubscription!: Subscription;
|
||||
@Output() closeMe: 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();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.authSubscription) {
|
||||
this.authSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
collapse() {
|
||||
this.closeMe.emit(true);
|
||||
}
|
||||
|
||||
onLogout() {
|
||||
console.log("onlogout click");
|
||||
this.collapse();
|
||||
this.authService.logout();
|
||||
// this.router.navigate(['/login']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user