Fixed load menu #70

This commit is contained in:
2022-10-16 13:09:26 +02:00
parent 1a3126dfc5
commit dbbd2b54c4
3 changed files with 10 additions and 13 deletions

View File

@@ -20,33 +20,32 @@ export class SidebarComponent implements OnInit {
private authService: AuthService,
private translateService: TranslateService,
private themeService: ThemeService
) { }
ngOnInit(): void {
) {
this.themeService.isSidebarOpen$.subscribe(value => {
this.isSidebarOpen = value;
this.setMenu();
});
this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.setMenu();
});
this.setMenu();
}
ngOnInit(): void {
this.themeService.loadMenu();
}
setMenu() {
this.authService.hasUserPermission(AuthRoles.Admin).then(hasPermission => {
this.menuItems = [];
this.menuItems = [
{ label: this.isSidebarOpen ? this.translateService.instant('sidebar.dashboard') : '', icon: 'pi pi-th-large', routerLink: 'dashboard' },
];
if (!hasPermission) {
return;
}
this.menuItems.push(
{ separator: true },
{ label: this.isSidebarOpen ? this.translateService.instant('sidebar.config') : '', icon: 'pi pi-cog', routerLink: '/admin/settings' },