From b63087d53f4157c40a982de1a11cf624132305a9 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 17 Dec 2020 16:00:23 +0200 Subject: [PATCH] Moved edge rule chains and edges to edge management page --- ui-ngx/src/app/core/services/menu.service.ts | 52 +++---- .../home/pages/edge/edge-routing.module.ts | 71 +++++++++ .../rulechain/rulechain-page.component.ts | 12 +- .../rulechain/rulechain-routing.module.ts | 144 ++++-------------- .../rulechains-table-config.resolver.ts | 2 +- 5 files changed, 137 insertions(+), 144 deletions(-) diff --git a/ui-ngx/src/app/core/services/menu.service.ts b/ui-ngx/src/app/core/services/menu.service.ts index 2f4ea559b5..f165dbd30e 100644 --- a/ui-ngx/src/app/core/services/menu.service.ts +++ b/ui-ngx/src/app/core/services/menu.service.ts @@ -228,26 +228,9 @@ export class MenuService { { id: guid(), name: 'rulechain.rulechains', - type: 'toggle', + type: 'link', path: '/ruleChains', - height: '80px', icon: 'settings_ethernet', - pages: [ - { - id: guid(), - name: 'rulechain.core-rulechains', - type: 'link', - path: '/ruleChains/core', - icon: 'settings_ethernet' - }, - { - id: guid(), - name: 'rulechain.edge-rulechains', - type: 'link', - path: '/ruleChains/edge', - icon: 'router' - } - ] }, { id: guid(), @@ -287,10 +270,27 @@ export class MenuService { }, { id: guid(), - name: 'edge.edges', - type: 'link', + name: 'edge.management', + type: 'toggle', path: '/edges', - icon: 'router' + height: '80px', + icon: 'router', + pages: [ + { + id: guid(), + name: 'edge.edges', + type: 'link', + path: '/edges', + icon: 'router' + }, + { + id: guid(), + name: 'rulechain.edge-rulechains', + type: 'link', + path: '/edges/ruleChains', + icon: 'settings_ethernet' + } + ] }, { id: guid(), @@ -335,11 +335,6 @@ export class MenuService { name: 'rulechain.rulechains', icon: 'settings_ethernet', path: '/ruleChains' - }, - { - name: 'rulechain.edge-rulechains', - icon: 'router', - path: '/edgesRuleChains' } ] }, @@ -396,6 +391,11 @@ export class MenuService { name: 'edge.edges', icon: 'router', path: '/edges' + }, + { + name: 'rulechain.edge-rulechains', + icon: 'settings_ethernet', + path: '/edges/ruleChains' } ] }, diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts b/ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts index f9711986f5..adca2e34b1 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts @@ -27,6 +27,15 @@ import { RuleChainsTableConfigResolver } from "@home/pages/rulechain/rulechains- import { DashboardPageComponent } from "@home/pages/dashboard/dashboard-page.component"; import { dashboardBreadcumbLabelFunction, DashboardResolver } from "@home/pages/dashboard/dashboard-routing.module"; import { BreadCrumbConfig } from "@shared/components/breadcrumb"; +import {RuleChainPageComponent} from "@home/pages/rulechain/rulechain-page.component"; +import {ConfirmOnExitGuard} from "@core/guards/confirm-on-exit.guard"; +import {ruleChainType} from "@shared/models/rule-chain.models"; +import { + importRuleChainBreadcumbLabelFunction, + ResolvedRuleChainMetaDataResolver, + ruleChainBreadcumbLabelFunction, RuleChainImportGuard, + RuleChainResolver, RuleNodeComponentsResolver +} from "@home/pages/rulechain/rulechain-routing.module"; const routes: Routes = [ { @@ -147,6 +156,68 @@ const routes: Routes = [ } ] }, + { + path: 'ruleChains', + data: { + breadcrumb: { + label: 'rulechain.edge-rulechains', + icon: 'settings_ethernet' + } + }, + children: [ + { + path: '', + component: EntitiesTableComponent, + data: { + auth: [Authority.TENANT_ADMIN], + title: 'rulechain.edge-rulechains', + ruleChainsType: 'edges' + }, + resolve: { + entitiesTableConfig: RuleChainsTableConfigResolver + } + }, + { + path: ':ruleChainId', + component: RuleChainPageComponent, + canDeactivate: [ConfirmOnExitGuard], + data: { + breadcrumb: { + labelFunction: ruleChainBreadcumbLabelFunction, + icon: 'settings_ethernet' + } as BreadCrumbConfig, + auth: [Authority.TENANT_ADMIN], + title: 'rulechain.edge-rulechain', + import: false, + ruleChainType: ruleChainType.edge + }, + resolve: { + ruleChain: RuleChainResolver, + ruleChainMetaData: ResolvedRuleChainMetaDataResolver, + ruleNodeComponents: RuleNodeComponentsResolver + } + }, + { + path: 'ruleChain/import', + component: RuleChainPageComponent, + canActivate: [RuleChainImportGuard], + canDeactivate: [ConfirmOnExitGuard], + data: { + breadcrumb: { + labelFunction: importRuleChainBreadcumbLabelFunction, + icon: 'settings_ethernet' + } as BreadCrumbConfig, + auth: [Authority.TENANT_ADMIN], + title: 'rulechain.edge-rulechain', + import: true, + ruleChainType: ruleChainType.edge + }, + resolve: { + ruleNodeComponents: RuleNodeComponentsResolver + } + } + ] + } ] }] diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts index 9c235cb8de..80e99a15b1 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts @@ -48,7 +48,8 @@ import { RuleChainConnectionInfo, RuleChainImport, RuleChainMetaData, - ruleChainNodeComponent + ruleChainNodeComponent, + ruleChainType } from '@shared/models/rule-chain.models'; import { FcItemInfo, FlowchartConstants, NgxFlowchartComponent, UserCallbacks } from 'ngx-flowchart/dist/ngx-flowchart'; import { @@ -119,6 +120,8 @@ export class RuleChainPageComponent extends PageComponent isDirtyValue: boolean; isInvalid = false; + ruleChainType: string; + errorTooltips: {[nodeId: string]: JQueryTooltipster.ITooltipsterInstance} = {}; isFullscreen = false; @@ -288,6 +291,7 @@ export class RuleChainPageComponent extends PageComponent private init() { this.initHotKeys(); this.isImport = this.route.snapshot.data.import; + this.ruleChainType = this.route.snapshot.data.ruleChainType; if (this.isImport) { const ruleChainImport: RuleChainImport = this.itembuffer.getRuleChainImport(); this.ruleChain = ruleChainImport.ruleChain; @@ -1281,7 +1285,11 @@ export class RuleChainPageComponent extends PageComponent if (this.isImport) { this.isDirtyValue = false; this.isImport = false; - this.router.navigateByUrl(`ruleChains/${this.route.snapshot.data.ruleChainType.toLowerCase()}/${this.ruleChain.id.id}`); + if (this.ruleChainType !== ruleChainType.edge) { + this.router.navigateByUrl(`ruleChains/${this.ruleChain.id.id}`); + } else { + this.router.navigateByUrl(`edges/ruleChains/${this.ruleChain.id.id}`); + } } else { this.createRuleChainModel(); } diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts index 7c2f3e31ef..c1cf012eea 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts @@ -123,140 +123,54 @@ const routes: Routes = [ children: [ { path: '', - redirectTo: '/ruleChains/core', - pathMatch: 'full', component: EntitiesTableComponent, data: { auth: [Authority.TENANT_ADMIN], - title: 'rulechain.rulechains' + title: 'rulechain.rulechains', + ruleChainsType: 'tenant' }, resolve: { entitiesTableConfig: RuleChainsTableConfigResolver } }, { - path: 'core', + path: ':ruleChainId', + component: RuleChainPageComponent, + canDeactivate: [ConfirmOnExitGuard], data: { breadcrumb: { - label: 'rulechain.core-rulechains', + labelFunction: ruleChainBreadcumbLabelFunction, icon: 'settings_ethernet' - } + } as BreadCrumbConfig, + auth: [Authority.TENANT_ADMIN], + title: 'rulechain.rulechain', + import: false, + ruleChainType: ruleChainType.core }, - children: [ - { - path: '', - component: EntitiesTableComponent, - data: { - auth: [Authority.TENANT_ADMIN], - title: 'rulechain.rulechains', - ruleChainsType: 'tenant' - }, - resolve: { - entitiesTableConfig: RuleChainsTableConfigResolver - }, - }, - { - path: ':ruleChainId', - component: RuleChainPageComponent, - canDeactivate: [ConfirmOnExitGuard], - data: { - breadcrumb: { - labelFunction: ruleChainBreadcumbLabelFunction, - icon: 'settings_ethernet' - } as BreadCrumbConfig, - auth: [Authority.TENANT_ADMIN], - title: 'rulechain.rulechain', - import: false, - ruleChainType: ruleChainType.core - }, - resolve: { - ruleChain: RuleChainResolver, - ruleChainMetaData: ResolvedRuleChainMetaDataResolver, - ruleNodeComponents: RuleNodeComponentsResolver - } - }, - { - path: 'ruleChain/import', - component: RuleChainPageComponent, - canActivate: [RuleChainImportGuard], - canDeactivate: [ConfirmOnExitGuard], - data: { - breadcrumb: { - labelFunction: importRuleChainBreadcumbLabelFunction, - icon: 'settings_ethernet' - } as BreadCrumbConfig, - auth: [Authority.TENANT_ADMIN], - title: 'rulechain.rulechain', - import: true, - ruleChainType: ruleChainType.core - }, - resolve: { - ruleNodeComponents: RuleNodeComponentsResolver - } - } - ] + resolve: { + ruleChain: RuleChainResolver, + ruleChainMetaData: ResolvedRuleChainMetaDataResolver, + ruleNodeComponents: RuleNodeComponentsResolver + } }, { - path: 'edge', + path: 'ruleChain/import', + component: RuleChainPageComponent, + canActivate: [RuleChainImportGuard], + canDeactivate: [ConfirmOnExitGuard], data: { breadcrumb: { - label: 'rulechain.edge-rulechains', + labelFunction: importRuleChainBreadcumbLabelFunction, icon: 'settings_ethernet' - } + } as BreadCrumbConfig, + auth: [Authority.TENANT_ADMIN], + title: 'rulechain.rulechain', + import: true, + ruleChainType: ruleChainType.core }, - children: [ - { - path: '', - component: EntitiesTableComponent, - data: { - auth: [Authority.TENANT_ADMIN], - title: 'rulechain.edge-rulechains', - ruleChainsType: 'edges' - }, - resolve: { - entitiesTableConfig: RuleChainsTableConfigResolver - } - }, - { - path: ':ruleChainId', - component: RuleChainPageComponent, - canDeactivate: [ConfirmOnExitGuard], - data: { - breadcrumb: { - labelFunction: ruleChainBreadcumbLabelFunction, - icon: 'settings_ethernet' - } as BreadCrumbConfig, - auth: [Authority.TENANT_ADMIN], - title: 'rulechain.edge-rulechain', - import: false, - ruleChainType: ruleChainType.edge - }, - resolve: { - ruleChain: RuleChainResolver, - ruleChainMetaData: ResolvedRuleChainMetaDataResolver, - ruleNodeComponents: RuleNodeComponentsResolver - } - }, - { - path: 'ruleChain/import', - component: RuleChainPageComponent, - canActivate: [RuleChainImportGuard], - canDeactivate: [ConfirmOnExitGuard], - data: { - breadcrumb: { - labelFunction: importRuleChainBreadcumbLabelFunction, - icon: 'settings_ethernet' - } as BreadCrumbConfig, - auth: [Authority.TENANT_ADMIN], - title: 'rulechain.edge-rulechain', - import: true, - ruleChainType: ruleChainType.edge - }, - resolve: { - ruleNodeComponents: RuleNodeComponentsResolver - } - } - ] + resolve: { + ruleNodeComponents: RuleNodeComponentsResolver + } } ] } diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts index 36b6f72544..fb15089e02 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts @@ -169,7 +169,7 @@ export class RuleChainsTableConfigResolver implements Resolve this.fetchRuleChains(pageLink); } else if (ruleChainScope === 'edges') { this.config.tableTitle = this.translate.instant('rulechain.edge-rulechains');