Commit ad91c68e11e4ca89ba5e19aec4852862aeb59cb9

Authored by Artem Babak
1 parent 0336906b

Rule Chains routing refactored

@@ -51,7 +51,6 @@ import { @@ -51,7 +51,6 @@ import {
51 AddEntitiesToCustomerDialogData 51 AddEntitiesToCustomerDialogData
52 } from '../../dialogs/add-entities-to-customer-dialog.component'; 52 } from '../../dialogs/add-entities-to-customer-dialog.component';
53 import { HomeDialogsService } from '@home/dialogs/home-dialogs.service'; 53 import { HomeDialogsService } from '@home/dialogs/home-dialogs.service';
54 -  
55 import { Edge, EdgeInfo } from "@shared/models/edge.models"; 54 import { Edge, EdgeInfo } from "@shared/models/edge.models";
56 import { EdgeService } from "@core/http/edge.service"; 55 import { EdgeService } from "@core/http/edge.service";
57 import { EdgeComponent } from "@home/pages/edge/edge.component"; 56 import { EdgeComponent } from "@home/pages/edge/edge.component";
@@ -96,19 +95,15 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI @@ -96,19 +95,15 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
96 mergeMap((savedEdge) => this.edgeService.getEdge(savedEdge.id.id) 95 mergeMap((savedEdge) => this.edgeService.getEdge(savedEdge.id.id)
97 )); 96 ));
98 }; 97 };
99 -  
100 this.config.onEntityAction = action => this.onEdgeAction(action); 98 this.config.onEntityAction = action => this.onEdgeAction(action);
101 this.config.detailsReadonly = () => this.config.componentsData.edgeScope === 'customer_user'; 99 this.config.detailsReadonly = () => this.config.componentsData.edgeScope === 'customer_user';
102 -  
103 this.config.headerComponent = EdgeTableHeaderComponent; 100 this.config.headerComponent = EdgeTableHeaderComponent;
104 -  
105 } 101 }
106 102
107 resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> { 103 resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<EdgeInfo>> {
108 const routeParams = route.params; 104 const routeParams = route.params;
109 this.config.componentsData = { 105 this.config.componentsData = {
110 - edgeScope: route.data.edgesType,  
111 - edgeType: '' 106 + edgeScope: route.data.edgesType
112 }; 107 };
113 this.customerId = routeParams.customerId; 108 this.customerId = routeParams.customerId;
114 return this.store.pipe(select(selectAuthUser), take(1)).pipe( 109 return this.store.pipe(select(selectAuthUser), take(1)).pipe(
@@ -166,12 +161,12 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI @@ -166,12 +161,12 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
166 configureEntityFunctions(edgeScope: string): void { 161 configureEntityFunctions(edgeScope: string): void {
167 if (edgeScope === 'tenant') { 162 if (edgeScope === 'tenant') {
168 this.config.entitiesFetchFunction = pageLink => 163 this.config.entitiesFetchFunction = pageLink =>
169 - this.edgeService.getTenantEdgeInfos(pageLink, this.config.componentsData.edgeType); 164 + this.edgeService.getTenantEdgeInfos(pageLink);
170 this.config.deleteEntity = id => this.edgeService.deleteEdge(id.id); 165 this.config.deleteEntity = id => this.edgeService.deleteEdge(id.id);
171 } 166 }
172 if (edgeScope === 'customer') { 167 if (edgeScope === 'customer') {
173 this.config.entitiesFetchFunction = pageLink => 168 this.config.entitiesFetchFunction = pageLink =>
174 - this.edgeService.getCustomerEdgeInfos(this.customerId, pageLink, this.config.componentsData.edgeType); 169 + this.edgeService.getCustomerEdgeInfos(this.customerId, pageLink);
175 this.config.deleteEntity = id => this.edgeService.unassignEdgeFromCustomer(id.id); 170 this.config.deleteEntity = id => this.edgeService.unassignEdgeFromCustomer(id.id);
176 } 171 }
177 } 172 }
@@ -74,11 +74,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< @@ -74,11 +74,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
74 new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'), 74 new EntityTableColumn<RuleChain>('name', 'rulechain.name', '100%'),
75 new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px', 75 new EntityTableColumn<RuleChain>('root', 'rulechain.root', '60px',
76 entity => { 76 entity => {
77 - if (this.config.componentsData.edgeId) {  
78 - return checkBoxCell((this.edge.rootRuleChainId.id == entity.id.id));  
79 - } else {  
80 - return checkBoxCell(entity.root);  
81 - } 77 + if (isDefined(this.config.componentsData.edgeId)) {
  78 + return checkBoxCell((this.config.componentsData.edge.rootRuleChainId.id == entity.id.id));
  79 + } else {
  80 + return checkBoxCell(entity.root);
  81 + }
82 }) 82 })
83 ); 83 );
84 this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title', 84 this.config.deleteEntityTitle = ruleChain => this.translate.instant('rulechain.delete-rulechain-title',
@@ -99,13 +99,14 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< @@ -99,13 +99,14 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
99 edgeId: routeParams.edgeId 99 edgeId: routeParams.edgeId
100 }; 100 };
101 if (this.config.componentsData.edgeId) { 101 if (this.config.componentsData.edgeId) {
102 - this.config.entitySelectionEnabled = ruleChain => this.edge.rootRuleChainId.id != ruleChain.id.id; 102 + this.config.entitySelectionEnabled = ruleChain => this.config.componentsData.edge.rootRuleChainId.id != ruleChain.id.id;
103 this.config.deleteEnabled = () => false; 103 this.config.deleteEnabled = () => false;
104 this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => { 104 this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => {
105 - this.edge = edge;  
106 - this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains') 105 + this.config.componentsData.edge = edge;
  106 + this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains');
107 }); 107 });
108 - } else { 108 + }
  109 + else {
109 this.config.entitySelectionEnabled = ruleChain => ruleChain && !ruleChain.root; 110 this.config.entitySelectionEnabled = ruleChain => ruleChain && !ruleChain.root;
110 this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root; 111 this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root;
111 } 112 }
@@ -235,7 +236,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< @@ -235,7 +236,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
235 { 236 {
236 name: this.translate.instant('edge.unassign-from-edge'), 237 name: this.translate.instant('edge.unassign-from-edge'),
237 icon: 'portable_wifi_off', 238 icon: 'portable_wifi_off',
238 - isEnabled: (entity) => entity.id.id != this.edge.rootRuleChainId.id, 239 + isEnabled: (entity) => entity.id.id != this.config.componentsData.edge.rootRuleChainId.id,
239 onAction: ($event, entity) => this.unassignFromEdge($event, entity) 240 onAction: ($event, entity) => this.unassignFromEdge($event, entity)
240 } 241 }
241 ) 242 )
@@ -295,7 +296,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< @@ -295,7 +296,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
295 if (this.config.componentsData.edgeId) { 296 if (this.config.componentsData.edgeId) {
296 this.edgeService.setRootRuleChain(this.config.componentsData.edgeId, ruleChain.id.id).subscribe( 297 this.edgeService.setRootRuleChain(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
297 (edge) => { 298 (edge) => {
298 - this.edge = edge; 299 + this.config.componentsData.edge = edge;
299 this.config.table.updateData(); 300 this.config.table.updateData();
300 } 301 }
301 ) 302 )
@@ -465,7 +466,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< @@ -465,7 +466,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
465 466
466 isNonRootRuleChain(ruleChain: RuleChain) { 467 isNonRootRuleChain(ruleChain: RuleChain) {
467 if (this.config.componentsData.edgeId) { 468 if (this.config.componentsData.edgeId) {
468 - return (isDefined(this.edge.rootRuleChainId) && this.edge.rootRuleChainId != null && this.edge.rootRuleChainId.id != ruleChain.id.id); 469 + return (isDefined(this.config.componentsData.edge.rootRuleChainId) && this.config.componentsData.edge.rootRuleChainId != null && this.config.componentsData.edge.rootRuleChainId.id != ruleChain.id.id);
469 } 470 }
470 return (isDefined(ruleChain)) && !ruleChain.root; 471 return (isDefined(ruleChain)) && !ruleChain.root;
471 } 472 }
@@ -31,7 +31,7 @@ export enum DebugEventType { @@ -31,7 +31,7 @@ export enum DebugEventType {
31 DEBUG_RULE_NODE = 'DEBUG_RULE_NODE', 31 DEBUG_RULE_NODE = 'DEBUG_RULE_NODE',
32 DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN' 32 DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN'
33 } 33 }
34 -//TODO deaflynx filter CE only event types 34 +
35 export enum EdgeEventType { 35 export enum EdgeEventType {
36 DASHBOARD = "DASHBOARD", 36 DASHBOARD = "DASHBOARD",
37 ASSET = "ASSET", 37 ASSET = "ASSET",
@@ -44,11 +44,6 @@ export enum EdgeEventType { @@ -44,11 +44,6 @@ export enum EdgeEventType {
44 USER = "USER", 44 USER = "USER",
45 CUSTOMER = "CUSTOMER", 45 CUSTOMER = "CUSTOMER",
46 RELATION = "RELATION", 46 RELATION = "RELATION",
47 - ENTITY_GROUP = "ENTITY_GROUP",  
48 - SCHEDULER_EVENT = "SCHEDULER_EVENT",  
49 - WHITE_LABELING = "WHITE_LABELING",  
50 - LOGIN_WHITE_LABELING = "LOGIN_WHITE_LABELING",  
51 - CUSTOM_TRANSLATION = "CUSTOM_TRANSLATION",  
52 WIDGETS_BUNDLE = "WIDGETS_BUNDLE", 47 WIDGETS_BUNDLE = "WIDGETS_BUNDLE",
53 WIDGET_TYPE = "WIDGET_TYPE", 48 WIDGET_TYPE = "WIDGET_TYPE",
54 ADMIN_SETTINGS = "ADMIN_SETTINGS" 49 ADMIN_SETTINGS = "ADMIN_SETTINGS"