diff --git a/ui-ngx/src/app/core/services/breadcrumb.service.ts b/ui-ngx/src/app/core/services/breadcrumb.service.ts index 97e8e62522..bafa4979a1 100644 --- a/ui-ngx/src/app/core/services/breadcrumb.service.ts +++ b/ui-ngx/src/app/core/services/breadcrumb.service.ts @@ -24,6 +24,9 @@ import { distinctUntilChanged, filter, first, map, switchMap } from 'rxjs/operat import { MenuSection, menuSectionMap } from '@core/services/menu.models'; import { guid } from '@core/utils'; import { ActiveComponentService } from '@core/services/active-component.service'; +import { Store } from '@ngrx/store'; +import { AppState } from '@core/core.state'; +import { getCurrentAuthUser } from '@core/auth/auth.selectors'; @Injectable({ providedIn: 'root' @@ -45,6 +48,7 @@ export class BreadcrumbService { } constructor(private router: Router, + private store: Store, private activatedRoute: ActivatedRoute, private translate: TranslateService, private menuService: MenuService, @@ -90,10 +94,15 @@ export class BreadcrumbService { if (breadcrumbConfig && !breadcrumbConfig.skip) { let labelFunction: () => string; let section: MenuSection = null; - if (breadcrumbConfig.menuId) { - section = availableMenuSections.find(menu => menu.id === breadcrumbConfig.menuId); + let menuId = breadcrumbConfig.menuId; + if (!menuId && breadcrumbConfig.menuIdByAuthority) { + const authority = getCurrentAuthUser(this.store).authority; + menuId = breadcrumbConfig.menuIdByAuthority[authority]; + } + if (menuId) { + section = availableMenuSections.find(menu => menu.id === menuId); if (!section) { - section = menuSectionMap.get(breadcrumbConfig.menuId); + section = menuSectionMap.get(menuId); } } const label = section?.name || breadcrumbConfig.label || 'home.home'; diff --git a/ui-ngx/src/app/core/services/menu.models.ts b/ui-ngx/src/app/core/services/menu.models.ts index 1b3efa8e50..3be6ceef0c 100644 --- a/ui-ngx/src/app/core/services/menu.models.ts +++ b/ui-ngx/src/app/core/services/menu.models.ts @@ -73,6 +73,7 @@ export enum MenuId { mobile_bundles = 'mobile_bundles', mobile_qr_code_widget = 'mobile_qr_code_widget', platform = 'platform', + platform_section = 'platform_section', settings = 'settings', general = 'general', mail_server = 'mail_server', @@ -101,7 +102,9 @@ export enum MenuId { profiles = 'profiles', device_profiles = 'device_profiles', asset_profiles = 'asset_profiles', + customers_and_users = 'customers_and_users', customers = 'customers', + data_processing = 'data_processing', calculated_fields = 'calculated_fields', rule_chains = 'rule_chains', edge_management = 'edge_management', @@ -367,6 +370,16 @@ export const menuSectionMap = new Map([ icon: 'miscellaneous_services' } ], + [ + MenuId.platform_section, + { + id: MenuId.platform_section, + name: 'admin.platform', + type: 'toggle', + path: '/platform', + icon: 'miscellaneous_services' + } + ], [ MenuId.settings, { @@ -577,10 +590,10 @@ export const menuSectionMap = new Map([ MenuId.entities, { id: MenuId.entities, - name: 'entity.entities', + name: 'entity.devices-and-assets', type: 'toggle', path: '/entities', - icon: 'category' + icon: 'mdi:shape-outline' } ], [ @@ -653,6 +666,16 @@ export const menuSectionMap = new Map([ icon: 'mdi:alpha-a-box' } ], + [ + MenuId.customers_and_users, + { + id: MenuId.customers_and_users, + name: 'customer.customers-and-users', + type: 'link', + path: '/customers', + icon: 'mdi:account-multiple-outline' + } + ], [ MenuId.customers, { @@ -663,6 +686,16 @@ export const menuSectionMap = new Map([ icon: 'supervisor_account' } ], + [ + MenuId.data_processing, + { + id: MenuId.data_processing, + name: 'entity.data-processing', + type: 'toggle', + path: '/dataProcessing', + icon: 'settings_ethernet', + } + ], [ MenuId.calculated_fields, { @@ -763,7 +796,7 @@ export const menuSectionMap = new Map([ name: 'api-usage.api-usage', type: 'link', path: '/usage', - icon: 'insert_chart' + icon: 'insert_chart_outlined' } ], [ @@ -917,33 +950,20 @@ const defaultUserMenuMap = new Map([ id: MenuId.entities, pages: [ {id: MenuId.devices}, + {id: MenuId.gateways}, {id: MenuId.assets}, - {id: MenuId.entity_views}, - {id: MenuId.gateways} - ] - }, - { - id: MenuId.profiles, - pages: [ {id: MenuId.device_profiles}, - {id: MenuId.asset_profiles} - ] - }, - {id: MenuId.customers}, - {id: MenuId.calculated_fields}, - {id: MenuId.rule_chains}, - { - id: MenuId.edge_management, - pages: [ - {id: MenuId.edges}, - {id: MenuId.rulechain_templates} + {id: MenuId.asset_profiles}, + {id: MenuId.entity_views}, + {id: MenuId.otaUpdates} ] }, + {id: MenuId.customers_and_users}, { - id: MenuId.features, + id: MenuId.data_processing, pages: [ - {id: MenuId.otaUpdates}, - {id: MenuId.version_control} + {id: MenuId.calculated_fields}, + {id: MenuId.rule_chains} ] }, { @@ -963,36 +983,49 @@ const defaultUserMenuMap = new Map([ ] }, { - id: MenuId.mobile_center, - pages: [ - {id: MenuId.mobile_bundles}, - {id: MenuId.mobile_apps} - ] - }, - {id: MenuId.api_usage}, - { - id: MenuId.settings, + id: MenuId.security_settings, pages: [ - {id: MenuId.home_settings}, - {id: MenuId.notification_settings}, - {id: MenuId.repository_settings}, - {id: MenuId.auto_commit_settings}, - {id: MenuId.trendz_settings}, - {id: MenuId.ai_models} + { + id: MenuId.oauth2, + pages: [ + {id: MenuId.clients} + ] + }, + {id: MenuId.audit_log} ] }, { - id: MenuId.security_settings, + id: MenuId.platform_section, pages: [ - {id: MenuId.audit_log}, + {id: MenuId.version_control}, { - id: MenuId.oauth2, + id: MenuId.settings, pages: [ - {id: MenuId.clients} + {id: MenuId.home_settings}, + {id: MenuId.notification_settings}, + {id: MenuId.repository_settings}, + {id: MenuId.auto_commit_settings}, + {id: MenuId.trendz_settings}, + {id: MenuId.ai_models} ] } ] - } + }, + { + id: MenuId.edge_management, + pages: [ + {id: MenuId.edges}, + {id: MenuId.rulechain_templates} + ] + }, + { + id: MenuId.mobile_center, + pages: [ + {id: MenuId.mobile_bundles}, + {id: MenuId.mobile_apps} + ] + }, + {id: MenuId.api_usage}, ] ], [ diff --git a/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts b/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts index 5051f6ecd6..700ee2b2e9 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts @@ -227,7 +227,10 @@ const routes: Routes = [ auth: [Authority.SYS_ADMIN, Authority.TENANT_ADMIN], showMainLoadingBar: false, breadcrumb: { - menuId: MenuId.platform + menuIdByAuthority: { + SYS_ADMIN: MenuId.platform, + TENANT_ADMIN: MenuId.settings + } } }, children: [ diff --git a/ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts b/ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts index 0c2dc6b3f8..d302af7c2c 100644 --- a/ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts @@ -38,7 +38,7 @@ const routes: Routes = [ path: 'customers', data: { breadcrumb: { - menuId: MenuId.customers + menuId: MenuId.customers_and_users } }, children: [ diff --git a/ui-ngx/src/app/modules/home/pages/features/features-routing.module.ts b/ui-ngx/src/app/modules/home/pages/features/features-routing.module.ts index f664a4b607..7e1e9fa970 100644 --- a/ui-ngx/src/app/modules/home/pages/features/features-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/features/features-routing.module.ts @@ -27,7 +27,8 @@ const routes: Routes = [ data: { auth: [Authority.TENANT_ADMIN], breadcrumb: { - menuId: MenuId.features + menuId: MenuId.features, + skip: true } }, children: [ diff --git a/ui-ngx/src/app/modules/home/pages/profiles/profiles-routing.module.ts b/ui-ngx/src/app/modules/home/pages/profiles/profiles-routing.module.ts index 7593162704..e99cb56113 100644 --- a/ui-ngx/src/app/modules/home/pages/profiles/profiles-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/profiles/profiles-routing.module.ts @@ -27,7 +27,8 @@ const routes: Routes = [ data: { auth: [Authority.TENANT_ADMIN], breadcrumb: { - menuId: MenuId.profiles + menuId: MenuId.profiles, + skip: true } }, children: [ diff --git a/ui-ngx/src/app/shared/components/breadcrumb.ts b/ui-ngx/src/app/shared/components/breadcrumb.ts index 71911d9f5b..ed45335510 100644 --- a/ui-ngx/src/app/shared/components/breadcrumb.ts +++ b/ui-ngx/src/app/shared/components/breadcrumb.ts @@ -18,6 +18,7 @@ import { ActivatedRouteSnapshot, Params } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { HasUUID } from '@shared/models/id/has-uuid'; import { MenuId } from '@core/services/menu.models'; +import { Authority } from '@shared/models/authority.enum'; export interface BreadCrumb extends HasUUID{ label: string; @@ -32,6 +33,7 @@ export type BreadCrumbLabelFunction = (route: ActivatedRouteSnapshot, transla export interface BreadCrumbConfig { labelFunction: BreadCrumbLabelFunction; menuId?: MenuId; + menuIdByAuthority?: {[authority: string]: MenuId}; label?: string; icon?: string; skip: boolean; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index e24dd0eb88..5996766c51 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1733,6 +1733,7 @@ "customer": { "customer": "Customer", "customers": "Customers", + "customers-and-users": "Customers & users", "management": "Customer management", "dashboard": "Customer Dashboard", "dashboards": "Customer Dashboards", @@ -3025,6 +3026,8 @@ "entity": { "entity": "Entity", "entities": "Entities", + "devices-and-assets": "Devices & assets", + "data-processing": "Data processing", "entities-count": "Entities count", "alarms-count": "Alarms count", "aliases": "Entity aliases",