Browse Source

UI: more menu/breadcrumb wiring — admin/customer/features/profiles route data and translations

pull/15888/head
Igor Kulikov 3 months ago
parent
commit
9bb172af5b
  1. 15
      ui-ngx/src/app/core/services/breadcrumb.service.ts
  2. 121
      ui-ngx/src/app/core/services/menu.models.ts
  3. 5
      ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts
  4. 2
      ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts
  5. 3
      ui-ngx/src/app/modules/home/pages/features/features-routing.module.ts
  6. 3
      ui-ngx/src/app/modules/home/pages/profiles/profiles-routing.module.ts
  7. 2
      ui-ngx/src/app/shared/components/breadcrumb.ts
  8. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

15
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 { MenuSection, menuSectionMap } from '@core/services/menu.models';
import { guid } from '@core/utils'; import { guid } from '@core/utils';
import { ActiveComponentService } from '@core/services/active-component.service'; 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({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -45,6 +48,7 @@ export class BreadcrumbService {
} }
constructor(private router: Router, constructor(private router: Router,
private store: Store<AppState>,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private translate: TranslateService, private translate: TranslateService,
private menuService: MenuService, private menuService: MenuService,
@ -90,10 +94,15 @@ export class BreadcrumbService {
if (breadcrumbConfig && !breadcrumbConfig.skip) { if (breadcrumbConfig && !breadcrumbConfig.skip) {
let labelFunction: () => string; let labelFunction: () => string;
let section: MenuSection = null; let section: MenuSection = null;
if (breadcrumbConfig.menuId) { let menuId = breadcrumbConfig.menuId;
section = availableMenuSections.find(menu => menu.id === 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) { if (!section) {
section = menuSectionMap.get(breadcrumbConfig.menuId); section = menuSectionMap.get(menuId);
} }
} }
const label = section?.name || breadcrumbConfig.label || 'home.home'; const label = section?.name || breadcrumbConfig.label || 'home.home';

121
ui-ngx/src/app/core/services/menu.models.ts

@ -73,6 +73,7 @@ export enum MenuId {
mobile_bundles = 'mobile_bundles', mobile_bundles = 'mobile_bundles',
mobile_qr_code_widget = 'mobile_qr_code_widget', mobile_qr_code_widget = 'mobile_qr_code_widget',
platform = 'platform', platform = 'platform',
platform_section = 'platform_section',
settings = 'settings', settings = 'settings',
general = 'general', general = 'general',
mail_server = 'mail_server', mail_server = 'mail_server',
@ -101,7 +102,9 @@ export enum MenuId {
profiles = 'profiles', profiles = 'profiles',
device_profiles = 'device_profiles', device_profiles = 'device_profiles',
asset_profiles = 'asset_profiles', asset_profiles = 'asset_profiles',
customers_and_users = 'customers_and_users',
customers = 'customers', customers = 'customers',
data_processing = 'data_processing',
calculated_fields = 'calculated_fields', calculated_fields = 'calculated_fields',
rule_chains = 'rule_chains', rule_chains = 'rule_chains',
edge_management = 'edge_management', edge_management = 'edge_management',
@ -367,6 +370,16 @@ export const menuSectionMap = new Map<MenuId, MenuSection>([
icon: 'miscellaneous_services' icon: 'miscellaneous_services'
} }
], ],
[
MenuId.platform_section,
{
id: MenuId.platform_section,
name: 'admin.platform',
type: 'toggle',
path: '/platform',
icon: 'miscellaneous_services'
}
],
[ [
MenuId.settings, MenuId.settings,
{ {
@ -577,10 +590,10 @@ export const menuSectionMap = new Map<MenuId, MenuSection>([
MenuId.entities, MenuId.entities,
{ {
id: MenuId.entities, id: MenuId.entities,
name: 'entity.entities', name: 'entity.devices-and-assets',
type: 'toggle', type: 'toggle',
path: '/entities', path: '/entities',
icon: 'category' icon: 'mdi:shape-outline'
} }
], ],
[ [
@ -653,6 +666,16 @@ export const menuSectionMap = new Map<MenuId, MenuSection>([
icon: 'mdi:alpha-a-box' 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, MenuId.customers,
{ {
@ -663,6 +686,16 @@ export const menuSectionMap = new Map<MenuId, MenuSection>([
icon: 'supervisor_account' icon: 'supervisor_account'
} }
], ],
[
MenuId.data_processing,
{
id: MenuId.data_processing,
name: 'entity.data-processing',
type: 'toggle',
path: '/dataProcessing',
icon: 'settings_ethernet',
}
],
[ [
MenuId.calculated_fields, MenuId.calculated_fields,
{ {
@ -763,7 +796,7 @@ export const menuSectionMap = new Map<MenuId, MenuSection>([
name: 'api-usage.api-usage', name: 'api-usage.api-usage',
type: 'link', type: 'link',
path: '/usage', path: '/usage',
icon: 'insert_chart' icon: 'insert_chart_outlined'
} }
], ],
[ [
@ -917,33 +950,20 @@ const defaultUserMenuMap = new Map<Authority, MenuReference[]>([
id: MenuId.entities, id: MenuId.entities,
pages: [ pages: [
{id: MenuId.devices}, {id: MenuId.devices},
{id: MenuId.gateways},
{id: MenuId.assets}, {id: MenuId.assets},
{id: MenuId.entity_views},
{id: MenuId.gateways}
]
},
{
id: MenuId.profiles,
pages: [
{id: MenuId.device_profiles}, {id: MenuId.device_profiles},
{id: MenuId.asset_profiles} {id: MenuId.asset_profiles},
] {id: MenuId.entity_views},
}, {id: MenuId.otaUpdates}
{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.customers_and_users},
{ {
id: MenuId.features, id: MenuId.data_processing,
pages: [ pages: [
{id: MenuId.otaUpdates}, {id: MenuId.calculated_fields},
{id: MenuId.version_control} {id: MenuId.rule_chains}
] ]
}, },
{ {
@ -963,36 +983,49 @@ const defaultUserMenuMap = new Map<Authority, MenuReference[]>([
] ]
}, },
{ {
id: MenuId.mobile_center, id: MenuId.security_settings,
pages: [
{id: MenuId.mobile_bundles},
{id: MenuId.mobile_apps}
]
},
{id: MenuId.api_usage},
{
id: MenuId.settings,
pages: [ pages: [
{id: MenuId.home_settings}, {
{id: MenuId.notification_settings}, id: MenuId.oauth2,
{id: MenuId.repository_settings}, pages: [
{id: MenuId.auto_commit_settings}, {id: MenuId.clients}
{id: MenuId.trendz_settings}, ]
{id: MenuId.ai_models} },
{id: MenuId.audit_log}
] ]
}, },
{ {
id: MenuId.security_settings, id: MenuId.platform_section,
pages: [ pages: [
{id: MenuId.audit_log}, {id: MenuId.version_control},
{ {
id: MenuId.oauth2, id: MenuId.settings,
pages: [ 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},
] ]
], ],
[ [

5
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], auth: [Authority.SYS_ADMIN, Authority.TENANT_ADMIN],
showMainLoadingBar: false, showMainLoadingBar: false,
breadcrumb: { breadcrumb: {
menuId: MenuId.platform menuIdByAuthority: {
SYS_ADMIN: MenuId.platform,
TENANT_ADMIN: MenuId.settings
}
} }
}, },
children: [ children: [

2
ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts

@ -38,7 +38,7 @@ const routes: Routes = [
path: 'customers', path: 'customers',
data: { data: {
breadcrumb: { breadcrumb: {
menuId: MenuId.customers menuId: MenuId.customers_and_users
} }
}, },
children: [ children: [

3
ui-ngx/src/app/modules/home/pages/features/features-routing.module.ts

@ -27,7 +27,8 @@ const routes: Routes = [
data: { data: {
auth: [Authority.TENANT_ADMIN], auth: [Authority.TENANT_ADMIN],
breadcrumb: { breadcrumb: {
menuId: MenuId.features menuId: MenuId.features,
skip: true
} }
}, },
children: [ children: [

3
ui-ngx/src/app/modules/home/pages/profiles/profiles-routing.module.ts

@ -27,7 +27,8 @@ const routes: Routes = [
data: { data: {
auth: [Authority.TENANT_ADMIN], auth: [Authority.TENANT_ADMIN],
breadcrumb: { breadcrumb: {
menuId: MenuId.profiles menuId: MenuId.profiles,
skip: true
} }
}, },
children: [ children: [

2
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 { TranslateService } from '@ngx-translate/core';
import { HasUUID } from '@shared/models/id/has-uuid'; import { HasUUID } from '@shared/models/id/has-uuid';
import { MenuId } from '@core/services/menu.models'; import { MenuId } from '@core/services/menu.models';
import { Authority } from '@shared/models/authority.enum';
export interface BreadCrumb extends HasUUID{ export interface BreadCrumb extends HasUUID{
label: string; label: string;
@ -32,6 +33,7 @@ export type BreadCrumbLabelFunction<C> = (route: ActivatedRouteSnapshot, transla
export interface BreadCrumbConfig<C> { export interface BreadCrumbConfig<C> {
labelFunction: BreadCrumbLabelFunction<C>; labelFunction: BreadCrumbLabelFunction<C>;
menuId?: MenuId; menuId?: MenuId;
menuIdByAuthority?: {[authority: string]: MenuId};
label?: string; label?: string;
icon?: string; icon?: string;
skip: boolean; skip: boolean;

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1733,6 +1733,7 @@
"customer": { "customer": {
"customer": "Customer", "customer": "Customer",
"customers": "Customers", "customers": "Customers",
"customers-and-users": "Customers & users",
"management": "Customer management", "management": "Customer management",
"dashboard": "Customer Dashboard", "dashboard": "Customer Dashboard",
"dashboards": "Customer Dashboards", "dashboards": "Customer Dashboards",
@ -3025,6 +3026,8 @@
"entity": { "entity": {
"entity": "Entity", "entity": "Entity",
"entities": "Entities", "entities": "Entities",
"devices-and-assets": "Devices & assets",
"data-processing": "Data processing",
"entities-count": "Entities count", "entities-count": "Entities count",
"alarms-count": "Alarms count", "alarms-count": "Alarms count",
"aliases": "Entity aliases", "aliases": "Entity aliases",

Loading…
Cancel
Save