import { Component , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap' ; import { JhiLanguageService } from 'ng-jhipster' ; import { SessionStorageService } from 'ngx-webstorage' ; import { VERSION } from 'app/app.constants' ; import { JhiLanguageHelper , AccountService , LoginModalService , LoginService } from 'app/core' ; import { ProfileService } from 'app/layouts/profiles/profile.service' ; @ Component ( { selector : 'jhi-navbar' , templateUrl : './navbar.component.html' , styleUrls : [ 'navbar.scss' ] } ) export class NavbarComponent implements OnInit { inProduction : boolean ; isNavbarCollapsed : boolean ; languages : any [ ] ; swaggerEnabled : boolean ; modalRef : NgbModalRef ; version : string ; constructor ( private loginService , private languageService , private languageHelper , private sessionStorage , private accountService , private loginModalService , private profileService , private router ) { this . version = VERSION ? 'v' + VERSION : '' ; this . isNavbarCollapsed = true ; } ngOnInit ( ) { this . languageHelper . getAll ( ) . then ( languages => { this . languages = languages ; } ) ; this . profileService . getProfileInfo ( ) . then ( profileInfo => { this . inProduction = profileInfo . inProduction ; this . swaggerEnabled = profileInfo . swaggerEnabled ; } ) ; } changeLanguage ( languageKey ) { this . sessionStorage . store ( 'locale' , languageKey ) ; this . languageService . changeLanguage ( languageKey ) ; } collapseNavbar ( ) { this . isNavbarCollapsed = true ; } isAuthenticated ( ) { return this . accountService . isAuthenticated ( ) ; } login ( ) { this . modalRef = this . loginModalService . open ( ) ; } logout ( ) { this . collapseNavbar ( ) ; this . loginService . logout ( ) ; this . router . navigate ( [ '' ] ) ; } toggleNavbar ( ) { this . isNavbarCollapsed = ! this . isNavbarCollapsed ; } getImageUrl ( ) { return this . isAuthenticated ( ) ? this . accountService . getImageUrl ( ) : null ; } }