2017-07-28 14:54:29 +03:00
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
2017-04-18 19:12:29 +03:00
|
|
|
|
2017-08-01 17:42:21 +03:00
|
|
|
import { NbMenuService, NbSidebarService } from '@nebular/theme';
|
|
|
|
|
import { NbThemeService } from '@nebular/theme';
|
2017-07-13 11:49:38 +03:00
|
|
|
import { UserService } from '../../../@core/data/users.service';
|
2017-04-18 19:12:29 +03:00
|
|
|
|
|
|
|
|
@Component({
|
2017-05-06 14:52:41 +03:00
|
|
|
selector: 'ngx-header',
|
2017-04-28 15:14:05 +03:00
|
|
|
styleUrls: ['./header.component.scss'],
|
2017-04-18 19:12:29 +03:00
|
|
|
template: `
|
2017-07-28 14:54:29 +03:00
|
|
|
<div class="header-container" [class.left]="position === 'normal'" [class.right]="position === 'inverse'">
|
2017-07-20 18:13:11 +03:00
|
|
|
<a (click)="toggleSidebar()" href="#" class="navigation"><i class="ion-navicon"></i></a>
|
|
|
|
|
<div class="logo" (click)="goToHome()">NgX <span>Admin</span></div>
|
2017-06-07 14:14:57 +03:00
|
|
|
<div class="theme-buttons">
|
2017-06-13 16:16:52 +03:00
|
|
|
<button class="btn btn-hero-primary" (click)="selectCosmicTheme()">Cosmic</button>
|
|
|
|
|
<button class="btn btn-hero-info" (click)="selectDefaultTheme()">Default</button>
|
2017-06-07 14:14:57 +03:00
|
|
|
</div>
|
2017-04-18 19:12:29 +03:00
|
|
|
</div>
|
2017-05-11 15:05:04 +03:00
|
|
|
|
2017-08-01 17:42:21 +03:00
|
|
|
<nb-actions
|
2017-07-28 14:54:29 +03:00
|
|
|
size="medium"
|
|
|
|
|
class="header-container"
|
|
|
|
|
[class.right]="position === 'normal'"
|
|
|
|
|
[class.left]="position === 'inverse'">
|
2017-08-01 17:42:21 +03:00
|
|
|
<nb-action icon="ion-ios-gear-outline" (click)="toggleSettings()"></nb-action>
|
|
|
|
|
<nb-action>
|
|
|
|
|
<nb-user [menu]="userMenu" [name]="user?.name" [picture]="user?.picture"></nb-user>
|
|
|
|
|
</nb-action>
|
|
|
|
|
<nb-action disabled icon="ion-ios-bell-outline"></nb-action>
|
|
|
|
|
<nb-action icon="ion-ios-email-outline"></nb-action>
|
|
|
|
|
<nb-action>
|
|
|
|
|
<nb-search type="rotate-layout"></nb-search>
|
|
|
|
|
</nb-action>
|
|
|
|
|
</nb-actions>
|
2017-04-21 17:23:44 +03:00
|
|
|
`,
|
2017-04-18 19:12:29 +03:00
|
|
|
})
|
2017-07-13 18:34:57 +03:00
|
|
|
export class HeaderComponent implements OnInit {
|
2017-04-29 18:41:44 +03:00
|
|
|
|
2017-07-28 14:54:29 +03:00
|
|
|
|
|
|
|
|
@Input() position: string = 'normal';
|
|
|
|
|
|
2017-07-13 11:49:38 +03:00
|
|
|
user: any;
|
|
|
|
|
|
2017-04-29 18:41:44 +03:00
|
|
|
userMenu = [
|
|
|
|
|
{
|
|
|
|
|
title: 'Profile',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'Log out',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2017-08-01 17:42:21 +03:00
|
|
|
constructor(private sidebarService: NbSidebarService,
|
|
|
|
|
private menuService: NbMenuService,
|
|
|
|
|
private themeService: NbThemeService,
|
2017-07-13 11:49:38 +03:00
|
|
|
private userService: UserService) {
|
2017-07-13 18:34:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.userService.getUsers()
|
|
|
|
|
.subscribe((users: any) => this.user = users.nick);
|
2017-04-18 19:12:29 +03:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 17:34:10 +03:00
|
|
|
toggleSidebar(): boolean {
|
2017-07-28 14:54:29 +03:00
|
|
|
this.sidebarService.toggle(true, 'menu-sidebar');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toggleSettings(): boolean {
|
|
|
|
|
this.sidebarService.toggle(false, 'settings-sidebar');
|
2017-06-21 17:34:10 +03:00
|
|
|
return false;
|
2017-04-18 19:12:29 +03:00
|
|
|
}
|
2017-04-21 17:23:44 +03:00
|
|
|
|
|
|
|
|
goToHome() {
|
|
|
|
|
this.menuService.navigateHome();
|
|
|
|
|
}
|
2017-04-26 08:59:57 +03:00
|
|
|
|
2017-06-07 14:14:57 +03:00
|
|
|
selectCosmicTheme() {
|
|
|
|
|
this.themeService.changeTheme('cosmic');
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-11 15:05:04 +03:00
|
|
|
selectDefaultTheme() {
|
|
|
|
|
this.themeService.changeTheme('default');
|
|
|
|
|
}
|
2017-04-18 19:12:29 +03:00
|
|
|
}
|