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