ngx-admin/src/app/@theme/components/header/header.component.ts
maksim-karatkevich 07f430126f
feat: upgrade to angular9, upgrade to nebular 5.0, add material theme (#5694)
* chore: update README for extra theme (#5466)

* fix(tinymce): set absolute path for skin url (#5491)

* feat: add calendar with week numbers example (#5515)

* chore(readme): update bundles section text

* fix(forms): add missing forms module import (#5530)

* feat: update Nebular to 4.4.0 (#5533)

* chore(readme): update bundles image (#5565)

* chore: add bundles black friday deal (#5569)

* chore(readme): update black friday 2019 image (#5570)

* chore(readme): remove bundles discounts image (#5574)

* chore(readme): update bundles image (#5575)

* feat(seo): add canonical tag (#5578)

* chore(analytics): add proper analytics tracking URLs (#5604)

* feat: Material theme

* feat: upgrade to Angular 9 and Nebular 5 (#5628)

BREAKING CHANGE:
Angular updated to version 9.
Nebular updated to version 5.
`@agm/core` replaced with `@angular/google-maps`.
`ng2-completer` replaced with `@akveo/ng2-completer`, read details [here](https://github.com/akveo/ng2-smart-table/pull/1140#issue-392285957).

* Upgrade to the latest minor version of Angular

* Upgrade to the latest major version of Angular

* Upgrade to nebular 5 beta, remove "angular-tree-component" package

* Remove packages uncompatible with Ivy

* Fix post-upgrade errors

* Replace @agm/core with @angular/google-maps

* Fix search-map component using @angular/google-maps

* Move material theme files from @nebular

* Add missing images and change fg text color of dark material theme to bright white

* Implement ripple effect for material themes

* Add material style overrides

* Add ripple effects to controls across application

* Configure material theme, add material button and input examples

* Add toggle button example

* Fix lint warnings

* Add material menu icon for material themes

* Fix lint warnings for styles

* Set menu font-weight to normal for material themes

* Add "hover" and "active" styles for material menu

* Update material styles

* Override input styles for material themes

* Override select styles for material themes

* Hide rounded inputs for material themes

* Update material styles

* Remove non-material themes

* Revert "Remove non-material themes"

This reverts commit c2e319499f.

* Fix actions color

* Fix lint warnings

* Fix scrollbar for "traffic" card

* Fix scroll for "user activity" card

* Revert "Fix scroll for "user activity" card"

This reverts commit 4d793b1731.

* Revert "Fix scrollbar for "traffic" card"

This reverts commit b00da0d260.

* Fix scroll for nb-list inside nb-card

* chore(readme): add material theme description

* Remove unused angular2-toaster package

* chore(readme): add material theme images

* chore(readme): update text

* Upgrade to @nebular 5 release

* feat: update ng2-smart-table to 1.6

* chore(readme): add info about material theme branch

* fix: put Material theme in front of others

Otherwise Material theme style override Nebular

* refactor(material): remove options list border radius

* refactor: material input new look

* fix(form-inputs): show material inputs
* feat(material): change inputs style

* refactor: improve observable layout change sharing

* feat: add safe delayed event of layout change

* fix: replace change layout with safe change

* fix: limit front card width to prevent map overflow before repaint

* build: starter-kit clean up

* feat: upgrade to angular 9

Co-authored-by: David Henley <henleydr@gmail.com>
Co-authored-by: Sergey Andrievskiy <yggg@users.noreply.github.com>
Co-authored-by: Leon Lafayette <me@le0n.io>
Co-authored-by: Vladimir Lugovsky <lugovsky.v@gmail.com>
Co-authored-by: Sergey Andrievskiy <s.andrievskiy@akveo.com>
Co-authored-by: Evgeny Lupanov <elupanov@users.noreply.github.com>
Co-authored-by: eugene-sinitsyn <e.sinitsyn.s@akveo.com>
Co-authored-by: Evgeny Lupanov <e.lupanov@akveo.com>
Co-authored-by: sashaqred <sashaqred@ya.ru>
Co-authored-by: Dmitry Nehaychik <4dmitr@gmail.com>
Co-authored-by: Maksim Karatkevich <m.karatkevich@akveo.com>
2020-05-22 18:43:15 +03:00

115 lines
2.9 KiB
TypeScript

import { Component, OnDestroy, OnInit } from '@angular/core';
import { NbMediaBreakpointsService, NbMenuService, NbSidebarService, NbThemeService } from '@nebular/theme';
import { UserData } from '../../../@core/data/users';
import { LayoutService } from '../../../@core/utils';
import { map, takeUntil } from 'rxjs/operators';
import { Subject, Observable } from 'rxjs';
import { RippleService } from '../../../@core/utils/ripple.service';
@Component({
selector: 'ngx-header',
styleUrls: ['./header.component.scss'],
templateUrl: './header.component.html',
})
export class HeaderComponent implements OnInit, OnDestroy {
private destroy$: Subject<void> = new Subject<void>();
public readonly materialTheme$: Observable<boolean>;
userPictureOnly: boolean = false;
user: any;
themes = [
{
value: 'default',
name: 'Light',
},
{
value: 'dark',
name: 'Dark',
},
{
value: 'cosmic',
name: 'Cosmic',
},
{
value: 'corporate',
name: 'Corporate',
},
{
value: 'material-light',
name: 'Material Light',
},
{
value: 'material-dark',
name: 'Material Dark',
},
];
currentTheme = 'default';
userMenu = [ { title: 'Profile' }, { title: 'Log out' } ];
public constructor(
private sidebarService: NbSidebarService,
private menuService: NbMenuService,
private themeService: NbThemeService,
private userService: UserData,
private layoutService: LayoutService,
private breakpointService: NbMediaBreakpointsService,
private rippleService: RippleService,
) {
this.materialTheme$ = this.themeService.onThemeChange()
.pipe(map(theme => {
const themeName: string = theme?.name || '';
return themeName.startsWith('material');
}));
}
ngOnInit() {
this.currentTheme = this.themeService.currentTheme;
this.userService.getUsers()
.pipe(takeUntil(this.destroy$))
.subscribe((users: any) => this.user = users.nick);
const { xl } = this.breakpointService.getBreakpointsMap();
this.themeService.onMediaQueryChange()
.pipe(
map(([, currentBreakpoint]) => currentBreakpoint.width < xl),
takeUntil(this.destroy$),
)
.subscribe((isLessThanXl: boolean) => this.userPictureOnly = isLessThanXl);
this.themeService.onThemeChange()
.pipe(
map(({ name }) => name),
takeUntil(this.destroy$),
)
.subscribe(themeName => {
this.currentTheme = themeName;
this.rippleService.toggle(themeName?.startsWith('material'));
});
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
changeTheme(themeName: string) {
this.themeService.changeTheme(themeName);
}
toggleSidebar(): boolean {
this.sidebarService.toggle(true, 'menu-sidebar');
this.layoutService.changeLayoutSize();
return false;
}
navigateHome() {
this.menuService.navigateHome();
return false;
}
}