From e393f3b51da85872770af3d10378a76a20f8e548 Mon Sep 17 00:00:00 2001 From: Artem Babak Date: Mon, 19 Oct 2020 12:37:47 +0300 Subject: [PATCH] Fixed Rule Chains page: openRuleChain(). Refactored getRuleNodeComponents() --- ui-ngx/src/app/core/http/component-descriptor.service.ts | 5 ++--- ui-ngx/src/app/core/http/rule-chain.service.ts | 8 ++++---- .../home/pages/rulechain/rulechain-routing.module.ts | 3 +-- .../pages/rulechain/rulechains-table-config.resolver.ts | 4 ++-- 4 files changed, 9 insertions(+), 11 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 d024778f15..e0e5aa2eed 100644 --- a/ui-ngx/src/app/core/http/component-descriptor.service.ts +++ b/ui-ngx/src/app/core/http/component-descriptor.service.ts @@ -53,8 +53,7 @@ export class ComponentDescriptorService { } } - public getComponentDescriptorsByTypes(componentTypes: Array, type: string, - config?: RequestConfig): Observable> { + public getComponentDescriptorsByTypes(componentTypes: Array, config?: RequestConfig): Observable> { let result: ComponentDescriptor[] = []; for (let i = componentTypes.length - 1; i >= 0; i--) { const componentType = componentTypes[i]; @@ -67,7 +66,7 @@ export class ComponentDescriptorService { if (!componentTypes.length) { return of(result); } else { - return this.http.get>(`/api/components/${type}?componentTypes=${componentTypes.join(',')}`, + return this.http.get>(`/api/components/?componentTypes=${componentTypes.join(',')}`, defaultHttpOptionsFromConfig(config)).pipe( map((componentDescriptors) => { componentDescriptors.forEach((componentDescriptor) => { 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 06c67b0134..2787b5b53a 100644 --- a/ui-ngx/src/app/core/http/rule-chain.service.ts +++ b/ui-ngx/src/app/core/http/rule-chain.service.ts @@ -117,12 +117,12 @@ export class RuleChainService { ); } - public getRuleNodeComponents(ruleNodeConfigResourcesModulesMap: {[key: string]: any}, type: string, config?: RequestConfig): + public getRuleNodeComponents(ruleNodeConfigResourcesModulesMap: {[key: string]: any}, config?: RequestConfig): Observable> { if (this.ruleNodeComponents) { return of(this.ruleNodeComponents); } else { - return this.loadRuleNodeComponents(type, config).pipe( + return this.loadRuleNodeComponents(config).pipe( mergeMap((components) => { return this.resolveRuleNodeComponentsUiResources(components, ruleNodeConfigResourcesModulesMap).pipe( map((ruleNodeComponents) => { @@ -205,8 +205,8 @@ export class RuleChainService { } } - private loadRuleNodeComponents(type: string, config?: RequestConfig): Observable> { - return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, type, config).pipe( + private loadRuleNodeComponents(config?: RequestConfig): Observable> { + return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, 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 41fa0db079..d08d114d31 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,8 +71,7 @@ export class RuleNodeComponentsResolver implements Resolve> { - const type = route.data.type; - return this.ruleChainService.getRuleNodeComponents(this.modulesMap, type); + return this.ruleChainService.getRuleNodeComponents(this.modulesMap); } } 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 b4ff120e6a..4b36f774da 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 @@ -269,7 +269,7 @@ export class RuleChainsTableConfigResolver implements Resolve { if (ruleChainImport) { this.itembuffer.storeRuleChainImport(ruleChainImport); - this.router.navigateByUrl(`ruleChains/ruleChain/import`); + this.router.navigateByUrl(`${this.router.routerState.snapshot.url}/ruleChain/import`); } }); } @@ -278,7 +278,7 @@ export class RuleChainsTableConfigResolver implements Resolve