Commit ad91c68e11e4ca89ba5e19aec4852862aeb59cb9

Authored by Artem Babak
1 parent 0336906b

Rule Chains routing refactored

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