diff --git a/kdb-web/package.json b/kdb-web/package.json index 0df95016..498f6a0f 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,6 +1,6 @@ { "name": "kdb-web", - "version": "0.3.dev78", + "version": "0.3.dev130", "scripts": { "ng": "ng", "update-version": "ts-node-esm update-version.ts", @@ -50,4 +50,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} \ No newline at end of file +} diff --git a/kdb-web/src/app/components/sidebar/sidebar.component.ts b/kdb-web/src/app/components/sidebar/sidebar.component.ts index 09eb593b..955bec11 100644 --- a/kdb-web/src/app/components/sidebar/sidebar.component.ts +++ b/kdb-web/src/app/components/sidebar/sidebar.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from "@angular/core"; -import { LangChangeEvent, TranslateService } from "@ngx-translate/core"; +import { TranslateService } from "@ngx-translate/core"; import { MenuItem } from "primeng/api"; import { AuthService } from "src/app/services/auth/auth.service"; import { ThemeService } from "src/app/services/theme/theme.service"; @@ -21,15 +21,6 @@ export class SidebarComponent implements OnInit { private themeService: ThemeService, private sidebar: SidebarService ) { - this.translateService.onLangChange.subscribe((event: LangChangeEvent) => { - this.sidebar.setMenu(); - }); - - this.themeService.isSidebarOpen$.subscribe(value => { - this.isSidebarOpen = value; - this.sidebar.setMenu(); - }); - this.sidebar.menuItems$.subscribe(value => { this.menuItems = value; }); diff --git a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts b/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts index 39f4f372..d4df31b8 100644 --- a/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts +++ b/kdb-web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.ts @@ -122,7 +122,7 @@ export class DashboardComponent implements OnInit { } selectServer(server: Server) { - this.sidebar.server$.next(server); + this.sidebar.setServer(server); this.router.navigate(["/server", server.id]); } diff --git a/kdb-web/src/app/modules/view/server/profile/profile.component.ts b/kdb-web/src/app/modules/view/server/profile/profile.component.ts index f366ee08..fe55ba14 100644 --- a/kdb-web/src/app/modules/view/server/profile/profile.component.ts +++ b/kdb-web/src/app/modules/view/server/profile/profile.component.ts @@ -38,7 +38,7 @@ export class ProfileComponent implements OnInit { return data.servers.length > 0 ? data.servers[0] : null; } ).subscribe(server => { - this.sidebar.server$.next(server); + this.sidebar.setServer(server); this.spinner.hideSpinner(); }); } diff --git a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts b/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts index fd923e09..d0e15616 100644 --- a/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts +++ b/kdb-web/src/app/modules/view/server/server-dashboard/server-dashboard.component.ts @@ -42,7 +42,7 @@ export class ServerDashboardComponent implements OnInit { } ).subscribe(server => { this.server = server; - this.sidebar.server$.next(server); + this.sidebar.setServer(server); this.spinner.hideSpinner(); }); } diff --git a/kdb-web/src/app/services/sidebar/sidebar.service.ts b/kdb-web/src/app/services/sidebar/sidebar.service.ts index 79ef2cb4..bc6691c6 100644 --- a/kdb-web/src/app/services/sidebar/sidebar.service.ts +++ b/kdb-web/src/app/services/sidebar/sidebar.service.ts @@ -29,8 +29,11 @@ export class SidebarService { this.setMenu(); }); + this.translateService.onLangChange.subscribe(_ => { + this.setMenu(); + }); - this.server$.subscribe(value => { + this.server$.subscribe(_ => { this.setMenu(); }); @@ -38,13 +41,18 @@ export class SidebarService { if (!(event instanceof NavigationEnd)) { return; } - - if (!event.url.startsWith('/server/')) { - this.server$.next(null); + if (!event.url.startsWith("/server/") && this.server$.value) { + this.setServer(null); } }); } + setServer(server: Server | null) { + if (server?.id != this.server$.value?.id) { + this.server$.next(server); + } + } + setMenu() { this.authService.hasUserPermission(AuthRoles.Admin).then(async hasPermission => { let menuItems: MenuItem[] = [ @@ -53,7 +61,8 @@ export class SidebarService { const serverMenu = { label: this.isSidebarOpen ? this.server$.value?.name : "", icon: "pi pi-server", items: [ - { label: this.isSidebarOpen ? this.translateService.instant("sidebar.profile") : "", icon: "pi pi-user", routerLink: `server/${this.server$.value?.id}/profile` }, + { label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.dashboard") : "", icon: "pi pi-th-large", routerLink: `server/${this.server$.value?.id}` }, + { label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.profile") : "", icon: "pi pi-user", routerLink: `server/${this.server$.value?.id}/profile` } // { label: this.isSidebarOpen ? this.translateService.instant("sidebar.members") : "", icon: "pi pi-users", routerLink: "server/members" } ] }; @@ -63,7 +72,7 @@ export class SidebarService { if (user?.isAdmin) { serverMenu.items.push( - { label: this.isSidebarOpen ? this.translateService.instant("sidebar.members") : "", icon: "pi pi-users", routerLink: `server/${this.server$.value?.id}/members` } + { label: this.isSidebarOpen ? this.translateService.instant("sidebar.server.members") : "", icon: "pi pi-users", routerLink: `server/${this.server$.value?.id}/members` } ); } diff --git a/kdb-web/src/assets/config.json b/kdb-web/src/assets/config.json index 87e33a65..7ffcfbef 100644 --- a/kdb-web/src/assets/config.json +++ b/kdb-web/src/assets/config.json @@ -3,7 +3,7 @@ "WebVersion": { "Major": "0", "Minor": "3", - "Micro": "dev78" + "Micro": "dev130" }, "Themes": [ { @@ -23,4 +23,4 @@ "Name": "sh-edraft-dark-theme" } ] -} \ No newline at end of file +} diff --git a/kdb-web/src/assets/i18n/de.json b/kdb-web/src/assets/i18n/de.json index 4e4e06b9..e03ba0b5 100644 --- a/kdb-web/src/assets/i18n/de.json +++ b/kdb-web/src/assets/i18n/de.json @@ -7,7 +7,11 @@ }, "sidebar": { "dashboard": "Dashboard", - "server": "Server", + "server": { + "dashboard": "Dashboard", + "profile": "Dein Profil", + "members": "Mitglieder" + }, "server_empty": "Kein Server ausgewählt", "members": "Mitglieder", "settings": "Einstellungen",