Browse Source

Fixed Rule Chains page: openRuleChain(). Refactored getRuleNodeComponents()

pull/3811/head
Artem Babak 6 years ago
parent
commit
e393f3b51d
  1. 5
      ui-ngx/src/app/core/http/component-descriptor.service.ts
  2. 8
      ui-ngx/src/app/core/http/rule-chain.service.ts
  3. 3
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts
  4. 4
      ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts

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

@ -53,8 +53,7 @@ export class ComponentDescriptorService {
}
}
public getComponentDescriptorsByTypes(componentTypes: Array<ComponentType>, type: string,
config?: RequestConfig): Observable<Array<ComponentDescriptor>> {
public getComponentDescriptorsByTypes(componentTypes: Array<ComponentType>, config?: RequestConfig): Observable<Array<ComponentDescriptor>> {
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<Array<ComponentDescriptor>>(`/api/components/${type}?componentTypes=${componentTypes.join(',')}`,
return this.http.get<Array<ComponentDescriptor>>(`/api/components/?componentTypes=${componentTypes.join(',')}`,
defaultHttpOptionsFromConfig(config)).pipe(
map((componentDescriptors) => {
componentDescriptors.forEach((componentDescriptor) => {

8
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<Array<RuleNodeComponentDescriptor>> {
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<Array<RuleNodeComponentDescriptor>> {
return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, type, config).pipe(
private loadRuleNodeComponents(config?: RequestConfig): Observable<Array<RuleNodeComponentDescriptor>> {
return this.componentDescriptorService.getComponentDescriptorsByTypes(ruleNodeTypeComponentTypes, config).pipe(
map((components) => {
const ruleNodeComponents: RuleNodeComponentDescriptor[] = [];
components.forEach((component) => {

3
ui-ngx/src/app/modules/home/pages/rulechain/rulechain-routing.module.ts

@ -71,8 +71,7 @@ export class RuleNodeComponentsResolver implements Resolve<Array<RuleNodeCompone
}
resolve(route: ActivatedRouteSnapshot): Observable<Array<RuleNodeComponentDescriptor>> {
const type = route.data.type;
return this.ruleChainService.getRuleNodeComponents(this.modulesMap, type);
return this.ruleChainService.getRuleNodeComponents(this.modulesMap);
}
}

4
ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts

@ -269,7 +269,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
this.importExport.importRuleChain().subscribe((ruleChainImport) => {
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<EntityTableConfig<
if ($event) {
$event.stopPropagation();
}
this.router.navigateByUrl(`ruleChains/${ruleChain.id.id}`);
this.router.navigateByUrl(`${this.router.routerState.snapshot.url}/${ruleChain.id.id}`);
}
saveRuleChain(ruleChain: RuleChain) {

Loading…
Cancel
Save