import {Component,Input,OnInit,OnChanges} from '@angular/core';
import { ContentComponent } from '../../content/content.component';
import { Router, ActivatedRoute, Params ,NavigationEnd} from '@angular/router';
import { LoginService } from '../../main_modules/login-module/services/login.service';

@Component({
    selector:'navbar',
    templateUrl:'./navbar.component.html',
    styleUrls:['./navbar.component.css'],
    
})

export class NavbarComponent implements OnInit,OnChanges{
@Input()
enavLink
nav="nav";
sideNavState=1;  
viewStateLabel="Login Panel"
user;
constructor( private route: ActivatedRoute,private router:Router,private loginService:LoginService){
      
       router.events.subscribe(event => {
      if(event instanceof NavigationEnd) {
          var url =this.router.routerState.snapshot.url.split('/');
          var lenght = url.length;
     this.viewStateLabel=url[lenght-1];
        //console.log(this.router.routerState);
       
      }
    });
     
}
ngOnInit(){
    this.user=this.loginService.getLoggedUser();
    //this.viewStateLabel=this.router.routerState.snapshot.url
}

toggleSideNav():void{

      this.enavLink[0].toggle();
      
}


():void{

      this.enavLink[1].toggle();
      
}

navigate(){
    this.loginService.logOut().subscribe(res=>{
        if(res=="ok"){
           location.reload();
    
           this.router.navigate(['/login']);
        }
    });
   // this.router.navigate(['/login'])
}
ngOnChanges(){
    //this.viewStateLabel=this.router.routerState.snapshot.url;
}

}


toggleNotificationBar