Fixed load menu #70
This commit is contained in:
parent
1a3126dfc5
commit
dbbd2b54c4
@ -31,7 +31,6 @@ export class AppComponent implements OnInit {
|
|||||||
|
|
||||||
this.socket.startSocket();
|
this.socket.startSocket();
|
||||||
this.themeService.loadTheme();
|
this.themeService.loadTheme();
|
||||||
this.themeService.loadMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,33 +20,32 @@ export class SidebarComponent implements OnInit {
|
|||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private themeService: ThemeService
|
private themeService: ThemeService
|
||||||
) { }
|
) {
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.themeService.isSidebarOpen$.subscribe(value => {
|
this.themeService.isSidebarOpen$.subscribe(value => {
|
||||||
this.isSidebarOpen = value;
|
this.isSidebarOpen = value;
|
||||||
this.setMenu();
|
this.setMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||||
this.setMenu();
|
this.setMenu();
|
||||||
});
|
});
|
||||||
this.setMenu();
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.themeService.loadMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
setMenu() {
|
setMenu() {
|
||||||
|
|
||||||
this.authService.hasUserPermission(AuthRoles.Admin).then(hasPermission => {
|
this.authService.hasUserPermission(AuthRoles.Admin).then(hasPermission => {
|
||||||
this.menuItems = [];
|
this.menuItems = [];
|
||||||
this.menuItems = [
|
this.menuItems = [
|
||||||
{ label: this.isSidebarOpen ? this.translateService.instant('sidebar.dashboard') : '', icon: 'pi pi-th-large', routerLink: 'dashboard' },
|
{ label: this.isSidebarOpen ? this.translateService.instant('sidebar.dashboard') : '', icon: 'pi pi-th-large', routerLink: 'dashboard' },
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!hasPermission) {
|
if (!hasPermission) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.menuItems.push(
|
this.menuItems.push(
|
||||||
{ separator: true },
|
{ separator: true },
|
||||||
{ label: this.isSidebarOpen ? this.translateService.instant('sidebar.config') : '', icon: 'pi pi-cog', routerLink: '/admin/settings' },
|
{ label: this.isSidebarOpen ? this.translateService.instant('sidebar.config') : '', icon: 'pi pi-cog', routerLink: '/admin/settings' },
|
||||||
|
@ -27,13 +27,13 @@ export class ThemeService {
|
|||||||
});
|
});
|
||||||
this.isSidebarOpen$.subscribe(isSidebarOpen => {
|
this.isSidebarOpen$.subscribe(isSidebarOpen => {
|
||||||
this.isSidebarOpen = isSidebarOpen;
|
this.isSidebarOpen = isSidebarOpen;
|
||||||
|
this.sidebarWidth$.next(isSidebarOpen ? '150px' : '50px');
|
||||||
});
|
});
|
||||||
this.sidebarWidth$.subscribe(sidebarWidth => {
|
this.sidebarWidth$.subscribe(sidebarWidth => {
|
||||||
this.sidebarWidth = sidebarWidth;
|
this.sidebarWidth = sidebarWidth;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loadTheme();
|
this.loadTheme();
|
||||||
this.loadMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTheme(): void {
|
loadTheme(): void {
|
||||||
@ -87,7 +87,7 @@ export class ThemeService {
|
|||||||
let isMenuOpen = true;
|
let isMenuOpen = true;
|
||||||
let isMenuOpenStr = localStorage.getItem(`${mail}_isMenuOpen`);
|
let isMenuOpenStr = localStorage.getItem(`${mail}_isMenuOpen`);
|
||||||
if (isMenuOpenStr) {
|
if (isMenuOpenStr) {
|
||||||
isMenuOpen = Boolean(isMenuOpenStr);
|
isMenuOpen = JSON.parse(isMenuOpenStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setIsMenuOpen(isMenuOpen);
|
this.setIsMenuOpen(isMenuOpen);
|
||||||
@ -107,7 +107,6 @@ export class ThemeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSideWidth(isSidebarOpen: boolean): void {
|
setSideWidth(isSidebarOpen: boolean): void {
|
||||||
this.sidebarWidth$.next(isSidebarOpen ? '150px' : '50px');
|
|
||||||
this.isSidebarOpen$.next(isSidebarOpen);
|
this.isSidebarOpen$.next(isSidebarOpen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user