diff --git a/ui-ngx/src/app/core/services/menu.models.ts b/ui-ngx/src/app/core/services/menu.models.ts index f9715b3555..028a0f5380 100644 --- a/ui-ngx/src/app/core/services/menu.models.ts +++ b/ui-ngx/src/app/core/services/menu.models.ts @@ -14,9 +14,11 @@ /// limitations under the License. /// +import { HasUUID } from '@shared/models/id/has-uuid'; + export declare type MenuSectionType = 'link' | 'toggle'; -export class MenuSection { +export interface MenuSection extends HasUUID{ name: string; type: MenuSectionType; path: string; @@ -26,12 +28,12 @@ export class MenuSection { pages?: Array; } -export class HomeSection { +export interface HomeSection { name: string; places: Array; } -export class HomeSectionPlace { +export interface HomeSectionPlace { name: string; icon: string; isMdiIcon?: boolean; diff --git a/ui-ngx/src/app/core/services/menu.service.ts b/ui-ngx/src/app/core/services/menu.service.ts index 6032bf24f3..b3f99671e6 100644 --- a/ui-ngx/src/app/core/services/menu.service.ts +++ b/ui-ngx/src/app/core/services/menu.service.ts @@ -24,6 +24,7 @@ import { HomeSection, MenuSection } from '@core/services/menu.models'; import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { Authority } from '@shared/models/authority.enum'; import { AuthUser } from '@shared/models/user.model'; +import { guid } from '@core/utils'; @Injectable({ providedIn: 'root' @@ -74,24 +75,28 @@ export class MenuService { const sections: Array = []; sections.push( { + id: guid(), name: 'home.home', type: 'link', path: '/home', icon: 'home' }, { + id: guid(), name: 'tenant.tenants', type: 'link', path: '/tenants', icon: 'supervisor_account' }, { + id: guid(), name: 'widget.widget-library', type: 'link', path: '/widgets-bundles', icon: 'now_widgets' }, { + id: guid(), name: 'admin.system-settings', type: 'toggle', path: '/settings', @@ -99,18 +104,21 @@ export class MenuService { icon: 'settings', pages: [ { + id: guid(), name: 'admin.general', type: 'link', path: '/settings/general', icon: 'settings_applications' }, { + id: guid(), name: 'admin.outgoing-mail', type: 'link', path: '/settings/outgoing-mail', icon: 'mail' }, { + id: guid(), name: 'admin.security-settings', type: 'link', path: '/settings/security-settings', @@ -173,54 +181,63 @@ export class MenuService { const sections: Array = []; sections.push( { + id: guid(), name: 'home.home', type: 'link', path: '/home', icon: 'home' }, { + id: guid(), name: 'rulechain.rulechains', type: 'link', path: '/ruleChains', icon: 'settings_ethernet' }, { + id: guid(), name: 'customer.customers', type: 'link', path: '/customers', icon: 'supervisor_account' }, { + id: guid(), name: 'asset.assets', type: 'link', path: '/assets', icon: 'domain' }, { + id: guid(), name: 'device.devices', type: 'link', path: '/devices', icon: 'devices_other' }, { + id: guid(), name: 'entity-view.entity-views', type: 'link', path: '/entityViews', icon: 'view_quilt' }, { + id: guid(), name: 'widget.widget-library', type: 'link', path: '/widgets-bundles', icon: 'now_widgets' }, { + id: guid(), name: 'dashboard.dashboards', type: 'link', path: '/dashboards', icon: 'dashboards' }, { + id: guid(), name: 'audit-log.audit-logs', type: 'link', path: '/auditLogs', @@ -316,30 +333,35 @@ export class MenuService { const sections: Array = []; sections.push( { + id: guid(), name: 'home.home', type: 'link', path: '/home', icon: 'home' }, { + id: guid(), name: 'asset.assets', type: 'link', path: '/assets', icon: 'domain' }, { + id: guid(), name: 'device.devices', type: 'link', path: '/devices', icon: 'devices_other' }, { + id: guid(), name: 'entity-view.entity-views', type: 'link', path: '/entityViews', icon: 'view_quilt' }, { + id: guid(), name: 'dashboard.dashboards', type: 'link', path: '/dashboards', diff --git a/ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts b/ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts index 9a515bcfba..da1b5d6a42 100644 --- a/ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts +++ b/ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts @@ -46,6 +46,6 @@ export class MenuToggleComponent implements OnInit { } trackBySectionPages(index: number, section: MenuSection){ - return section.name; + return section.id; } } diff --git a/ui-ngx/src/app/modules/home/menu/side-menu.component.ts b/ui-ngx/src/app/modules/home/menu/side-menu.component.ts index b5d1be8610..92e80d38aa 100644 --- a/ui-ngx/src/app/modules/home/menu/side-menu.component.ts +++ b/ui-ngx/src/app/modules/home/menu/side-menu.component.ts @@ -31,7 +31,7 @@ export class SideMenuComponent implements OnInit { } trackByMenuSection(index: number, section: MenuSection){ - return section.name; + return section.id; } ngOnInit() { diff --git a/ui-ngx/src/app/shared/components/breadcrumb.component.ts b/ui-ngx/src/app/shared/components/breadcrumb.component.ts index 651ed77831..401d72859b 100644 --- a/ui-ngx/src/app/shared/components/breadcrumb.component.ts +++ b/ui-ngx/src/app/shared/components/breadcrumb.component.ts @@ -20,6 +20,7 @@ import { BreadCrumb, BreadCrumbConfig } from './breadcrumb'; import { ActivatedRoute, ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router'; import { distinctUntilChanged, filter, map } from 'rxjs/operators'; import { TranslateService } from '@ngx-translate/core'; +import { guid } from '@core/utils'; @Component({ selector: 'tb-breadcrumb', @@ -94,6 +95,7 @@ export class BreadcrumbComponent implements OnInit, OnDestroy { const isMdiIcon = icon.startsWith('mdi:'); const link = [ route.pathFromRoot.map(v => v.url.map(segment => segment.toString()).join('/')).join('/') ]; const breadcrumb = { + id: guid(), label, labelFunction, ignoreTranslate, @@ -112,6 +114,6 @@ export class BreadcrumbComponent implements OnInit, OnDestroy { } trackByBreadcrumbs(index: number, breadcrumb: BreadCrumb){ - return breadcrumb.labelFunction ? breadcrumb.labelFunction() : breadcrumb.label; + return breadcrumb.id; } } diff --git a/ui-ngx/src/app/shared/components/breadcrumb.ts b/ui-ngx/src/app/shared/components/breadcrumb.ts index 2a1f3d5988..bf43f8ef5b 100644 --- a/ui-ngx/src/app/shared/components/breadcrumb.ts +++ b/ui-ngx/src/app/shared/components/breadcrumb.ts @@ -16,8 +16,9 @@ import { ActivatedRouteSnapshot, Params } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; +import { HasUUID } from '@shared/models/id/has-uuid'; -export interface BreadCrumb { +export interface BreadCrumb extends HasUUID{ label: string; labelFunction?: () => string; ignoreTranslate: boolean;