import { Component , OnDestroy , OnInit , Renderer2 } from '@angular/core' ; import { AuthService } from '../../../auth/services/auth.service' ; import { UserService } from '../../../management/services/user.service' ; import { User } from '../../../management/models/user' ; import { GroupService } from '../../../management/services/group.service' ; import { Group } from '../../../management/models/group' ; import { NgbModal } from '@ng-bootstrap/ng-bootstrap' ; import { FeedbackModalComponent } from '../../helpers/modals/feedback-modal/feedback-modal.component' ; @ Component ( { selector : 'cmdb-navigation' , templateUrl : './navigation.component.html' , styleUrls : [ './navigation.component.scss' ] } ) export class NavigationComponent implements OnInit , OnDestroy { public readonly title : string = 'DATAGERRY' ; public user : User ; public group : Group ; constructor ( private renderer , public authService , private userService , private groupService , private modalService ) { this . user = this . userService . getCurrentUser ( ) ; } public ngOnInit ( ) { this . groupService . getGroup ( this . user . group_id ) . subscribe ( resp => { this . group = resp ; } ) ; this . renderer . addClass ( document . body , 'header-fixed' ) ; this . dropdownSubmenu ( ) ; } public ngOnDestroy ( ) { this . renderer . removeClass ( document . body , 'header-fixed' ) ; } public logout ( ) { this . authService . logout ( ) ; } private dropdownSubmenu ( ) { $ ( '.dropdown-menu a.dropdown-toggle' ) . on ( 'click' , ( e ) => { if ( ! $ ( this ) . next ( ) . hasClass ( 'show' ) ) { $ ( this ) . parents ( '.dropdown-menu' ) . first ( ) . find ( '.show' ) . removeClass ( 'show' ) ; } const $subMenu = $ ( this ) . next ( '.dropdown-menu' ) ; $subMenu . toggleClass ( 'show' ) ; $ ( this ) . parents ( 'li.nav-item.dropdown.show' ) . on ( 'hidden.bs.dropdown' , ( ) => { $ ( '.dropdown-submenu .show' ) . removeClass ( 'show' ) ; } ) ; return false ; } ) ; } public visibilitySidebar ( ) { const sidebar = document . getElementById ( 'sidebar' ) . classList ; sidebar . length === 0 ? sidebar . add ( 'set-sidebar-visible' ) : sidebar . remove ( 'set-sidebar-visible' ) ; } public feedback ( ) { const modalComponent = this . modalService . open ( FeedbackModalComponent , { size : 'xl' } ) ; return modalComponent . result ; } }