Commit bbb625c67f40abec64e52da5ca7a9b8a520c3156

Authored by deaflynx
2 parents 9b27bb2d d8de53c1

Merge voba with new rulechain type

... ... @@ -69,9 +69,9 @@ import {
69 69 } from '@shared/models/query/query.models';
70 70 import { alarmFields } from '@shared/models/alarm.models';
71 71 import { EdgeService } from "@core/http/edge.service";
72   -import { ruleChainType } from "@shared/models/rule-chain.models";
73 72 import { Edge } from '@shared/models/edge.models';
74 73 import { WINDOW } from "@core/services/window.service";
  74 +import { RuleChainType } from "@shared/models/rule-chain.models";
75 75
76 76 @Injectable({
77 77 providedIn: 'root'
... ... @@ -327,7 +327,7 @@ export class EntityService {
327 327 entitiesObservable = this.ruleChainService.getRuleChains(pageLink, subType, config);
328 328 } else {
329 329 // safe fallback to default core type
330   - entitiesObservable = this.ruleChainService.getRuleChains(pageLink, ruleChainType.core, config);
  330 + entitiesObservable = this.ruleChainService.getRuleChains(pageLink, RuleChainType.core, config);
331 331 }
332 332 break;
333 333 case EntityType.DASHBOARD:
... ...
... ... @@ -151,12 +151,8 @@ export class RuleChainService {
151 151 return this.ruleNodeConfigFactories[directive];
152 152 }
153 153
154   - public getRuleNodeComponentByClazz(clazz: string): RuleNodeComponentDescriptor {
155   - let mergedRuleNodeComponents: RuleNodeComponentDescriptor[] = [];
156   - this.ruleNodeComponentsMap.forEach((value: Array<RuleNodeComponentDescriptor>, key: RuleChainType) => {
157   - mergedRuleNodeComponents = mergedRuleNodeComponents.concat(value);
158   - });
159   - const found = mergedRuleNodeComponents.filter((component) => component.clazz === clazz);
  154 + public getRuleNodeComponentByClazz(ruleChainType: RuleChainType = RuleChainType.core, clazz: string): RuleNodeComponentDescriptor {
  155 + const found = this.ruleNodeComponentsMap.get(ruleChainType).filter((component) => component.clazz === clazz);
160 156 if (found && found.length) {
161 157 return found[0];
162 158 } else {
... ...
... ... @@ -331,7 +331,7 @@ export class ItemBufferService {
331 331 const deltaX = x - ruleNodes.originX;
332 332 const deltaY = y - ruleNodes.originY;
333 333 for (const node of ruleNodes.nodes) {
334   - const component = this.ruleChainService.getRuleNodeComponentByClazz(node.componentClazz);
  334 + const component = this.ruleChainService.getRuleNodeComponentByClazz(node.ruleChainType, node.componentClazz);
335 335 if (component) {
336 336 let icon = ruleNodeTypeDescriptors.get(component.type).icon;
337 337 let iconUrl: string = null;
... ...
... ... @@ -56,8 +56,7 @@ import {
56 56 RuleChain,
57 57 RuleChainImport,
58 58 RuleChainMetaData,
59   - RuleChainType,
60   - ruleChainType
  59 + RuleChainType
61 60 } from '@shared/models/rule-chain.models';
62 61 import { RuleChainService } from '@core/http/rule-chain.service';
63 62 import * as JSZip from 'jszip';
... ... @@ -406,9 +405,6 @@ export class ImportExportService {
406 405 public importRuleChain(expectedRuleChainType: RuleChainType): Observable<RuleChainImport> {
407 406 return this.openImportDialog('rulechain.import', 'rulechain.rulechain-file').pipe(
408 407 mergeMap((ruleChainImport: RuleChainImport) => {
409   - if (isUndefined(ruleChainImport.ruleChain.type)) {
410   - ruleChainImport.ruleChain.type = ruleChainType.core;
411   - }
412 408 if (!this.validateImportedRuleChain(ruleChainImport)) {
413 409 this.store.dispatch(new ActionNotificationShow(
414 410 {message: this.translate.instant('rulechain.invalid-rulechain-file-error'),
... ... @@ -472,6 +468,9 @@ export class ImportExportService {
472 468 || isUndefined(ruleChainImport.ruleChain.name)) {
473 469 return false;
474 470 }
  471 + if (isUndefined(ruleChainImport.ruleChain.type)) {
  472 + ruleChainImport.ruleChain.type = RuleChainType.core;
  473 + }
475 474 return true;
476 475 }
477 476
... ...
... ... @@ -29,7 +29,7 @@ import { EntityService } from '@core/http/entity.service';
29 29 import { TruncatePipe } from '@shared/pipe/truncate.pipe';
30 30 import { RuleChainService } from '@core/http/rule-chain.service';
31 31 import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
32   -import { ruleChainType } from '@app/shared/models/rule-chain.models';
  32 +import { RuleChainType } from '@app/shared/models/rule-chain.models';
33 33
34 34 @Component({
35 35 selector: 'tb-rule-chain-autocomplete',
... ... @@ -190,7 +190,7 @@ export class RuleChainAutocompleteComponent implements ControlValueAccessor, OnI
190 190 this.searchText = searchText;
191 191 // voba: at the moment device profiles are not supported by edge, so 'core' hardcoded
192 192 return this.entityService.getEntitiesByNameFilter(EntityType.RULE_CHAIN, searchText,
193   - 50, ruleChainType.core, {ignoreLoading: true});
  193 + 50, RuleChainType.core, {ignoreLoading: true});
194 194 }
195 195
196 196 clear() {
... ...
... ... @@ -30,7 +30,7 @@ import { DashboardService } from '@core/http/dashboard.service';
30 30 import { DialogComponent } from '@shared/components/dialog.component';
31 31 import { Router } from '@angular/router';
32 32 import { RuleChainService } from '@core/http/rule-chain.service';
33   -import { ruleChainType } from '@shared/models/rule-chain.models';
  33 +import { RuleChainType } from '@shared/models/rule-chain.models';
34 34
35 35 export interface AddEntitiesToEdgeDialogData {
36 36 edgeId: string;
... ... @@ -85,7 +85,7 @@ export class AddEntitiesToEdgeDialogComponent extends
85 85 case EntityType.RULE_CHAIN:
86 86 this.assignToEdgeTitle = 'rulechain.assign-rulechain-to-edge-title';
87 87 this.assignToEdgeText = 'rulechain.assign-rulechain-to-edge-text';
88   - this.subType = ruleChainType.edge;
  88 + this.subType = RuleChainType.edge;
89 89 break;
90 90 case EntityType.ASSET:
91 91 this.assignToEdgeTitle = 'asset.assign-asset-to-edge-title';
... ...
... ... @@ -29,7 +29,7 @@ import { dashboardBreadcumbLabelFunction, DashboardResolver } from '@home/pages/
29 29 import { BreadCrumbConfig } from '@shared/components/breadcrumb';
30 30 import { RuleChainPageComponent } from '@home/pages/rulechain/rulechain-page.component';
31 31 import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
32   -import { ruleChainType } from '@shared/models/rule-chain.models';
  32 +import { RuleChainType } from '@shared/models/rule-chain.models';
33 33 import {
34 34 importRuleChainBreadcumbLabelFunction,
35 35 ResolvedRuleChainMetaDataResolver,
... ... @@ -189,7 +189,7 @@ const routes: Routes = [
189 189 auth: [Authority.TENANT_ADMIN],
190 190 title: 'rulechain.edge-rulechain',
191 191 import: false,
192   - ruleChainType: ruleChainType.edge
  192 + ruleChainType: RuleChainType.edge
193 193 },
194 194 resolve: {
195 195 ruleChain: RuleChainResolver,
... ... @@ -210,7 +210,7 @@ const routes: Routes = [
210 210 auth: [Authority.TENANT_ADMIN],
211 211 title: 'rulechain.edge-rulechain',
212 212 import: true,
213   - ruleChainType: ruleChainType.edge
  213 + ruleChainType: RuleChainType.edge
214 214 },
215 215 resolve: {
216 216 ruleNodeComponents: RuleNodeComponentsResolver
... ...
... ... @@ -24,7 +24,7 @@ import { EdgeInfo } from '@shared/models/edge.models';
24 24 import { TranslateService } from '@ngx-translate/core';
25 25 import { NULL_UUID } from '@shared/models/id/has-uuid';
26 26 import { ActionNotificationShow } from '@core/notification/notification.actions';
27   -import { guid, isUndefined } from '@core/utils';
  27 +import { generateSecret, guid } from '@core/utils';
28 28 import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
29 29 import { WINDOW } from '@core/services/window.service';
30 30
... ... @@ -51,7 +51,7 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
51 51 ngOnInit() {
52 52 this.edgeScope = this.entitiesTableConfig.componentsData.edgeScope;
53 53 this.entityForm.patchValue({
54   - cloudEndpoint:this.window.location.origin
  54 + cloudEndpoint: this.window.location.origin
55 55 });
56 56 super.ngOnInit();
57 57 }
... ... @@ -76,8 +76,8 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
76 76 label: [entity ? entity.label : ''],
77 77 cloudEndpoint: [null, [Validators.required]],
78 78 edgeLicenseKey: ['', [Validators.required]],
79   - routingKey: this.fb.control({ value: entity ? entity.routingKey : null, disabled: true }),
80   - secret: this.fb.control({ value: entity ? entity.secret : null, disabled: true }),
  79 + routingKey: this.fb.control({value: entity ? entity.routingKey : null, disabled: true}),
  80 + secret: this.fb.control({value: entity ? entity.secret : null, disabled: true}),
81 81 additionalInfo: this.fb.group(
82 82 {
83 83 description: [entity && entity.additionalInfo ? entity.additionalInfo.description : '']
... ... @@ -107,14 +107,14 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
107 107
108 108 updateFormState() {
109 109 super.updateFormState();
110   - this.entityForm.get('routingKey').disable({ emitEvent: false });
111   - this.entityForm.get('secret').disable({ emitEvent: false });
  110 + this.entityForm.get('routingKey').disable({emitEvent: false});
  111 + this.entityForm.get('secret').disable({emitEvent: false});
112 112 }
113 113
114 114 private checkIsNewEdge(entity: EdgeInfo, form: FormGroup) {
115 115 if (entity && !entity.id) {
116   - form.get('routingKey').patchValue(guid(), { emitEvent: false });
117   - form.get('secret').patchValue(this.generateSecret(20), { emitEvent: false });
  116 + form.get('routingKey').patchValue(guid(), {emitEvent: false});
  117 + form.get('secret').patchValue(generateSecret(20), {emitEvent: false});
118 118 }
119 119 }
120 120
... ... @@ -129,18 +129,6 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
129 129 }));
130 130 }
131 131
132   - generateSecret(length): string {
133   - if (isUndefined(length) || length == null) {
134   - length = 1;
135   - }
136   - var l = length > 10 ? 10 : length;
137   - var str = Math.random().toString(36).substr(2, l);
138   - if (str.length >= length) {
139   - return str;
140   - }
141   - return str.concat(this.generateSecret(length - str.length));
142   - }
143   -
144 132 onEdgeInfoCopied(type: string) {
145 133 const message = type === 'key' ? 'edge.edge-key-copied-message'
146 134 : 'edge.edge-secret-copied-message';
... ...
... ... @@ -210,31 +210,31 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
210 210 name: this.translate.instant('edge.manage-edge-assets'),
211 211 icon: 'domain',
212 212 isEnabled: (entity) => true,
213   - onAction: ($event, entity) => this.openEdgeAssets($event, entity)
  213 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ASSET)
214 214 },
215 215 {
216 216 name: this.translate.instant('edge.manage-edge-devices'),
217 217 icon: 'devices_other',
218 218 isEnabled: (entity) => true,
219   - onAction: ($event, entity) => this.openEdgeDevices($event, entity)
  219 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DEVICE)
220 220 },
221 221 {
222 222 name: this.translate.instant('edge.manage-edge-entity-views'),
223 223 icon: 'view_quilt',
224 224 isEnabled: (entity) => true,
225   - onAction: ($event, entity) => this.openEdgeEntityViews($event, entity)
  225 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ENTITY_VIEW)
226 226 },
227 227 {
228 228 name: this.translate.instant('edge.manage-edge-dashboards'),
229 229 icon: 'dashboard',
230 230 isEnabled: (entity) => true,
231   - onAction: ($event, entity) => this.openEdgeDashboards($event, entity)
  231 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DASHBOARD)
232 232 },
233 233 {
234 234 name: this.translate.instant('edge.manage-edge-rulechains'),
235 235 icon: 'settings_ethernet',
236 236 isEnabled: (entity) => true,
237   - onAction: ($event, entity) => this.openEdgeRuleChains($event, entity)
  237 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.RULE_CHAIN)
238 238 }
239 239 );
240 240 }
... ... @@ -260,25 +260,25 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
260 260 name: this.translate.instant('edge.manage-edge-assets'),
261 261 icon: 'domain',
262 262 isEnabled: (entity) => true,
263   - onAction: ($event, entity) => this.openEdgeAssets($event, entity)
  263 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ASSET)
264 264 },
265 265 {
266 266 name: this.translate.instant('edge.manage-edge-devices'),
267 267 icon: 'devices_other',
268 268 isEnabled: (entity) => true,
269   - onAction: ($event, entity) => this.openEdgeDevices($event, entity)
  269 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DEVICE)
270 270 },
271 271 {
272 272 name: this.translate.instant('edge.manage-edge-entity-views'),
273 273 icon: 'view_quilt',
274 274 isEnabled: (entity) => true,
275   - onAction: ($event, entity) => this.openEdgeEntityViews($event, entity)
  275 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.ENTITY_VIEW)
276 276 },
277 277 {
278 278 name: this.translate.instant('edge.manage-edge-dashboards'),
279 279 icon: 'dashboard',
280 280 isEnabled: (entity) => true,
281   - onAction: ($event, entity) => this.openEdgeDashboards($event, entity)
  281 + onAction: ($event, entity) => this.openEdgeEntitiesByType($event, entity, EntityType.DASHBOARD)
282 282 }
283 283 );
284 284 }
... ... @@ -392,39 +392,32 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
392 392 );
393 393 }
394 394
395   - openEdgeDashboards($event, edge) {
  395 + openEdgeEntitiesByType($event: Event, edge: Edge, entityType: EntityType) {
396 396 if ($event) {
397 397 $event.stopPropagation();
398 398 }
399   - this.router.navigateByUrl(`edges/${edge.id.id}/dashboards`);
400   - }
401   -
402   - openEdgeRuleChains($event, edge) {
403   - if ($event) {
404   - $event.stopPropagation();
405   - }
406   - this.router.navigateByUrl(`edges/${edge.id.id}/ruleChains`);
407   - }
408   -
409   - openEdgeAssets($event: Event, edge: Edge) {
410   - if ($event) {
411   - $event.stopPropagation();
412   - }
413   - this.router.navigateByUrl(`edges/${edge.id.id}/assets`);
414   - }
415   -
416   - openEdgeDevices($event, edge) {
417   - if ($event) {
418   - $event.stopPropagation();
419   - }
420   - this.router.navigateByUrl(`edges/${edge.id.id}/devices`);
421   - }
422   -
423   - openEdgeEntityViews($event, edge) {
424   - if ($event) {
425   - $event.stopPropagation();
  399 + let suffix: string;
  400 + switch (entityType) {
  401 + case EntityType.DEVICE:
  402 + suffix = 'devices';
  403 + break;
  404 + case EntityType.ASSET:
  405 + suffix = 'assets';
  406 + break;
  407 + case EntityType.EDGE:
  408 + suffix = 'assets';
  409 + break;
  410 + case EntityType.ENTITY_VIEW:
  411 + suffix = 'entityViews';
  412 + break;
  413 + case EntityType.DASHBOARD:
  414 + suffix = 'dashboards';
  415 + break;
  416 + case EntityType.RULE_CHAIN:
  417 + suffix = 'ruleChains';
  418 + break;
426 419 }
427   - this.router.navigateByUrl(`edges/${edge.id.id}/entityViews`);
  420 + this.router.navigateByUrl(`edges/${edge.id.id}/${suffix}`);
428 421 }
429 422
430 423 assignToCustomer($event: Event, edgesIds: Array<EdgeId>) {
... ... @@ -537,19 +530,19 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
537 530 this.unassignFromCustomer(action.event, action.entity);
538 531 return true;
539 532 case 'openEdgeAssets':
540   - this.openEdgeAssets(action.event, action.entity);
  533 + this.openEdgeEntitiesByType(action.event, action.entity, EntityType.ASSET);
541 534 return true;
542 535 case 'openEdgeDevices':
543   - this.openEdgeDevices(action.event, action.entity);
  536 + this.openEdgeEntitiesByType(action.event, action.entity, EntityType.DEVICE);
544 537 return true;
545 538 case 'openEdgeEntityViews':
546   - this.openEdgeEntityViews(action.event, action.entity);
  539 + this.openEdgeEntitiesByType(action.event, action.entity, EntityType.ENTITY_VIEW);
547 540 return true;
548 541 case 'openEdgeDashboards':
549   - this.openEdgeDashboards(action.event, action.entity);
  542 + this.openEdgeEntitiesByType(action.event, action.entity, EntityType.DASHBOARD);
550 543 return true;
551 544 case 'openEdgeRuleChains':
552   - this.openEdgeRuleChains(action.event, action.entity);
  545 + this.openEdgeEntitiesByType(action.event, action.entity, EntityType.RULE_CHAIN);
553 546 return true;
554 547 case 'syncEdge':
555 548 this.syncEdge(action.event, action.entity);
... ...
... ... @@ -25,7 +25,7 @@ import { Subscription } from 'rxjs';
25 25 import { RuleChainService } from '@core/http/rule-chain.service';
26 26 import { RuleNodeConfigComponent } from './rule-node-config.component';
27 27 import { Router } from '@angular/router';
28   -import { ruleChainType } from '@app/shared/models/rule-chain.models';
  28 +import { RuleChainType } from '@app/shared/models/rule-chain.models';
29 29
30 30 @Component({
31 31 selector: 'tb-rule-node',
... ... @@ -43,7 +43,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
43 43 ruleChainId: string;
44 44
45 45 @Input()
46   - ruleChainType: string;
  46 + ruleChainType: RuleChainType;
47 47
48 48 @Input()
49 49 isEdit: boolean;
... ... @@ -151,7 +151,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
151 151 $event.stopPropagation();
152 152 }
153 153 if (this.ruleNode.targetRuleChainId) {
154   - if (this.ruleChainType === ruleChainType.edge) {
  154 + if (this.ruleChainType === RuleChainType.edge) {
155 155 this.router.navigateByUrl(`/edges/ruleChains/${this.ruleNode.targetRuleChainId}`);
156 156 } else {
157 157 this.router.navigateByUrl(`/ruleChains/${this.ruleNode.targetRuleChainId}`);
... ...
... ... @@ -48,8 +48,7 @@ import {
48 48 RuleChainConnectionInfo,
49 49 RuleChainImport,
50 50 RuleChainMetaData,
51   - ruleChainNodeComponent,
52   - ruleChainType
  51 + ruleChainNodeComponent, RuleChainType
53 52 } from '@shared/models/rule-chain.models';
54 53 import { FcItemInfo, FlowchartConstants, NgxFlowchartComponent, UserCallbacks } from 'ngx-flowchart/dist/ngx-flowchart';
55 54 import {
... ... @@ -120,7 +119,7 @@ export class RuleChainPageComponent extends PageComponent
120 119 isDirtyValue: boolean;
121 120 isInvalid = false;
122 121
123   - ruleChainType: string;
  122 + ruleChainType: RuleChainType;
124 123
125 124 errorTooltips: {[nodeId: string]: JQueryTooltipster.ITooltipsterInstance} = {};
126 125 isFullscreen = false;
... ... @@ -514,7 +513,7 @@ export class RuleChainPageComponent extends PageComponent
514 513 );
515 514 const nodes: FcRuleNode[] = [];
516 515 this.ruleChainMetaData.nodes.forEach((ruleNode) => {
517   - const component = this.ruleChainService.getRuleNodeComponentByClazz(ruleNode.type);
  516 + const component = this.ruleChainService.getRuleNodeComponentByClazz(this.ruleChainType, ruleNode.type);
518 517 const descriptor = ruleNodeTypeDescriptors.get(component.type);
519 518 let icon = descriptor.icon;
520 519 let iconUrl = null;
... ... @@ -1287,7 +1286,7 @@ export class RuleChainPageComponent extends PageComponent
1287 1286 if (this.isImport) {
1288 1287 this.isDirtyValue = false;
1289 1288 this.isImport = false;
1290   - if (this.ruleChainType !== ruleChainType.edge) {
  1289 + if (this.ruleChainType !== RuleChainType.edge) {
1291 1290 this.router.navigateByUrl(`ruleChains/${this.ruleChain.id.id}`);
1292 1291 } else {
1293 1292 this.router.navigateByUrl(`edges/ruleChains/${this.ruleChain.id.id}`);
... ... @@ -1514,7 +1513,7 @@ export class AddRuleNodeLinkDialogComponent extends DialogComponent<AddRuleNodeL
1514 1513 export interface AddRuleNodeDialogData {
1515 1514 ruleNode: FcRuleNode;
1516 1515 ruleChainId: string;
1517   - ruleChainType: string;
  1516 + ruleChainType: RuleChainType;
1518 1517 }
1519 1518
1520 1519 @Component({
... ... @@ -1530,7 +1529,7 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo
1530 1529
1531 1530 ruleNode: FcRuleNode;
1532 1531 ruleChainId: string;
1533   - ruleChainType: string;
  1532 + ruleChainType: RuleChainType;
1534 1533
1535 1534 submitted = false;
1536 1535
... ...
... ... @@ -33,8 +33,7 @@ import { Observable } from 'rxjs';
33 33 import { BreadCrumbConfig, BreadCrumbLabelFunction } from '@shared/components/breadcrumb';
34 34 import {
35 35 ResolvedRuleChainMetaData,
36   - RuleChain,
37   - ruleChainType,
  36 + RuleChain, RuleChainType
38 37 } from '@shared/models/rule-chain.models';
39 38 import { RuleChainService } from '@core/http/rule-chain.service';
40 39 import { RuleChainPageComponent } from '@home/pages/rulechain/rulechain-page.component';
... ... @@ -145,7 +144,7 @@ const routes: Routes = [
145 144 auth: [Authority.TENANT_ADMIN],
146 145 title: 'rulechain.rulechain',
147 146 import: false,
148   - ruleChainType: ruleChainType.core
  147 + ruleChainType: RuleChainType.core
149 148 },
150 149 resolve: {
151 150 ruleChain: RuleChainResolver,
... ... @@ -166,7 +165,7 @@ const routes: Routes = [
166 165 auth: [Authority.TENANT_ADMIN],
167 166 title: 'rulechain.rulechain',
168 167 import: true,
169   - ruleChainType: ruleChainType.core
  168 + ruleChainType: RuleChainType.core
170 169 },
171 170 resolve: {
172 171 ruleNodeComponents: RuleNodeComponentsResolver
... ...
... ... @@ -31,7 +31,7 @@ import { TranslateService } from '@ngx-translate/core';
31 31 import { DatePipe } from '@angular/common';
32 32 import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models';
33 33 import { EntityAction } from '@home/models/entity/entity-component.models';
34   -import { RuleChain, ruleChainType } from '@shared/models/rule-chain.models';
  34 +import { RuleChain, RuleChainType } from '@shared/models/rule-chain.models';
35 35 import { RuleChainService } from '@core/http/rule-chain.service';
36 36 import { RuleChainComponent } from '@modules/home/pages/rulechain/rulechain.component';
37 37 import { DialogService } from '@core/services/dialog.service';
... ... @@ -272,7 +272,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
272 272 if ($event) {
273 273 $event.stopPropagation();
274 274 }
275   - const expectedRuleChainType = this.config.componentsData.ruleChainScope === 'tenant' ? ruleChainType.core : ruleChainType.edge;
  275 + const expectedRuleChainType = this.config.componentsData.ruleChainScope === 'tenant' ? RuleChainType.core : RuleChainType.edge;
276 276 this.importExport.importRuleChain(expectedRuleChainType).subscribe((ruleChainImport) => {
277 277 if (ruleChainImport) {
278 278 this.itembuffer.storeRuleChainImport(ruleChainImport);
... ... @@ -299,12 +299,12 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
299 299 saveRuleChain(ruleChain: RuleChain) {
300 300 if (isUndefined(ruleChain.type)) {
301 301 if (this.config.componentsData.ruleChainScope == 'tenant') {
302   - ruleChain.type = ruleChainType.core;
  302 + ruleChain.type = RuleChainType.core;
303 303 } else if (this.config.componentsData.ruleChainScope == 'edges') {
304   - ruleChain.type = ruleChainType.edge;
  304 + ruleChain.type = RuleChainType.edge;
305 305 } else {
306 306 // safe fallback to default core type
307   - ruleChain.type = ruleChainType.core;
  307 + ruleChain.type = RuleChainType.core;
308 308 }
309 309 }
310 310 return this.ruleChainService.saveRuleChain(ruleChain);
... ... @@ -550,7 +550,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
550 550 }
551 551
552 552 fetchRuleChains(pageLink: PageLink) {
553   - return this.ruleChainService.getRuleChains(pageLink, ruleChainType.core);
  553 + return this.ruleChainService.getRuleChains(pageLink, RuleChainType.core);
554 554 }
555 555
556 556 fetchEdgeRuleChains(pageLink: PageLink) {
... ... @@ -558,7 +558,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
558 558 mergeMap((ruleChains) => {
559 559 this.config.componentsData.autoAssignToEdgeRuleChainIds = [];
560 560 ruleChains.map(ruleChain => this.config.componentsData.autoAssignToEdgeRuleChainIds.push(ruleChain.id.id));
561   - return this.ruleChainService.getRuleChains(pageLink, ruleChainType.edge);
  561 + return this.ruleChainService.getRuleChains(pageLink, RuleChainType.edge);
562 562 })
563 563 );
564 564 }
... ...
... ... @@ -19,7 +19,7 @@ import { Component, OnInit } from '@angular/core';
19 19 import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart';
20 20 import { FcRuleNode, RuleNodeType } from '@shared/models/rule-node.models';
21 21 import { Router } from '@angular/router';
22   -import { ruleChainType } from '@app/shared/models/rule-chain.models';
  22 +import { RuleChainType } from '@app/shared/models/rule-chain.models';
23 23
24 24 @Component({
25 25 // tslint:disable-next-line:component-selector
... ... @@ -49,7 +49,7 @@ export class RuleNodeComponent extends FcNodeComponent implements OnInit {
49 49 $event.stopPropagation();
50 50 }
51 51 if (node.targetRuleChainId) {
52   - if (node.ruleChainType === ruleChainType.edge) {
  52 + if (node.ruleChainType === RuleChainType.edge) {
53 53 this.router.navigateByUrl(`/edges/ruleChains/${node.targetRuleChainId}`);
54 54 } else {
55 55 this.router.navigateByUrl(`/ruleChains/${node.targetRuleChainId}`);
... ...
... ... @@ -121,16 +121,14 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
121 121 this.config.entitySelectionEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
122 122 this.config.detailsReadonly = (widgetsBundle) => !this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
123 123 const authState = getCurrentAuthState(this.store);
124   - if (!authState.edgesSupportEnabled) {
125   - this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink).pipe(
126   - map((widgetBundles) => {
  124 + this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink).pipe(
  125 + map((widgetBundles) => {
  126 + if (!authState.edgesSupportEnabled) {
127 127 widgetBundles.data = widgetBundles.data.filter(widgetBundle => widgetBundle.alias !== 'edge_widgets');
128   - return widgetBundles;
129   - })
130   - );
131   - } else {
132   - this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink);
133   - }
  128 + }
  129 + return widgetBundles;
  130 + })
  131 + );
134 132 return this.config;
135 133 }
136 134
... ...
... ... @@ -82,6 +82,13 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni
82 82
83 83 ngOnInit() {
84 84 this.widgetsBundles$ = this.getWidgetsBundles().pipe(
  85 + map((widgetsBundles) => {
  86 + const authState = getCurrentAuthState(this.store);
  87 + if (!authState.edgesSupportEnabled) {
  88 + widgetsBundles = widgetsBundles.filter(widgetsBundle => widgetsBundle.alias !== 'edge_widgets');
  89 + }
  90 + return widgetsBundles;
  91 + }),
85 92 tap((widgetsBundles) => {
86 93 this.widgetsBundles = widgetsBundles;
87 94 if (this.selectFirstBundle) {
... ... @@ -95,13 +102,6 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni
95 102 }
96 103 }
97 104 }),
98   - map((widgetsBundles) => {
99   - const authState = getCurrentAuthState(this.store);
100   - if (!authState.edgesSupportEnabled) {
101   - widgetsBundles = widgetsBundles.filter(widgetsBundle => widgetsBundle.alias !== 'edge_widgets');
102   - }
103   - return widgetsBundles;
104   - }),
105 105 share()
106 106 );
107 107 }
... ...
... ... @@ -113,9 +113,7 @@ export const inputNodeComponent: RuleNodeComponentDescriptor = {
113 113 clazz: 'tb.internal.Input'
114 114 };
115 115
116   -export declare type RuleChainType = 'CORE' | 'EDGE';
117   -
118   -export enum ruleChainType {
  116 +export enum RuleChainType {
119 117 core = 'CORE',
120 118 edge = 'EDGE'
121 119 }
... ...
... ... @@ -25,6 +25,7 @@ import { AfterViewInit, EventEmitter, Inject, OnInit, Directive } from '@angular
25 25 import { Store } from '@ngrx/store';
26 26 import { AppState } from '@core/core.state';
27 27 import { AbstractControl, FormGroup } from '@angular/forms';
  28 +import { RuleChainType } from '@shared/models/rule-chain.models';
28 29
29 30 export interface RuleNodeConfiguration {
30 31 [key: string]: any;
... ... @@ -313,7 +314,7 @@ export interface FcRuleNode extends FcRuleNodeType {
313 314 error?: string;
314 315 highlighted?: boolean;
315 316 componentClazz?: string;
316   - ruleChainType?: string;
  317 + ruleChainType?: RuleChainType;
317 318 }
318 319
319 320 export interface FcRuleEdge extends FcEdge {
... ...