2019-08-09 19:13:18 +03:00
|
|
|
///
|
2023-01-31 10:43:56 +02:00
|
|
|
/// Copyright © 2016-2023 The Thingsboard Authors
|
2019-08-09 19:13:18 +03:00
|
|
|
///
|
|
|
|
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
/// you may not use this file except in compliance with the License.
|
|
|
|
|
/// You may obtain a copy of the License at
|
|
|
|
|
///
|
|
|
|
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
///
|
|
|
|
|
/// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
/// See the License for the specific language governing permissions and
|
|
|
|
|
/// limitations under the License.
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { select, Store } from '@ngrx/store';
|
|
|
|
|
import { AppState } from '../core.state';
|
2023-02-09 19:13:44 +02:00
|
|
|
import { getCurrentOpenedMenuSections, selectAuth, selectIsAuthenticated } from '../auth/auth.selectors';
|
2023-02-13 19:09:05 +02:00
|
|
|
import { filter, take } from 'rxjs/operators';
|
2019-08-09 19:13:18 +03:00
|
|
|
import { HomeSection, MenuSection } from '@core/services/menu.models';
|
|
|
|
|
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
|
|
|
|
import { Authority } from '@shared/models/authority.enum';
|
2020-09-15 12:20:19 +03:00
|
|
|
import { guid } from '@core/utils';
|
2021-01-12 22:01:32 +02:00
|
|
|
import { AuthState } from '@core/auth/auth.models';
|
2023-02-13 19:09:05 +02:00
|
|
|
import { NavigationEnd, Router } from '@angular/router';
|
2019-08-09 19:13:18 +03:00
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class MenuService {
|
|
|
|
|
|
2023-02-13 19:09:05 +02:00
|
|
|
currentMenuSections: Array<MenuSection>;
|
2019-08-09 19:13:18 +03:00
|
|
|
menuSections$: Subject<Array<MenuSection>> = new BehaviorSubject<Array<MenuSection>>([]);
|
|
|
|
|
homeSections$: Subject<Array<HomeSection>> = new BehaviorSubject<Array<HomeSection>>([]);
|
|
|
|
|
|
2023-02-09 19:13:44 +02:00
|
|
|
constructor(private store: Store<AppState>,
|
|
|
|
|
private router: Router) {
|
2019-08-09 19:13:18 +03:00
|
|
|
this.store.pipe(select(selectIsAuthenticated)).subscribe(
|
|
|
|
|
(authenticated: boolean) => {
|
|
|
|
|
if (authenticated) {
|
|
|
|
|
this.buildMenu();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2023-02-13 19:09:05 +02:00
|
|
|
this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(
|
|
|
|
|
() => {
|
|
|
|
|
this.updateOpenedMenuSections();
|
|
|
|
|
}
|
|
|
|
|
);
|
2019-08-09 19:13:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private buildMenu() {
|
2020-12-20 19:47:26 +02:00
|
|
|
this.store.pipe(select(selectAuth), take(1)).subscribe(
|
|
|
|
|
(authState: AuthState) => {
|
|
|
|
|
if (authState.authUser) {
|
2019-08-09 19:13:18 +03:00
|
|
|
let homeSections: Array<HomeSection>;
|
2020-12-20 19:47:26 +02:00
|
|
|
switch (authState.authUser.authority) {
|
2019-08-09 19:13:18 +03:00
|
|
|
case Authority.SYS_ADMIN:
|
2023-02-13 19:09:05 +02:00
|
|
|
this.currentMenuSections = this.buildSysAdminMenu(authState);
|
2020-12-20 19:47:26 +02:00
|
|
|
homeSections = this.buildSysAdminHome(authState);
|
2019-08-09 19:13:18 +03:00
|
|
|
break;
|
|
|
|
|
case Authority.TENANT_ADMIN:
|
2023-02-13 19:09:05 +02:00
|
|
|
this.currentMenuSections = this.buildTenantAdminMenu(authState);
|
2020-12-20 19:47:26 +02:00
|
|
|
homeSections = this.buildTenantAdminHome(authState);
|
2019-08-09 19:13:18 +03:00
|
|
|
break;
|
|
|
|
|
case Authority.CUSTOMER_USER:
|
2023-02-13 19:09:05 +02:00
|
|
|
this.currentMenuSections = this.buildCustomerUserMenu(authState);
|
2020-12-20 19:47:26 +02:00
|
|
|
homeSections = this.buildCustomerUserHome(authState);
|
2019-08-09 19:13:18 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2023-02-13 19:09:05 +02:00
|
|
|
this.updateOpenedMenuSections();
|
|
|
|
|
this.menuSections$.next(this.currentMenuSections);
|
2019-08-09 19:13:18 +03:00
|
|
|
this.homeSections$.next(homeSections);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-13 19:09:05 +02:00
|
|
|
private updateOpenedMenuSections() {
|
|
|
|
|
const url = this.router.url;
|
|
|
|
|
const openedMenuSections = getCurrentOpenedMenuSections(this.store);
|
|
|
|
|
this.currentMenuSections.filter(section => section.type === 'toggle' &&
|
|
|
|
|
(url.startsWith(section.path) || openedMenuSections.includes(section.path))).forEach(
|
|
|
|
|
section => section.opened = true
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-20 19:47:26 +02:00
|
|
|
private buildSysAdminMenu(authState: AuthState): Array<MenuSection> {
|
2019-08-09 19:13:18 +03:00
|
|
|
const sections: Array<MenuSection> = [];
|
|
|
|
|
sections.push(
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2019-08-09 19:13:18 +03:00
|
|
|
name: 'home.home',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/home',
|
|
|
|
|
icon: 'home'
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2019-08-09 19:13:18 +03:00
|
|
|
name: 'tenant.tenants',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/tenants',
|
|
|
|
|
icon: 'supervisor_account'
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-09-16 12:12:59 +03:00
|
|
|
id: guid(),
|
2020-08-27 19:32:15 +03:00
|
|
|
name: 'tenant-profile.tenant-profiles',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/tenantProfiles',
|
|
|
|
|
icon: 'mdi:alpha-t-box',
|
|
|
|
|
isMdiIcon: true
|
|
|
|
|
},
|
2019-08-09 19:13:18 +03:00
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-09 19:13:44 +02:00
|
|
|
name: 'admin.resources',
|
|
|
|
|
type: 'toggle',
|
|
|
|
|
path: '/resources',
|
|
|
|
|
height: '80px',
|
|
|
|
|
icon: 'folder',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'widget.widget-library',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/resources/widgets-bundles',
|
|
|
|
|
icon: 'now_widgets'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'resource.resources-library',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/resources/resources-library',
|
|
|
|
|
icon: 'mdi:rhombus-split',
|
|
|
|
|
isMdiIcon: true
|
|
|
|
|
}
|
|
|
|
|
]
|
2019-08-09 19:13:18 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'admin.settings',
|
2023-02-09 19:13:44 +02:00
|
|
|
type: 'link',
|
2019-08-09 19:13:18 +03:00
|
|
|
path: '/settings',
|
|
|
|
|
icon: 'settings',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2019-08-09 19:13:18 +03:00
|
|
|
name: 'admin.general',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/settings/general',
|
|
|
|
|
icon: 'settings_applications'
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2019-08-09 19:13:18 +03:00
|
|
|
name: 'admin.outgoing-mail',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/settings/outgoing-mail',
|
|
|
|
|
icon: 'mail'
|
|
|
|
|
},
|
2020-11-20 13:08:20 +02:00
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-09 19:13:44 +02:00
|
|
|
name: 'admin.notifications',
|
2020-11-20 13:08:20 +02:00
|
|
|
type: 'link',
|
2023-02-09 19:13:44 +02:00
|
|
|
path: '/settings/notifications',
|
|
|
|
|
icon: 'mdi:message-badge',
|
|
|
|
|
isMdiIcon: true
|
2020-11-20 13:08:20 +02:00
|
|
|
},
|
2019-08-09 19:13:18 +03:00
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-09 19:13:44 +02:00
|
|
|
name: 'admin.queues',
|
2019-08-09 19:13:18 +03:00
|
|
|
type: 'link',
|
2023-02-09 19:13:44 +02:00
|
|
|
path: '/settings/queues',
|
|
|
|
|
icon: 'swap_calls'
|
2020-07-09 13:47:35 +03:00
|
|
|
},
|
2023-02-09 19:13:44 +02:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'security.security',
|
2023-03-21 12:19:37 +02:00
|
|
|
type: 'toggle',
|
2023-02-09 19:13:44 +02:00
|
|
|
path: '/security-settings',
|
2023-03-21 12:19:37 +02:00
|
|
|
height: '120px',
|
2023-02-09 19:13:44 +02:00
|
|
|
icon: 'security',
|
|
|
|
|
pages: [
|
2020-07-09 13:47:35 +03:00
|
|
|
{
|
2020-10-08 11:37:04 +03:00
|
|
|
id: guid(),
|
2023-02-09 19:13:44 +02:00
|
|
|
name: 'admin.general',
|
2020-07-09 13:47:35 +03:00
|
|
|
type: 'link',
|
2023-02-09 19:13:44 +02:00
|
|
|
path: '/security-settings/general',
|
|
|
|
|
icon: 'settings_applications'
|
2021-04-29 16:55:05 +03:00
|
|
|
},
|
2022-04-28 23:03:37 +03:00
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-14 16:59:04 +02:00
|
|
|
name: 'admin.2fa.2fa',
|
2022-04-28 23:03:37 +03:00
|
|
|
type: 'link',
|
2023-02-14 16:59:04 +02:00
|
|
|
path: '/security-settings/2fa',
|
|
|
|
|
icon: 'mdi:two-factor-authentication',
|
2022-04-28 23:03:37 +03:00
|
|
|
isMdiIcon: true
|
|
|
|
|
},
|
2021-04-29 16:55:05 +03:00
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-14 16:59:04 +02:00
|
|
|
name: 'admin.oauth2.oauth2',
|
2022-02-18 16:41:24 +02:00
|
|
|
type: 'link',
|
2023-02-14 16:59:04 +02:00
|
|
|
path: '/security-settings/oauth2',
|
|
|
|
|
icon: 'mdi:shield-account',
|
2023-02-09 19:13:44 +02:00
|
|
|
isMdiIcon: true
|
|
|
|
|
}
|
2019-08-09 19:13:18 +03:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
return sections;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-20 19:47:26 +02:00
|
|
|
private buildSysAdminHome(authState: AuthState): Array<HomeSection> {
|
2019-08-09 19:13:18 +03:00
|
|
|
const homeSections: Array<HomeSection> = [];
|
|
|
|
|
homeSections.push(
|
|
|
|
|
{
|
|
|
|
|
name: 'tenant.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'tenant.tenants',
|
|
|
|
|
icon: 'supervisor_account',
|
|
|
|
|
path: '/tenants'
|
2020-08-27 19:32:15 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'tenant-profile.tenant-profiles',
|
|
|
|
|
icon: 'mdi:alpha-t-box',
|
|
|
|
|
isMdiIcon: true,
|
|
|
|
|
path: '/tenantProfiles'
|
|
|
|
|
},
|
2019-08-09 19:13:18 +03:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'widget.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'widget.widget-library',
|
|
|
|
|
icon: 'now_widgets',
|
|
|
|
|
path: '/widgets-bundles'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.system-settings',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.general',
|
|
|
|
|
icon: 'settings_applications',
|
|
|
|
|
path: '/settings/general'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.outgoing-mail',
|
|
|
|
|
icon: 'mail',
|
|
|
|
|
path: '/settings/outgoing-mail'
|
|
|
|
|
},
|
2020-11-20 13:08:20 +02:00
|
|
|
{
|
|
|
|
|
name: 'admin.sms-provider',
|
|
|
|
|
icon: 'sms',
|
|
|
|
|
path: '/settings/sms-provider'
|
|
|
|
|
},
|
2019-08-09 19:13:18 +03:00
|
|
|
{
|
|
|
|
|
name: 'admin.security-settings',
|
|
|
|
|
icon: 'security',
|
|
|
|
|
path: '/settings/security-settings'
|
2020-10-15 12:51:02 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.oauth2.oauth2',
|
|
|
|
|
icon: 'security',
|
|
|
|
|
path: '/settings/oauth2'
|
2021-04-29 16:55:05 +03:00
|
|
|
},
|
2022-04-28 23:03:37 +03:00
|
|
|
{
|
|
|
|
|
name: 'admin.2fa.2fa',
|
|
|
|
|
icon: 'mdi:two-factor-authentication',
|
|
|
|
|
isMdiIcon: true,
|
|
|
|
|
path: '/settings/2fa'
|
|
|
|
|
},
|
2021-04-29 16:55:05 +03:00
|
|
|
{
|
|
|
|
|
name: 'resource.resources-library',
|
|
|
|
|
icon: 'folder',
|
2021-08-21 15:17:56 +08:00
|
|
|
path: '/settings/resources-library'
|
2022-02-18 16:41:24 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.queues',
|
|
|
|
|
icon: 'swap_calls',
|
|
|
|
|
path: '/settings/queues'
|
|
|
|
|
},
|
2019-08-09 19:13:18 +03:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
return homeSections;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-20 19:47:26 +02:00
|
|
|
private buildTenantAdminMenu(authState: AuthState): Array<MenuSection> {
|
2019-08-09 19:13:18 +03:00
|
|
|
const sections: Array<MenuSection> = [];
|
|
|
|
|
sections.push(
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2019-08-09 19:13:18 +03:00
|
|
|
name: 'home.home',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/home',
|
|
|
|
|
icon: 'home'
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'alarm.alarms',
|
2019-08-09 19:13:18 +03:00
|
|
|
type: 'link',
|
2023-03-10 14:58:16 +02:00
|
|
|
path: '/alarms',
|
|
|
|
|
icon: 'notifications'
|
2019-08-09 19:13:18 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'dashboard.dashboards',
|
2019-08-09 19:13:18 +03:00
|
|
|
type: 'link',
|
2023-02-13 19:09:05 +02:00
|
|
|
path: '/dashboards',
|
|
|
|
|
icon: 'dashboards'
|
2019-08-09 19:13:18 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'entity.entities',
|
|
|
|
|
type: 'toggle',
|
|
|
|
|
path: '/entities',
|
|
|
|
|
height: '120px',
|
|
|
|
|
icon: 'category',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'device.devices',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/entities/devices',
|
|
|
|
|
icon: 'devices_other'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'asset.assets',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/entities/assets',
|
|
|
|
|
icon: 'domain'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'entity-view.entity-views',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/entities/entityViews',
|
|
|
|
|
icon: 'view_quilt'
|
|
|
|
|
}
|
|
|
|
|
]
|
2019-08-09 19:13:18 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-16 12:12:59 +03:00
|
|
|
id: guid(),
|
2022-09-26 18:10:12 +03:00
|
|
|
name: 'profiles.profiles',
|
|
|
|
|
type: 'toggle',
|
|
|
|
|
path: '/profiles',
|
|
|
|
|
height: '80px',
|
|
|
|
|
icon: 'badge',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'device-profile.device-profiles',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/profiles/deviceProfiles',
|
|
|
|
|
icon: 'mdi:alpha-d-box',
|
|
|
|
|
isMdiIcon: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'asset-profile.asset-profiles',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/profiles/assetProfiles',
|
|
|
|
|
icon: 'mdi:alpha-a-box',
|
|
|
|
|
isMdiIcon: true
|
|
|
|
|
}
|
|
|
|
|
]
|
2020-09-02 18:32:57 +03:00
|
|
|
},
|
2021-04-12 16:56:00 +03:00
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'customer.customers',
|
2019-08-09 19:13:18 +03:00
|
|
|
type: 'link',
|
2023-02-13 19:09:05 +02:00
|
|
|
path: '/customers',
|
|
|
|
|
icon: 'supervisor_account'
|
2020-12-18 16:29:12 +02:00
|
|
|
}
|
|
|
|
|
);
|
2020-12-20 19:47:26 +02:00
|
|
|
if (authState.edgesSupportEnabled) {
|
2020-12-18 16:29:12 +02:00
|
|
|
sections.push(
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'edge.management',
|
|
|
|
|
type: 'toggle',
|
2021-05-26 21:02:35 +03:00
|
|
|
path: '/edgeManagement',
|
2023-02-13 19:09:05 +02:00
|
|
|
height: '80px',
|
2021-05-26 21:02:35 +03:00
|
|
|
icon: 'settings_input_antenna',
|
2020-12-18 16:29:12 +02:00
|
|
|
pages: [
|
2023-02-13 19:09:05 +02:00
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'edge.instances',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/edgeManagement/instances',
|
|
|
|
|
icon: 'router'
|
|
|
|
|
},
|
2020-12-18 16:29:12 +02:00
|
|
|
{
|
|
|
|
|
id: guid(),
|
2020-12-21 19:14:22 +02:00
|
|
|
name: 'edge.rulechain-templates',
|
2020-12-18 16:29:12 +02:00
|
|
|
type: 'link',
|
2021-05-26 21:02:35 +03:00
|
|
|
path: '/edgeManagement/ruleChains',
|
2020-12-18 16:29:12 +02:00
|
|
|
icon: 'settings_ethernet'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
sections.push(
|
2019-08-09 19:13:18 +03:00
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'feature.advanced-features',
|
|
|
|
|
type: 'toggle',
|
|
|
|
|
path: '/features',
|
|
|
|
|
height: '120px',
|
|
|
|
|
icon: 'construction',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'rulechain.rulechains',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/features/ruleChains',
|
|
|
|
|
icon: 'settings_ethernet'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'ota-update.ota-updates',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/features/otaUpdates',
|
|
|
|
|
icon: 'memory'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'version-control.version-control',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/features/vc',
|
|
|
|
|
icon: 'history'
|
|
|
|
|
}
|
|
|
|
|
]
|
2019-08-09 19:13:18 +03:00
|
|
|
},
|
2022-05-25 12:26:23 +03:00
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'admin.resources',
|
|
|
|
|
type: 'toggle',
|
|
|
|
|
path: '/resources',
|
|
|
|
|
height: '80px',
|
|
|
|
|
icon: 'folder',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'widget.widget-library',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/resources/widgets-bundles',
|
|
|
|
|
icon: 'now_widgets'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'resource.resources-library',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/resources/resources-library',
|
|
|
|
|
icon: 'mdi:rhombus-split',
|
|
|
|
|
isMdiIcon: true
|
|
|
|
|
}
|
|
|
|
|
]
|
2022-05-25 12:26:23 +03:00
|
|
|
},
|
2019-08-09 19:13:18 +03:00
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'notification.notification-center',
|
2019-08-09 19:13:18 +03:00
|
|
|
type: 'link',
|
2023-02-13 19:09:05 +02:00
|
|
|
path: '/notification',
|
|
|
|
|
icon: 'mdi:message-badge',
|
|
|
|
|
isMdiIcon: true,
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'notification.inbox',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/notification/inbox',
|
|
|
|
|
icon: 'inbox'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'notification.sent',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/notification/sent',
|
|
|
|
|
icon: 'outbox'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'notification.templates',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/notification/templates',
|
|
|
|
|
icon: 'mdi:message-draw',
|
|
|
|
|
isMdiIcon: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'notification.recipients',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/notification/recipients',
|
|
|
|
|
icon: 'contacts'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'notification.rules',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/notification/rules',
|
|
|
|
|
icon: 'mdi:message-cog',
|
|
|
|
|
isMdiIcon: true
|
|
|
|
|
}
|
|
|
|
|
]
|
2020-11-27 17:35:19 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'api-usage.api-usage',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/usage',
|
2022-01-18 11:31:40 +02:00
|
|
|
icon: 'insert_chart'
|
2021-04-29 16:55:05 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'admin.settings',
|
|
|
|
|
type: 'link',
|
2021-04-29 16:55:05 +03:00
|
|
|
path: '/settings',
|
|
|
|
|
icon: 'settings',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'admin.home',
|
2021-04-29 16:55:05 +03:00
|
|
|
type: 'link',
|
|
|
|
|
path: '/settings/home',
|
|
|
|
|
icon: 'settings_applications'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'admin.repository',
|
2022-05-20 15:02:30 +03:00
|
|
|
type: 'link',
|
2022-05-31 16:16:24 +03:00
|
|
|
path: '/settings/repository',
|
2022-05-20 15:02:30 +03:00
|
|
|
icon: 'manage_history'
|
2022-05-31 18:42:33 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'admin.auto-commit',
|
2022-05-31 18:42:33 +03:00
|
|
|
type: 'link',
|
|
|
|
|
path: '/settings/auto-commit',
|
|
|
|
|
icon: 'settings_backup_restore'
|
2021-04-29 16:55:05 +03:00
|
|
|
}
|
|
|
|
|
]
|
2023-02-13 19:09:05 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'security.security',
|
2023-03-21 12:19:37 +02:00
|
|
|
type: 'toggle',
|
2023-02-13 19:09:05 +02:00
|
|
|
path: '/security-settings',
|
2023-03-21 12:19:37 +02:00
|
|
|
height: '40px',
|
2023-02-13 19:09:05 +02:00
|
|
|
icon: 'security',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'audit-log.audit-logs',
|
|
|
|
|
type: 'link',
|
2023-02-14 11:31:34 +02:00
|
|
|
path: '/security-settings/auditLogs',
|
2023-02-13 19:09:05 +02:00
|
|
|
icon: 'track_changes'
|
|
|
|
|
}
|
|
|
|
|
]
|
2019-08-09 19:13:18 +03:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
return sections;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-20 19:47:26 +02:00
|
|
|
private buildTenantAdminHome(authState: AuthState): Array<HomeSection> {
|
2019-08-09 19:13:18 +03:00
|
|
|
const homeSections: Array<HomeSection> = [];
|
|
|
|
|
homeSections.push(
|
|
|
|
|
{
|
|
|
|
|
name: 'rulechain.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'rulechain.rulechains',
|
|
|
|
|
icon: 'settings_ethernet',
|
|
|
|
|
path: '/ruleChains'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'customer.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'customer.customers',
|
|
|
|
|
icon: 'supervisor_account',
|
|
|
|
|
path: '/customers'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'asset.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'asset.assets',
|
|
|
|
|
icon: 'domain',
|
|
|
|
|
path: '/assets'
|
2022-09-26 18:10:12 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'asset-profile.asset-profiles',
|
|
|
|
|
icon: 'mdi:alpha-a-box',
|
|
|
|
|
isMdiIcon: true,
|
|
|
|
|
path: '/profiles/assetProfiles'
|
2019-08-09 19:13:18 +03:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'device.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'device.devices',
|
|
|
|
|
icon: 'devices_other',
|
|
|
|
|
path: '/devices'
|
2020-09-02 18:32:57 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'device-profile.device-profiles',
|
|
|
|
|
icon: 'mdi:alpha-d-box',
|
|
|
|
|
isMdiIcon: true,
|
2022-09-26 18:10:12 +03:00
|
|
|
path: '/profiles/deviceProfiles'
|
2021-04-12 16:56:00 +03:00
|
|
|
},
|
|
|
|
|
{
|
2021-05-31 18:15:31 +03:00
|
|
|
name: 'ota-update.ota-updates',
|
2021-04-12 16:56:00 +03:00
|
|
|
icon: 'memory',
|
2021-05-31 18:15:31 +03:00
|
|
|
path: '/otaUpdates'
|
2019-08-09 19:13:18 +03:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'entity-view.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'entity-view.entity-views',
|
|
|
|
|
icon: 'view_quilt',
|
|
|
|
|
path: '/entityViews'
|
|
|
|
|
}
|
|
|
|
|
]
|
2020-12-18 16:29:12 +02:00
|
|
|
}
|
|
|
|
|
);
|
2020-12-20 19:47:26 +02:00
|
|
|
if (authState.edgesSupportEnabled) {
|
2020-12-18 16:29:12 +02:00
|
|
|
homeSections.push(
|
|
|
|
|
{
|
|
|
|
|
name: 'edge.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
2020-12-21 19:14:22 +02:00
|
|
|
name: 'edge.edge-instances',
|
2020-12-18 16:29:12 +02:00
|
|
|
icon: 'router',
|
2021-05-26 21:02:35 +03:00
|
|
|
path: '/edgeInstances'
|
2020-12-18 16:29:12 +02:00
|
|
|
},
|
|
|
|
|
{
|
2020-12-21 19:14:22 +02:00
|
|
|
name: 'edge.rulechain-templates',
|
2020-12-18 16:29:12 +02:00
|
|
|
icon: 'settings_ethernet',
|
2021-05-26 21:02:35 +03:00
|
|
|
path: '/edgeManagement/ruleChains'
|
2020-12-18 16:29:12 +02:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
homeSections.push(
|
2019-08-09 19:13:18 +03:00
|
|
|
{
|
|
|
|
|
name: 'dashboard.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'widget.widget-library',
|
|
|
|
|
icon: 'now_widgets',
|
|
|
|
|
path: '/widgets-bundles'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'dashboard.dashboards',
|
|
|
|
|
icon: 'dashboard',
|
|
|
|
|
path: '/dashboards'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-05-25 12:26:23 +03:00
|
|
|
{
|
|
|
|
|
name: 'version-control.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'version-control.version-control',
|
|
|
|
|
icon: 'history',
|
|
|
|
|
path: '/vc'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
2019-08-09 19:13:18 +03:00
|
|
|
{
|
|
|
|
|
name: 'audit-log.audit',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'audit-log.audit-logs',
|
|
|
|
|
icon: 'track_changes',
|
|
|
|
|
path: '/auditLogs'
|
2020-11-27 17:35:19 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'api-usage.api-usage',
|
|
|
|
|
icon: 'insert_chart',
|
|
|
|
|
path: '/usage'
|
2019-08-09 19:13:18 +03:00
|
|
|
}
|
|
|
|
|
]
|
2021-04-29 16:55:05 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.system-settings',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.home-settings',
|
|
|
|
|
icon: 'settings_applications',
|
|
|
|
|
path: '/settings/home'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'resource.resources-library',
|
|
|
|
|
icon: 'folder',
|
|
|
|
|
path: '/settings/resources-library'
|
2022-05-20 15:02:30 +03:00
|
|
|
},
|
|
|
|
|
{
|
2022-05-31 16:16:24 +03:00
|
|
|
name: 'admin.repository-settings',
|
2022-05-20 15:02:30 +03:00
|
|
|
icon: 'manage_history',
|
2022-05-31 16:16:24 +03:00
|
|
|
path: '/settings/repository',
|
2022-05-31 18:42:33 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'admin.auto-commit-settings',
|
|
|
|
|
icon: 'settings_backup_restore',
|
|
|
|
|
path: '/settings/auto-commit'
|
2021-04-29 16:55:05 +03:00
|
|
|
}
|
|
|
|
|
]
|
2019-08-09 19:13:18 +03:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
return homeSections;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-20 19:47:26 +02:00
|
|
|
private buildCustomerUserMenu(authState: AuthState): Array<MenuSection> {
|
2019-08-09 19:13:18 +03:00
|
|
|
const sections: Array<MenuSection> = [];
|
|
|
|
|
sections.push(
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2019-08-09 19:13:18 +03:00
|
|
|
name: 'home.home',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/home',
|
|
|
|
|
icon: 'home'
|
2019-08-12 19:34:23 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'alarm.alarms',
|
2019-08-12 19:34:23 +03:00
|
|
|
type: 'link',
|
2023-02-13 19:09:05 +02:00
|
|
|
path: '/alarms',
|
|
|
|
|
icon: 'notifications'
|
2019-08-12 19:34:23 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'dashboard.dashboards',
|
2019-08-12 19:34:23 +03:00
|
|
|
type: 'link',
|
2023-02-13 19:09:05 +02:00
|
|
|
path: '/dashboards',
|
|
|
|
|
icon: 'dashboards'
|
2019-08-12 19:34:23 +03:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-15 12:20:19 +03:00
|
|
|
id: guid(),
|
2023-02-13 19:09:05 +02:00
|
|
|
name: 'entity.entities',
|
|
|
|
|
type: 'toggle',
|
|
|
|
|
path: '/entities',
|
|
|
|
|
height: '120px',
|
|
|
|
|
icon: 'category',
|
|
|
|
|
pages: [
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'device.devices',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/entities/devices',
|
|
|
|
|
icon: 'devices_other'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'asset.assets',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/entities/assets',
|
|
|
|
|
icon: 'domain'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'entity-view.entity-views',
|
|
|
|
|
type: 'link',
|
|
|
|
|
path: '/entities/entityViews',
|
|
|
|
|
icon: 'view_quilt'
|
|
|
|
|
}
|
|
|
|
|
]
|
2020-12-21 19:14:22 +02:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
if (authState.edgesSupportEnabled) {
|
|
|
|
|
sections.push(
|
|
|
|
|
{
|
|
|
|
|
id: guid(),
|
|
|
|
|
name: 'edge.edge-instances',
|
|
|
|
|
type: 'link',
|
2023-02-13 19:09:05 +02:00
|
|
|
path: '/edgeManagement/instances',
|
2020-12-21 19:14:22 +02:00
|
|
|
icon: 'router'
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2019-08-09 19:13:18 +03:00
|
|
|
return sections;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-20 19:47:26 +02:00
|
|
|
private buildCustomerUserHome(authState: AuthState): Array<HomeSection> {
|
2020-12-21 19:14:22 +02:00
|
|
|
const homeSections: Array<HomeSection> = [];
|
|
|
|
|
homeSections.push(
|
2019-08-12 19:34:23 +03:00
|
|
|
{
|
|
|
|
|
name: 'asset.view-assets',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'asset.assets',
|
|
|
|
|
icon: 'domain',
|
|
|
|
|
path: '/assets'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'device.view-devices',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'device.devices',
|
|
|
|
|
icon: 'devices_other',
|
|
|
|
|
path: '/devices'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'entity-view.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'entity-view.entity-views',
|
|
|
|
|
icon: 'view_quilt',
|
|
|
|
|
path: '/entityViews'
|
|
|
|
|
}
|
|
|
|
|
]
|
2020-12-21 19:14:22 +02:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
if (authState.edgesSupportEnabled) {
|
|
|
|
|
homeSections.push(
|
|
|
|
|
{
|
|
|
|
|
name: 'edge.management',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'edge.edge-instances',
|
2021-05-26 21:02:35 +03:00
|
|
|
icon: 'settings_input_antenna',
|
|
|
|
|
path: '/edgeInstances'
|
2020-12-21 19:14:22 +02:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
homeSections.push(
|
2019-08-12 19:34:23 +03:00
|
|
|
{
|
|
|
|
|
name: 'dashboard.view-dashboards',
|
|
|
|
|
places: [
|
|
|
|
|
{
|
|
|
|
|
name: 'dashboard.dashboards',
|
|
|
|
|
icon: 'dashboard',
|
|
|
|
|
path: '/dashboards'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2020-12-21 19:14:22 +02:00
|
|
|
);
|
2019-08-09 19:13:18 +03:00
|
|
|
return homeSections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public menuSections(): Observable<Array<MenuSection>> {
|
|
|
|
|
return this.menuSections$;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public homeSections(): Observable<Array<HomeSection>> {
|
|
|
|
|
return this.homeSections$;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|