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 2787b5b53a..ec6ab24976 100644 --- a/ui-ngx/src/app/core/http/rule-chain.service.ts +++ b/ui-ngx/src/app/core/http/rule-chain.service.ts @@ -323,9 +323,8 @@ export class RuleChainService { return this.http.delete(`/api/ruleChain/${ruleChainId}/defaultEdge`, defaultHttpOptionsFromConfig(config)); } - public getDefaultEdgeRuleChains(config?: RequestConfig): Observable> { - return this.http.get>(`/api/ruleChain/defaultEdgeRuleChains`, - defaultHttpOptionsFromConfig(config)); + public getDefaultEdgeRuleChains(config?: RequestConfig): Observable> { + return this.http.get>(`/api/ruleChain/defaultEdgeRuleChains`, defaultHttpOptionsFromConfig(config)); } } 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 4b36f774da..473cc58fc5 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 @@ -29,7 +29,7 @@ import { TranslateService } from '@ngx-translate/core'; import { DatePipe } from '@angular/common'; import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models'; import { EntityAction } from '@home/models/entity/entity-component.models'; -import {RuleChain, RuleChainType, ruleChainType} from '@shared/models/rule-chain.models'; +import { RuleChain, ruleChainType} from '@shared/models/rule-chain.models'; import { RuleChainService } from '@core/http/rule-chain.service'; import { RuleChainComponent } from '@modules/home/pages/rulechain/rulechain.component'; import { DialogService } from '@core/services/dialog.service'; @@ -141,7 +141,6 @@ export class RuleChainsTableConfigResolver implements Resolve this.fetchRuleChains(pageLink, ruleChainType.core); + this.config.entitiesFetchFunction = pageLink => this.fetchRuleChains(pageLink); } else if (ruleChainScope === 'edges') { this.config.tableTitle = this.translate.instant('rulechain.edge-rulechains'); - this.config.entitiesFetchFunction = pageLink => this.fetchRuleChains(pageLink, ruleChainType.edge); + this.config.entitiesFetchFunction = pageLink => this.fetchEdgeRuleChains(pageLink); } else if (ruleChainScope === 'edge') { if (this.edgeId) { this.edgeService.getEdge(this.edgeId) @@ -238,13 +237,13 @@ export class RuleChainsTableConfigResolver implements Resolve true, + isEnabled: (entity) => this.isNonDefaultEdgeRuleChain(entity), onAction: ($event, entity) => this.setDefaultEdgeRuleChain($event, entity) }, { name: this.translate.instant('rulechain.remove-default-edge'), icon: 'bookmark', - isEnabled: () => true, + isEnabled: (entity) => this.isDefaultEdgeRuleChain(entity), onAction: ($event, entity) => this.removeDefaultEdgeRuleChain($event, entity) } ) @@ -481,8 +480,32 @@ export class RuleChainsTableConfigResolver implements Resolve = []; + this.ruleChainService.getDefaultEdgeRuleChains().pipe( + map(ruleChains => + ruleChains.map(ruleChain => + defaultEdgeRuleChainIds.push(ruleChain.id.id))) + ).subscribe(); + return this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge).pipe( + map((response) => { + response.data.map(ruleChain => + ruleChain.isDefault = defaultEdgeRuleChainIds.some(id => ruleChain.id.id.includes(id))); + return response; + }) + ) } }