From ac94a063ac12237ee74a3189da0f567d6953c0e5 Mon Sep 17 00:00:00 2001 From: Artem Babak Date: Mon, 26 Oct 2020 20:16:44 +0200 Subject: [PATCH] Fixed fetch edge rule chains for 'rulechain' Node --- ui-ngx/src/app/core/http/component-descriptor.service.ts | 4 ++-- ui-ngx/src/app/core/http/entity.service.ts | 2 +- ui-ngx/src/app/core/http/rule-chain.service.ts | 9 ++++----- .../home/pages/rulechain/rulechain-routing.module.ts | 3 ++- 4 files changed, 9 insertions(+), 9 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 e0e5aa2eed..875e0d5037 100644 --- a/ui-ngx/src/app/core/http/component-descriptor.service.ts +++ b/ui-ngx/src/app/core/http/component-descriptor.service.ts @@ -53,7 +53,7 @@ export class ComponentDescriptorService { } } - public getComponentDescriptorsByTypes(componentTypes: Array, config?: RequestConfig): Observable> { + public getComponentDescriptorsByTypes(componentTypes: Array, ruleChainType: string, config?: RequestConfig): Observable> { let result: ComponentDescriptor[] = []; for (let i = componentTypes.length - 1; i >= 0; i--) { const componentType = componentTypes[i]; @@ -66,7 +66,7 @@ export class ComponentDescriptorService { if (!componentTypes.length) { return of(result); } else { - return this.http.get>(`/api/components/?componentTypes=${componentTypes.join(',')}`, + return this.http.get>(`/api/components?componentTypes=${componentTypes.join(',')}&ruleChainType=${ruleChainType}`, defaultHttpOptionsFromConfig(config)).pipe( map((componentDescriptors) => { componentDescriptors.forEach((componentDescriptor) => { diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index af0d5a6fe6..0d077fea45 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -323,7 +323,7 @@ export class EntityService { break; case EntityType.RULE_CHAIN: pageLink.sortOrder.property = 'name'; - if (this.route.url.includes('edges')) { + if (this.route.url.includes('edge')) { entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge, config); } else { entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.core, config); 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 c0fd7c4d30..7bdbead5f3 100644 --- a/ui-ngx/src/app/core/http/rule-chain.service.ts +++ b/ui-ngx/src/app/core/http/rule-chain.service.ts @@ -25,7 +25,6 @@ import { RuleChain, RuleChainConnectionInfo, RuleChainMetaData, - ruleChainType, ruleChainNodeComponent, ruleNodeTypeComponentTypes, unknownNodeComponent @@ -117,12 +116,12 @@ export class RuleChainService { ); } - public getRuleNodeComponents(ruleNodeConfigResourcesModulesMap: {[key: string]: any}, config?: RequestConfig): + public getRuleNodeComponents(ruleNodeConfigResourcesModulesMap: {[key: string]: any}, ruleChainType: string, config?: RequestConfig): Observable> { if (this.ruleNodeComponents) { return of(this.ruleNodeComponents); } else { - return this.loadRuleNodeComponents(config).pipe( + return this.loadRuleNodeComponents(ruleChainType, config).pipe( mergeMap((components) => { return this.resolveRuleNodeComponentsUiResources(components, ruleNodeConfigResourcesModulesMap).pipe( map((ruleNodeComponents) => { @@ -205,8 +204,8 @@ export class RuleChainService { } } - private loadRuleNodeComponents(config?: RequestConfig): Observable> { - return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, config).pipe( + private loadRuleNodeComponents(ruleChainType: string, config?: RequestConfig): Observable> { + return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, ruleChainType, config).pipe( map((components) => { const ruleNodeComponents: RuleNodeComponentDescriptor[] = []; components.forEach((component) => { 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 d08d114d31..e213f2cc7b 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 @@ -71,7 +71,8 @@ export class RuleNodeComponentsResolver implements Resolve> { - return this.ruleChainService.getRuleNodeComponents(this.modulesMap); + const ruleChainType = route.data.type; + return this.ruleChainService.getRuleNodeComponents(this.modulesMap, ruleChainType); } }