Browse Source

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

pull/15888/head
Igor Kulikov 3 weeks 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 { 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<AppState>,
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';

121
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<MenuId, MenuSection>([
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, MenuSection>([
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<MenuId, MenuSection>([
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<MenuId, MenuSection>([
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<MenuId, MenuSection>([
name: 'api-usage.api-usage',
type: 'link',
path: '/usage',
icon: 'insert_chart'
icon: 'insert_chart_outlined'
}
],
[
@ -917,33 +950,20 @@ const defaultUserMenuMap = new Map<Authority, MenuReference[]>([
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<Authority, MenuReference[]>([
]
},
{
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},
]
],
[

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

2
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: [

3
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: [

3
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: [

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 { 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<C> = (route: ActivatedRouteSnapshot, transla
export interface BreadCrumbConfig<C> {
labelFunction: BreadCrumbLabelFunction<C>;
menuId?: MenuId;
menuIdByAuthority?: {[authority: string]: MenuId};
label?: string;
icon?: string;
skip: boolean;

3
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",

Loading…
Cancel
Save