Newer
Older
import {AfterViewChecked, Component, ElementRef, OnChanges, OnInit, ViewChild} from '@angular/core';
import {Router} from '@angular/router';
import {NgbModalRef} from '@ng-bootstrap/ng-bootstrap';
import {ProfileService} from '../profiles/profile.service';
import {Principal, LoginService} from '../../shared';
import {SeparationComponent} from '../../system/modal/separation/separation.component';
import {BasicEditComponent} from '../../modal/basic-edit/basic-edit.component';
import {CreateGroupComponent} from '../../modal/create-group/create-group.component';
import {ModifyPasswordComponent} from '../../modal/modify-password/modify-password.component';
import {CommonService} from '../../shared/common/common.service';
@Component({
selector: 'jhi-navbar',
templateUrl: './navbar.component.html',
styleUrls: [
'navbar.css'
]
})
export class NavbarComponent implements OnInit, AfterViewChecked {
@ViewChild('parent') parent: ElementRef;
@ViewChild('children') children: ElementRef;
@ViewChild('smartSeparation') smartSeparation: SeparationComponent;
@ViewChild('basicEdit') basicEdit: BasicEditComponent;
@ViewChild('smartCreateGroup') smartCreateGroup: CreateGroupComponent;
@ViewChild('smartModifyPassword') smartModifyPassword: ModifyPasswordComponent;
inProduction: boolean;
isNavbarCollapsed: boolean;
languages: any[];
swaggerEnabled: boolean;
modalRef: NgbModalRef;
version: string;
token: boolean;
constructor(
private loginService: LoginService,
private principal: Principal,
private commonSer: CommonService,
private overAll: OverAllService,
private appSer: AppService,
private $localStorage: LocalStorageService,
private systemSer: SystemService,
) {
this.version = VERSION ? 'v' + VERSION : '';
this.isNavbarCollapsed = true;
}
ngOnInit() {
collapseNavbar() {
this.isNavbarCollapsed = true;
}
isAuthenticated() {
return this.principal.isAuthenticated();
}
logout() {
this.commonSer.confirmThing('退出', '确定退出?', () => {
this.collapseNavbar();
this.loginService.logout();
});
}
toggleNavbar() {
this.isNavbarCollapsed = !this.isNavbarCollapsed;
}
getImageUrl() {
return this.isAuthenticated() ? this.principal.getImageUrl() : null;
}
this.children.nativeElement.style.marginLeft = '0px';
this.isBool = true;
} else {
this.children.nativeElement.style.marginLeft = '-300px';
//添加资源 ,name-分组名称,id-分组id
showBasicEditModal() {
this.basicEdit.showModal();
}
//添加分组
showGroupModal() {
this.smartCreateGroup.showModal('添加分组');
}
changeTheme(item) {
this.themeLabel = item.label;
this.appSer.setTheme(item.value);