Updated enum to be uppercase. Use RuleChainType in the rule chain service
This commit is contained in:
parent
d8de53c186
commit
dd879efad6
@ -320,11 +320,11 @@ export class EntityService {
|
||||
break;
|
||||
case EntityType.RULE_CHAIN:
|
||||
pageLink.sortOrder.property = 'name';
|
||||
if (subType) {
|
||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, subType, config);
|
||||
if (RuleChainType[subType]) {
|
||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, subType as RuleChainType, config);
|
||||
} else {
|
||||
// safe fallback to default core type
|
||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, RuleChainType.core, config);
|
||||
entitiesObservable = this.ruleChainService.getRuleChains(pageLink, RuleChainType.CORE, config);
|
||||
}
|
||||
break;
|
||||
case EntityType.DASHBOARD:
|
||||
|
||||
@ -26,9 +26,9 @@ import {
|
||||
RuleChainConnectionInfo,
|
||||
RuleChainMetaData,
|
||||
ruleChainNodeComponent,
|
||||
RuleChainType,
|
||||
ruleNodeTypeComponentTypes,
|
||||
unknownNodeComponent,
|
||||
RuleChainType
|
||||
unknownNodeComponent
|
||||
} from '@shared/models/rule-chain.models';
|
||||
import { ComponentDescriptorService } from './component-descriptor.service';
|
||||
import {
|
||||
@ -62,7 +62,7 @@ export class RuleChainService {
|
||||
private translate: TranslateService
|
||||
) { }
|
||||
|
||||
public getRuleChains(pageLink: PageLink, type: string, config?: RequestConfig): Observable<PageData<RuleChain>> {
|
||||
public getRuleChains(pageLink: PageLink, type: RuleChainType = RuleChainType.CORE, config?: RequestConfig): Observable<PageData<RuleChain>> {
|
||||
return this.http.get<PageData<RuleChain>>(`/api/ruleChains${pageLink.toQuery()}&type=${type}`,
|
||||
defaultHttpOptionsFromConfig(config));
|
||||
}
|
||||
@ -151,7 +151,7 @@ export class RuleChainService {
|
||||
return this.ruleNodeConfigFactories[directive];
|
||||
}
|
||||
|
||||
public getRuleNodeComponentByClazz(ruleChainType: RuleChainType = RuleChainType.core, clazz: string): RuleNodeComponentDescriptor {
|
||||
public getRuleNodeComponentByClazz(ruleChainType: RuleChainType = RuleChainType.CORE, clazz: string): RuleNodeComponentDescriptor {
|
||||
const found = this.ruleNodeComponentsMap.get(ruleChainType).filter((component) => component.clazz === clazz);
|
||||
if (found && found.length) {
|
||||
return found[0];
|
||||
|
||||
@ -469,7 +469,7 @@ export class ImportExportService {
|
||||
return false;
|
||||
}
|
||||
if (isUndefined(ruleChainImport.ruleChain.type)) {
|
||||
ruleChainImport.ruleChain.type = RuleChainType.core;
|
||||
ruleChainImport.ruleChain.type = RuleChainType.CORE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ export class RuleChainAutocompleteComponent implements ControlValueAccessor, OnI
|
||||
this.searchText = searchText;
|
||||
// voba: at the moment device profiles are not supported by edge, so 'core' hardcoded
|
||||
return this.entityService.getEntitiesByNameFilter(EntityType.RULE_CHAIN, searchText,
|
||||
50, RuleChainType.core, {ignoreLoading: true});
|
||||
50, RuleChainType.CORE, {ignoreLoading: true});
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
||||
@ -85,7 +85,7 @@ export class AddEntitiesToEdgeDialogComponent extends
|
||||
case EntityType.RULE_CHAIN:
|
||||
this.assignToEdgeTitle = 'rulechain.assign-rulechain-to-edge-title';
|
||||
this.assignToEdgeText = 'rulechain.assign-rulechain-to-edge-text';
|
||||
this.subType = RuleChainType.edge;
|
||||
this.subType = RuleChainType.EDGE;
|
||||
break;
|
||||
case EntityType.ASSET:
|
||||
this.assignToEdgeTitle = 'asset.assign-asset-to-edge-title';
|
||||
|
||||
@ -189,7 +189,7 @@ const routes: Routes = [
|
||||
auth: [Authority.TENANT_ADMIN],
|
||||
title: 'rulechain.edge-rulechain',
|
||||
import: false,
|
||||
ruleChainType: RuleChainType.edge
|
||||
ruleChainType: RuleChainType.EDGE
|
||||
},
|
||||
resolve: {
|
||||
ruleChain: RuleChainResolver,
|
||||
@ -210,7 +210,7 @@ const routes: Routes = [
|
||||
auth: [Authority.TENANT_ADMIN],
|
||||
title: 'rulechain.edge-rulechain',
|
||||
import: true,
|
||||
ruleChainType: RuleChainType.edge
|
||||
ruleChainType: RuleChainType.EDGE
|
||||
},
|
||||
resolve: {
|
||||
ruleNodeComponents: RuleNodeComponentsResolver
|
||||
|
||||
@ -151,7 +151,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
||||
$event.stopPropagation();
|
||||
}
|
||||
if (this.ruleNode.targetRuleChainId) {
|
||||
if (this.ruleChainType === RuleChainType.edge) {
|
||||
if (this.ruleChainType === RuleChainType.EDGE) {
|
||||
this.router.navigateByUrl(`/edges/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
||||
} else {
|
||||
this.router.navigateByUrl(`/ruleChains/${this.ruleNode.targetRuleChainId}`);
|
||||
|
||||
@ -1286,7 +1286,7 @@ export class RuleChainPageComponent extends PageComponent
|
||||
if (this.isImport) {
|
||||
this.isDirtyValue = false;
|
||||
this.isImport = false;
|
||||
if (this.ruleChainType !== RuleChainType.edge) {
|
||||
if (this.ruleChainType !== RuleChainType.EDGE) {
|
||||
this.router.navigateByUrl(`ruleChains/${this.ruleChain.id.id}`);
|
||||
} else {
|
||||
this.router.navigateByUrl(`edges/ruleChains/${this.ruleChain.id.id}`);
|
||||
|
||||
@ -144,7 +144,7 @@ const routes: Routes = [
|
||||
auth: [Authority.TENANT_ADMIN],
|
||||
title: 'rulechain.rulechain',
|
||||
import: false,
|
||||
ruleChainType: RuleChainType.core
|
||||
ruleChainType: RuleChainType.CORE
|
||||
},
|
||||
resolve: {
|
||||
ruleChain: RuleChainResolver,
|
||||
@ -165,7 +165,7 @@ const routes: Routes = [
|
||||
auth: [Authority.TENANT_ADMIN],
|
||||
title: 'rulechain.rulechain',
|
||||
import: true,
|
||||
ruleChainType: RuleChainType.core
|
||||
ruleChainType: RuleChainType.CORE
|
||||
},
|
||||
resolve: {
|
||||
ruleNodeComponents: RuleNodeComponentsResolver
|
||||
|
||||
@ -272,7 +272,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
const expectedRuleChainType = this.config.componentsData.ruleChainScope === 'tenant' ? RuleChainType.core : RuleChainType.edge;
|
||||
const expectedRuleChainType = this.config.componentsData.ruleChainScope === 'tenant' ? RuleChainType.CORE : RuleChainType.EDGE;
|
||||
this.importExport.importRuleChain(expectedRuleChainType).subscribe((ruleChainImport) => {
|
||||
if (ruleChainImport) {
|
||||
this.itembuffer.storeRuleChainImport(ruleChainImport);
|
||||
@ -299,12 +299,12 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
saveRuleChain(ruleChain: RuleChain) {
|
||||
if (isUndefined(ruleChain.type)) {
|
||||
if (this.config.componentsData.ruleChainScope == 'tenant') {
|
||||
ruleChain.type = RuleChainType.core;
|
||||
ruleChain.type = RuleChainType.CORE;
|
||||
} else if (this.config.componentsData.ruleChainScope == 'edges') {
|
||||
ruleChain.type = RuleChainType.edge;
|
||||
ruleChain.type = RuleChainType.EDGE;
|
||||
} else {
|
||||
// safe fallback to default core type
|
||||
ruleChain.type = RuleChainType.core;
|
||||
ruleChain.type = RuleChainType.CORE;
|
||||
}
|
||||
}
|
||||
return this.ruleChainService.saveRuleChain(ruleChain);
|
||||
@ -550,7 +550,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
}
|
||||
|
||||
fetchRuleChains(pageLink: PageLink) {
|
||||
return this.ruleChainService.getRuleChains(pageLink, RuleChainType.core);
|
||||
return this.ruleChainService.getRuleChains(pageLink, RuleChainType.CORE);
|
||||
}
|
||||
|
||||
fetchEdgeRuleChains(pageLink: PageLink) {
|
||||
@ -558,7 +558,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
|
||||
mergeMap((ruleChains) => {
|
||||
this.config.componentsData.autoAssignToEdgeRuleChainIds = [];
|
||||
ruleChains.map(ruleChain => this.config.componentsData.autoAssignToEdgeRuleChainIds.push(ruleChain.id.id));
|
||||
return this.ruleChainService.getRuleChains(pageLink, RuleChainType.edge);
|
||||
return this.ruleChainService.getRuleChains(pageLink, RuleChainType.EDGE);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ export class RuleNodeComponent extends FcNodeComponent implements OnInit {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
if (node.targetRuleChainId) {
|
||||
if (node.ruleChainType === RuleChainType.edge) {
|
||||
if (node.ruleChainType === RuleChainType.EDGE) {
|
||||
this.router.navigateByUrl(`/edges/ruleChains/${node.targetRuleChainId}`);
|
||||
} else {
|
||||
this.router.navigateByUrl(`/ruleChains/${node.targetRuleChainId}`);
|
||||
|
||||
@ -114,6 +114,6 @@ export const inputNodeComponent: RuleNodeComponentDescriptor = {
|
||||
};
|
||||
|
||||
export enum RuleChainType {
|
||||
core = 'CORE',
|
||||
edge = 'EDGE'
|
||||
CORE = 'CORE',
|
||||
EDGE = 'EDGE'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user