multi-project/projects/app/_modules/layout/header/header.component.ts

59 lines
1.6 KiB
TypeScript

import {Component} from '@angular/core';
import {AuthenticationService, ListsService} from "@app/_services";
import {Subscription} from "rxjs";
import { Router } from '@angular/router';
import { html } from '@environments/htmlenv';
@Component({
selector: 'header',
templateUrl: html.header||'header.component.html',
styleUrls: ['header.component.scss']
})
export class HeaderComponent {
public user: any;
public loading: boolean = false;
subscription: Subscription;
showMobileMenu = false;
constructor(
private router:Router,
public authenticationService: AuthenticationService,
private listsService: ListsService) {
this.subscription = this.authenticationService.user.subscribe(user => {
this.user = user;
});
}
ngOnInit() {
let showSettingSite = localStorage.getItem('showSettingSite');
if (showSettingSite === null || showSettingSite === 'no') {
localStorage.setItem('showSettingSite', 'no');
this.listsService.result('showSettingSite').next(false);
}
}
ngOnDestroy() {
this.subscription?.unsubscribe();
}
openMobileMenu(){
this.router.navigate([{outlets: {slider: 'pages-menu'}}], {skipLocationChange: true}).then();
}
settingsSite() {
let showSettingSite = localStorage.getItem('showSettingSite');
showSettingSite = showSettingSite === 'yes' ? 'no' : 'yes';
localStorage.setItem('showSettingSite', showSettingSite);
this.listsService.result('showSettingSite').next(showSettingSite==='yes');
}
login() {
this.authenticationService.popup('login');
}
toggle(){
this.showMobileMenu = !this.showMobileMenu;
}
}