From 2ba04f868cfccf220c7bc060c2eaa5c049bc9f78 Mon Sep 17 00:00:00 2001 From: Artem Babak Date: Mon, 21 Dec 2020 11:46:02 +0200 Subject: [PATCH 1/3] Added edge ruleNode scope --- .../core/http/component-descriptor.service.ts | 16 +++++++++------- ui-ngx/src/app/core/http/rule-chain.service.ts | 8 +++++--- .../src/assets/locale/locale.constant-en_US.json | 5 +++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ui-ngx/src/app/core/http/component-descriptor.service.ts b/ui-ngx/src/app/core/http/component-descriptor.service.ts index 3ec35cad81..a121e343de 100644 --- a/ui-ngx/src/app/core/http/component-descriptor.service.ts +++ b/ui-ngx/src/app/core/http/component-descriptor.service.ts @@ -54,14 +54,16 @@ export class ComponentDescriptorService { } } - public getComponentDescriptorsByTypes(componentTypes: Array, ruleChainType: RuleChainType, config?: RequestConfig): Observable> { + public getComponentDescriptorsByTypes(componentTypes: Array, ruleChainType: RuleChainType, ruleNodeScope: RuleChainType, config?: RequestConfig): Observable> { let result: ComponentDescriptor[] = []; - for (let i = componentTypes.length - 1; i >= 0; i--) { - const componentType = componentTypes[i]; - const componentDescriptors = this.componentsByType.get(componentType); - if (componentDescriptors) { - result = result.concat(componentDescriptors); - componentTypes.splice(i, 1); + if (ruleNodeScope === ruleChainType) { + for (let i = componentTypes.length - 1; i >= 0; i--) { + const componentType = componentTypes[i]; + const componentDescriptors = this.componentsByType.get(componentType); + if (componentDescriptors) { + result = result.concat(componentDescriptors); + componentTypes.splice(i, 1); + } } } if (!componentTypes.length) { diff --git a/ui-ngx/src/app/core/http/rule-chain.service.ts b/ui-ngx/src/app/core/http/rule-chain.service.ts index e4e5015577..7b11c1cbf0 100644 --- a/ui-ngx/src/app/core/http/rule-chain.service.ts +++ b/ui-ngx/src/app/core/http/rule-chain.service.ts @@ -53,6 +53,7 @@ export class RuleChainService { private ruleNodeComponents: Array; private ruleNodeConfigFactories: {[directive: string]: ComponentFactory} = {}; + private ruleNodeScope: RuleChainType; constructor( private http: HttpClient, @@ -120,13 +121,14 @@ export class RuleChainService { public getRuleNodeComponents(ruleNodeConfigResourcesModulesMap: {[key: string]: any}, ruleChainType: RuleChainType, config?: RequestConfig): Observable> { - if (this.ruleNodeComponents) { + if (this.ruleNodeComponents && this.ruleNodeScope == ruleChainType) { return of(this.ruleNodeComponents); } else { - return this.loadRuleNodeComponents(ruleChainType, config).pipe( + return this.loadRuleNodeComponents(ruleChainType, config).pipe( mergeMap((components) => { return this.resolveRuleNodeComponentsUiResources(components, ruleNodeConfigResourcesModulesMap).pipe( map((ruleNodeComponents) => { + this.ruleNodeScope = ruleChainType; this.ruleNodeComponents = ruleNodeComponents; this.ruleNodeComponents.push(ruleChainNodeComponent); this.ruleNodeComponents.sort( @@ -207,7 +209,7 @@ export class RuleChainService { } private loadRuleNodeComponents(ruleChainType: RuleChainType, config?: RequestConfig): Observable> { - return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, ruleChainType, config).pipe( + return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, ruleChainType, this.ruleNodeScope, config).pipe( map((components) => { const ruleNodeComponents: RuleNodeComponentDescriptor[] = []; components.forEach((component) => { diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 099bfa7334..ae6c1b48ce 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -414,7 +414,8 @@ "unassign-asset-from-edge-text": "After the confirmation the asset will be unassigned and won't be accessible by the edge.", "unassign-assets-from-edge-action-title": "Unassign { count, plural, 1 {1 asset} other {# assets} } from edge", "unassign-assets-from-edge-title": "Are you sure you want to unassign { count, plural, 1 {1 asset} other {# assets} }?", - "unassign-assets-from-edge-text": "After the confirmation all selected assets will be unassigned and won't be accessible by the edge." + "unassign-assets-from-edge-text": "After the confirmation all selected assets will be unassigned and won't be accessible by the edge.", + "selected-assets": "{ count, plural, 1 {1 asset} other {# assets} } selected" }, "attribute": { "attributes": "Attributes", @@ -2044,7 +2045,7 @@ "edge-rulechain": "Edge Rule chain", "core-rulechains": "Core Rule chains", "unassign-rulechain-from-edge-text": "After the confirmation the rulechain will be unassigned and won't be accessible by the edge.", - "unassign-rulechains-from-edge-title": "Unassign { count, plural, 1 {1 rulechain} other {# rulechains} } from edge", + "unassign-rulechains-from-edge-title": "Are you sure you want to unassign { count, plural, 1 {1 rulechain} other {# rulechains} }?", "unassign-rulechains-from-edge-text": "After the confirmation all selected rulechains will be unassigned and won't be accessible by the edge.", "assign-rulechain-to-edge-title": "Assign Rule Chain(s) To Edge", "assign-rulechain-to-edge-text": "Please select the rulechains to assign to the edge", From 4b5ade990e119307ff2ec55f36b3c3f472b9e840 Mon Sep 17 00:00:00 2001 From: Artem Babak Date: Mon, 21 Dec 2020 13:28:53 +0200 Subject: [PATCH 2/3] Added Manage edge for customers and filter by type --- .../app/modules/home/pages/customer/customer.component.html | 6 ++++++ .../home/pages/customer/customers-table-config.resolver.ts | 3 +++ .../pages/dashboard/dashboards-table-config.resolver.ts | 2 +- .../modules/home/pages/edge/edges-table-config.resolver.ts | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/customer/customer.component.html b/ui-ngx/src/app/modules/home/pages/customer/customer.component.html index bb75d81fbd..750be237c3 100644 --- a/ui-ngx/src/app/modules/home/pages/customer/customer.component.html +++ b/ui-ngx/src/app/modules/home/pages/customer/customer.component.html @@ -40,6 +40,12 @@ [fxShow]="!isEdit"> {{'customer.manage-dashboards' | translate }} +