Commit d8de53c186c9818d02495077e2f7ebbc352f733d

Authored by Volodymyr Babak
1 parent f99d7171

Code review fixes

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