fuse-angular/src/app/main/navbar/navbar.component.ts
Sercan Yemen 3dfb79423a Changed how navigation data passed into the fuse-navigation
+ Added hidden property to the nav items
+ Updated fuse-navigation component docs
+ Updated other components that uses fuse-navigation service
+ Updated various packages including Angular and Angular Material
2018-02-20 11:05:07 +03:00

59 lines
1.8 KiB
TypeScript

import { Component, Input, OnDestroy, ViewChild, ViewEncapsulation } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { FusePerfectScrollbarDirective } from '@fuse/directives/fuse-perfect-scrollbar/fuse-perfect-scrollbar.directive';
import { FuseSidebarService } from '@fuse/components/sidebar/sidebar.service';
import { navigation } from 'app/navigation/navigation';
import { FuseNavigationService } from '@fuse/components/navigation/navigation.service';
@Component({
selector : 'fuse-navbar',
templateUrl : './navbar.component.html',
styleUrls : ['./navbar.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class FuseNavbarComponent implements OnDestroy
{
@ViewChild(FusePerfectScrollbarDirective) fusePerfectScrollbarDirective;
@Input() layout;
navigation: any;
navigationServiceWatcher: Subscription;
fusePerfectScrollbarUpdateTimeout;
constructor(
private sidebarService: FuseSidebarService,
private navigationService: FuseNavigationService
)
{
// Navigation data
this.navigation = navigation;
// Default layout
this.layout = 'vertical';
this.navigationServiceWatcher =
this.navigationService.onItemCollapseToggled.subscribe(() => {
this.fusePerfectScrollbarUpdateTimeout = setTimeout(() => {
this.fusePerfectScrollbarDirective.update();
}, 310);
});
}
ngOnDestroy()
{
clearTimeout(this.fusePerfectScrollbarUpdateTimeout);
this.navigationServiceWatcher.unsubscribe();
}
toggleSidebarOpened(key)
{
this.sidebarService.getSidebar(key).toggleOpen();
}
toggleSidebarFolded(key)
{
this.sidebarService.getSidebar(key).toggleFold();
}
}