Browse Source

Added edge ruleNode scope

pull/3811/head
Artem Babak 6 years ago
parent
commit
2ba04f868c
  1. 16
      ui-ngx/src/app/core/http/component-descriptor.service.ts
  2. 8
      ui-ngx/src/app/core/http/rule-chain.service.ts
  3. 5
      ui-ngx/src/assets/locale/locale.constant-en_US.json

16
ui-ngx/src/app/core/http/component-descriptor.service.ts

@ -54,14 +54,16 @@ export class ComponentDescriptorService {
}
}
public getComponentDescriptorsByTypes(componentTypes: Array<ComponentType>, ruleChainType: RuleChainType, config?: RequestConfig): Observable<Array<ComponentDescriptor>> {
public getComponentDescriptorsByTypes(componentTypes: Array<ComponentType>, ruleChainType: RuleChainType, ruleNodeScope: RuleChainType, config?: RequestConfig): Observable<Array<ComponentDescriptor>> {
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) {

8
ui-ngx/src/app/core/http/rule-chain.service.ts

@ -53,6 +53,7 @@ export class RuleChainService {
private ruleNodeComponents: Array<RuleNodeComponentDescriptor>;
private ruleNodeConfigFactories: {[directive: string]: ComponentFactory<IRuleNodeConfigurationComponent>} = {};
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<Array<RuleNodeComponentDescriptor>> {
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<Array<RuleNodeComponentDescriptor>> {
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) => {

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

Loading…
Cancel
Save