Commit a1db669a9de207fc5358944170fef78ec7531fe3
Committed by
GitHub
Merge pull request #46 from deaflynx/feature/edge
CE refactored & reviewed
Showing
17 changed files
with
149 additions
and
159 deletions
... | ... | @@ -28,31 +28,31 @@ function ComponentDescriptorService($http, $q) { |
28 | 28 | |
29 | 29 | return service; |
30 | 30 | |
31 | - function getComponentDescriptorsByTypes(componentTypes, ruleChainType) { | |
31 | + function getComponentDescriptorsByTypes(componentTypes, type) { | |
32 | 32 | var deferred = $q.defer(); |
33 | 33 | var result = []; |
34 | - if (!componentsByType[ruleChainType]) { | |
35 | - componentsByType[ruleChainType] = {}; | |
34 | + if (!componentsByType[type]) { | |
35 | + componentsByType[type] = {}; | |
36 | 36 | } |
37 | 37 | for (var i=componentTypes.length-1;i>=0;i--) { |
38 | 38 | var componentType = componentTypes[i]; |
39 | - if (componentsByType[ruleChainType][componentType]) { | |
40 | - result = result.concat(componentsByType[ruleChainType][componentType]); | |
39 | + if (componentsByType[type][componentType]) { | |
40 | + result = result.concat(componentsByType[type][componentType]); | |
41 | 41 | componentTypes.splice(i, 1); |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (!componentTypes.length) { |
45 | 45 | deferred.resolve(result); |
46 | 46 | } else { |
47 | - var url = '/api/components?componentTypes=' + componentTypes.join(',') + '&ruleChainType=' + ruleChainType; | |
47 | + var url = '/api/components?componentTypes=' + componentTypes.join(',') + '&ruleChainType=' + type; | |
48 | 48 | $http.get(url, null).then(function success(response) { |
49 | 49 | var components = response.data; |
50 | 50 | for (var i = 0; i < components.length; i++) { |
51 | 51 | var component = components[i]; |
52 | - var componentsList = componentsByType[ruleChainType][component.type]; | |
52 | + var componentsList = componentsByType[type][component.type]; | |
53 | 53 | if (!componentsList) { |
54 | 54 | componentsList = []; |
55 | - componentsByType[ruleChainType][component.type] = componentsList; | |
55 | + componentsByType[type][component.type] = componentsList; | |
56 | 56 | } |
57 | 57 | componentsList.push(component); |
58 | 58 | componentsByClazz[component.clazz] = component; | ... | ... |
... | ... | @@ -311,7 +311,7 @@ function RuleChainService($http, $q, $filter, $ocLazyLoad, $translate, types, co |
311 | 311 | } |
312 | 312 | |
313 | 313 | function getEdgesRuleChains(pageLink, config) { |
314 | - return getRuleChains(pageLink, config, types.edgeRuleChainType); | |
314 | + return getRuleChains(pageLink, config, types.ruleChainType.edge); | |
315 | 315 | } |
316 | 316 | |
317 | 317 | function getEdgeRuleChains(edgeId, pageLink, config) { | ... | ... |
... | ... | @@ -393,7 +393,15 @@ export default angular.module('thingsboard.types', []) |
393 | 393 | edge: "EDGE", |
394 | 394 | user: "USER", |
395 | 395 | customer: "CUSTOMER", |
396 | - relation: "RELATION" | |
396 | + relation: "RELATION", | |
397 | + entityGroup: "ENTITY_GROUP", | |
398 | + schedulerEvent: "SCHEDULER_EVENT", | |
399 | + whiteLabeling: "WHITE_LABELING", | |
400 | + loginWhiteLabeling: "LOGIN_WHITE_LABELING", | |
401 | + customTranslation: "CUSTOM_TRANSLATION", | |
402 | + widgetsBundle: "WIDGETS_BUNDLE", | |
403 | + widgetType: "WIDGET_TYPE", | |
404 | + adminSettings: "ADMIN_SETTINGS" | |
397 | 405 | }, |
398 | 406 | edgeEventAction: { |
399 | 407 | updated: "UPDATED", |
... | ... | @@ -786,8 +794,10 @@ export default angular.module('thingsboard.types', []) |
786 | 794 | clientSide: false |
787 | 795 | } |
788 | 796 | }, |
789 | - coreRuleChainType: "CORE", | |
790 | - edgeRuleChainType: "EDGE", | |
797 | + ruleChainType: { | |
798 | + core: "CORE", | |
799 | + edge: "EDGE" | |
800 | + }, | |
791 | 801 | ruleNodeTypeComponentTypes: ["FILTER", "ENRICHMENT", "TRANSFORMATION", "ACTION", "EXTERNAL"], |
792 | 802 | ruleChainNodeComponent: { |
793 | 803 | type: 'RULE_CHAIN', | ... | ... |
... | ... | @@ -53,13 +53,7 @@ export default function AddDashboardsToEdgeController(dashboardService, types, $ |
53 | 53 | fetchMoreItems_: function () { |
54 | 54 | if (vm.dashboards.hasNext && !vm.dashboards.pending) { |
55 | 55 | vm.dashboards.pending = true; |
56 | - var fetchDashboardsPromise; | |
57 | - if (edgeCustomerId === vm.types.id.nullUid) { | |
58 | - fetchDashboardsPromise = dashboardService.getTenantDashboards(vm.dashboards.nextPageLink); | |
59 | - } else { | |
60 | - fetchDashboardsPromise = dashboardService.getCustomerDashboards(edgeCustomerId, vm.dashboards.nextPageLink); | |
61 | - } | |
62 | - fetchDashboardsPromise.then( | |
56 | + dashboardService.getTenantDashboards(vm.dashboards.nextPageLink).then( | |
63 | 57 | function success(dashboards) { |
64 | 58 | vm.dashboards.data = vm.dashboards.data.concat(dashboards.data); |
65 | 59 | vm.dashboards.nextPageLink = dashboards.nextPageLink; | ... | ... |
... | ... | @@ -708,14 +708,7 @@ export function DashboardsController(userService, dashboardService, customerServ |
708 | 708 | $event.stopPropagation(); |
709 | 709 | } |
710 | 710 | var pageSize = 10; |
711 | - var fetchDashboardsPromise; | |
712 | - if (vm.edgeCustomerId.id === vm.types.id.nullUid) { | |
713 | - fetchDashboardsPromise = dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}); | |
714 | - } else { | |
715 | - fetchDashboardsPromise = dashboardService.getCustomerDashboards(vm.edgeCustomerId.id, {limit: pageSize, textSearch: ''}); | |
716 | - } | |
717 | - | |
718 | - fetchDashboardsPromise.then( | |
711 | + dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}).then( | |
719 | 712 | function success(_dashboards) { |
720 | 713 | var dashboards = { |
721 | 714 | pageSize: pageSize, | ... | ... |
... | ... | @@ -21,6 +21,8 @@ import devicesTemplate from "../device/devices.tpl.html"; |
21 | 21 | import assetsTemplate from "../asset/assets.tpl.html"; |
22 | 22 | import dashboardsTemplate from "../dashboard/dashboards.tpl.html"; |
23 | 23 | import dashboardTemplate from "../dashboard/dashboard.tpl.html"; |
24 | +import ruleChainsTemplate from "../rulechain/rulechains.tpl.html"; | |
25 | +import ruleChainTemplate from "../rulechain/rulechain.tpl.html"; | |
24 | 26 | |
25 | 27 | /* eslint-enable import/no-unresolved, import/default */ |
26 | 28 | |
... | ... | @@ -49,8 +51,7 @@ export default function EdgeRoutes($stateProvider, types) { |
49 | 51 | ncyBreadcrumb: { |
50 | 52 | label: '{"icon": "transform", "label": "edge.edges"}' |
51 | 53 | } |
52 | - }) | |
53 | - .state('home.edges.entityViews', { | |
54 | + }).state('home.edges.entityViews', { | |
54 | 55 | url: '/:edgeId/entityViews', |
55 | 56 | params: {'topIndex': 0}, |
56 | 57 | module: 'private', |
... | ... | @@ -72,8 +73,7 @@ export default function EdgeRoutes($stateProvider, types) { |
72 | 73 | ncyBreadcrumb: { |
73 | 74 | label: '{"icon": "view_quilt", "label": "edge.entity-views"}' |
74 | 75 | } |
75 | - }) | |
76 | - .state('home.edges.devices', { | |
76 | + }).state('home.edges.devices', { | |
77 | 77 | url: '/:edgeId/devices', |
78 | 78 | params: {'topIndex': 0}, |
79 | 79 | module: 'private', |
... | ... | @@ -95,8 +95,7 @@ export default function EdgeRoutes($stateProvider, types) { |
95 | 95 | ncyBreadcrumb: { |
96 | 96 | label: '{"icon": "devices_other", "label": "edge.devices"}' |
97 | 97 | } |
98 | - }) | |
99 | - .state('home.edges.assets', { | |
98 | + }).state('home.edges.assets', { | |
100 | 99 | url: '/:edgeId/assets', |
101 | 100 | params: {'topIndex': 0}, |
102 | 101 | module: 'private', |
... | ... | @@ -118,29 +117,27 @@ export default function EdgeRoutes($stateProvider, types) { |
118 | 117 | ncyBreadcrumb: { |
119 | 118 | label: '{"icon": "domain", "label": "edge.assets"}' |
120 | 119 | } |
121 | - }) | |
122 | - .state('home.edges.dashboards', { | |
123 | - url: '/:edgeId/dashboards', | |
124 | - params: {'topIndex': 0}, | |
125 | - module: 'private', | |
126 | - auth: ['TENANT_ADMIN'], | |
127 | - views: { | |
128 | - "content@home": { | |
129 | - templateUrl: dashboardsTemplate, | |
130 | - controllerAs: 'vm', | |
131 | - controller: 'DashboardsController' | |
120 | + }).state('home.edges.dashboards', { | |
121 | + url: '/:edgeId/dashboards', | |
122 | + params: {'topIndex': 0}, | |
123 | + module: 'private', | |
124 | + auth: ['TENANT_ADMIN'], | |
125 | + views: { | |
126 | + "content@home": { | |
127 | + templateUrl: dashboardsTemplate, | |
128 | + controllerAs: 'vm', | |
129 | + controller: 'DashboardsController' | |
130 | + } | |
131 | + }, | |
132 | + data: { | |
133 | + dashboardsType: 'edge', | |
134 | + searchEnabled: true, | |
135 | + pageTitle: 'edge.dashboards' | |
136 | + }, | |
137 | + ncyBreadcrumb: { | |
138 | + label: '{"icon": "dashboard", "label": "edge.dashboards"}' | |
132 | 139 | } |
133 | - }, | |
134 | - data: { | |
135 | - dashboardsType: 'edge', | |
136 | - searchEnabled: true, | |
137 | - pageTitle: 'edge.dashboards' | |
138 | - }, | |
139 | - ncyBreadcrumb: { | |
140 | - label: '{"icon": "dashboard", "label": "edge.dashboards"}' | |
141 | - } | |
142 | - }) | |
143 | - .state('home.edges.dashboards.dashboard', { | |
140 | + }).state('home.edges.dashboards.dashboard', { | |
144 | 141 | url: '/:dashboardId?state', |
145 | 142 | reloadOnSearch: false, |
146 | 143 | module: 'private', |
... | ... | @@ -161,8 +158,7 @@ export default function EdgeRoutes($stateProvider, types) { |
161 | 158 | ncyBreadcrumb: { |
162 | 159 | label: '{"icon": "dashboard", "label": "{{ vm.dashboard.title }}", "translate": "false"}' |
163 | 160 | } |
164 | - }) | |
165 | - .state('home.customers.edges', { | |
161 | + }).state('home.customers.edges', { | |
166 | 162 | url: '/:customerId/edges', |
167 | 163 | params: {'topIndex': 0}, |
168 | 164 | module: 'private', |
... | ... | @@ -184,5 +180,62 @@ export default function EdgeRoutes($stateProvider, types) { |
184 | 180 | ncyBreadcrumb: { |
185 | 181 | label: '{"icon": "router", "label": "{{ vm.customerEdgesTitle }}", "translate": "false"}' |
186 | 182 | } |
183 | + }).state('home.edges.ruleChains', { | |
184 | + url: '/:edgeId/ruleChains', | |
185 | + params: {'topIndex': 0}, | |
186 | + module: 'private', | |
187 | + auth: ['TENANT_ADMIN'], | |
188 | + views: { | |
189 | + "content@home": { | |
190 | + templateUrl: ruleChainsTemplate, | |
191 | + controllerAs: 'vm', | |
192 | + controller: 'RuleChainsController' | |
193 | + } | |
194 | + }, | |
195 | + data: { | |
196 | + searchEnabled: true, | |
197 | + pageTitle: 'edge.rulechains', | |
198 | + ruleChainsType: 'edge' | |
199 | + }, | |
200 | + ncyBreadcrumb: { | |
201 | + label: '{"icon": "settings_ethernet", "label": "rulechain.edge-rulechains"}' | |
202 | + } | |
203 | + }).state('home.edges.ruleChains.ruleChain', { | |
204 | + url: '/:ruleChainId', | |
205 | + reloadOnSearch: false, | |
206 | + module: 'private', | |
207 | + auth: ['SYS_ADMIN', 'TENANT_ADMIN'], | |
208 | + views: { | |
209 | + "content@home": { | |
210 | + templateUrl: ruleChainTemplate, | |
211 | + controller: 'RuleChainController', | |
212 | + controllerAs: 'vm' | |
213 | + } | |
214 | + }, | |
215 | + resolve: { | |
216 | + ruleChain: | |
217 | + /*@ngInject*/ | |
218 | + function($stateParams, ruleChainService) { | |
219 | + return ruleChainService.getRuleChain($stateParams.ruleChainId); | |
220 | + }, | |
221 | + ruleChainMetaData: | |
222 | + /*@ngInject*/ | |
223 | + function($stateParams, ruleChainService) { | |
224 | + return ruleChainService.getRuleChainMetaData($stateParams.ruleChainId); | |
225 | + }, | |
226 | + ruleNodeComponents: | |
227 | + /*@ngInject*/ | |
228 | + function($stateParams, ruleChainService) { | |
229 | + return ruleChainService.getRuleNodeComponents(types.ruleChainType.edge); | |
230 | + } | |
231 | + }, | |
232 | + data: { | |
233 | + import: false, | |
234 | + searchEnabled: false, | |
235 | + pageTitle: 'edge.rulechain' | |
236 | + }, | |
237 | + ncyBreadcrumb: { | |
238 | + label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' | |
239 | + } | |
187 | 240 | }); |
188 | 241 | } | ... | ... |
... | ... | @@ -16,12 +16,12 @@ |
16 | 16 | |
17 | 17 | --> |
18 | 18 | <div class="tb-cell" flex="20">{{ event.createdTime | date : 'yyyy-MM-dd HH:mm:ss' }}</div> |
19 | -<div class="tb-cell" flex="20">{{ event.edgeEventType }}</div> | |
20 | -<div class="tb-cell" flex="40">{{ event.edgeEventAction }}</div> | |
19 | +<div class="tb-cell" flex="20">{{ event.type }}</div> | |
20 | +<div class="tb-cell" flex="40">{{ event.action }}</div> | |
21 | 21 | <div class="tb-cell" flex="20">{{ event.entityId }}</div> |
22 | 22 | <div class="tb-cell" flex="15" ng-style="isPending ? {'color': 'rgba(0, 0, 0, .38)'} : {'color': '#000'}">{{ updateStatus(event.createdTime) | translate }}</div> |
23 | 23 | <div class="tb-cell" flex="10"> |
24 | - <md-button class="md-icon-button md-primary" | |
24 | + <md-button ng-if="checkEdgeEventType(event.type)" class="md-icon-button md-primary" | |
25 | 25 | ng-click="showEdgeEntityContent($event, 'edge.entity-info', 'JSON')" |
26 | 26 | aria-label="{{ 'action.view' | translate }}"> |
27 | 27 | <md-tooltip md-direction="top"> | ... | ... |
... | ... | @@ -106,9 +106,9 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $ |
106 | 106 | contentType = null; |
107 | 107 | } |
108 | 108 | var content = ''; |
109 | - switch(scope.event.edgeEventType) { | |
109 | + switch(scope.event.type) { | |
110 | 110 | case types.edgeEventType.relation: |
111 | - content = angular.toJson(scope.event.entityBody); | |
111 | + content = angular.toJson(scope.event.body); | |
112 | 112 | showDialog(); |
113 | 113 | break; |
114 | 114 | case types.edgeEventType.ruleChainMetaData: |
... | ... | @@ -121,7 +121,7 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $ |
121 | 121 | }); |
122 | 122 | break; |
123 | 123 | default: |
124 | - content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {ignoreErrors: true}).then( | |
124 | + content = entityService.getEntity(scope.event.type, scope.event.entityId, {ignoreErrors: true}).then( | |
125 | 125 | function success(info) { |
126 | 126 | showDialog(); |
127 | 127 | return angular.toJson(info); |
... | ... | @@ -150,6 +150,12 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $ |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | + scope.checkEdgeEventType = function (type) { | |
154 | + return !(type === types.edgeEventType.widgetType || | |
155 | + type === types.edgeEventType.adminSettings || | |
156 | + type === types.edgeEventType.widgetsBundle ); | |
157 | + } | |
158 | + | |
153 | 159 | scope.checkTooltip = function($event) { |
154 | 160 | var el = $event.target; |
155 | 161 | var $el = angular.element(el); | ... | ... |
... | ... | @@ -257,9 +257,6 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document, |
257 | 257 | ruleChain.firstRuleNodeId = null; |
258 | 258 | } |
259 | 259 | ruleChain.root = false; |
260 | - delete ruleChain.assignedEdgesText; | |
261 | - delete ruleChain.assignedEdges; | |
262 | - delete ruleChain.assignedEdgesIds; | |
263 | 260 | return ruleChain; |
264 | 261 | } |
265 | 262 | ... | ... |
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | "general-settings": "Allgemeine Einstellungen", |
68 | 68 | "outgoing-mail": "E-Mail Versand", |
69 | 69 | "outgoing-mail-settings": "Konfiguration des Postausgangsservers", |
70 | - "system-settings": "Systeminstellungen", | |
70 | + "system-settings": "Systemeinstellungen", | |
71 | 71 | "test-mail-sent": "Test E-Mail wurde erfolgreich versendet!", |
72 | 72 | "base-url": "Basis-URL", |
73 | 73 | "base-url-required": "Basis-URL ist erforderlich.", | ... | ... |
... | ... | @@ -54,7 +54,7 @@ export default function AddRuleChainsToEdgeController(ruleChainService, $mdDialo |
54 | 54 | vm.ruleChains.pending = true; |
55 | 55 | ruleChainService.getEdgesRuleChains(vm.ruleChains.nextPageLink).then( |
56 | 56 | function success(ruleChains) { |
57 | - vm.ruleChains.data = ruleChains.data; | |
57 | + vm.ruleChains.data = vm.ruleChains.data.concat(ruleChains.data); | |
58 | 58 | vm.ruleChains.nextPageLink = ruleChains.nextPageLink; |
59 | 59 | vm.ruleChains.hasNext = ruleChains.hasNext; |
60 | 60 | if (vm.ruleChains.hasNext) { | ... | ... |
... | ... | @@ -36,11 +36,6 @@ |
36 | 36 | </div> |
37 | 37 | |
38 | 38 | <md-content class="md-padding tb-rulechain-fieldset" layout="column"> |
39 | - <md-input-container class="md-block" | |
40 | - ng-show="!isEdit && ruleChain.assignedEdgesText && ruleChainScope === 'tenant'"> | |
41 | - <label translate>rulechain.assigned-to-edges</label> | |
42 | - <input ng-model="ruleChain.assignedEdgesText" disabled> | |
43 | - </md-input-container> | |
44 | 39 | <fieldset ng-disabled="$root.loading || !isEdit || isReadOnly"> |
45 | 40 | <md-input-container class="md-block"> |
46 | 41 | <label translate>rulechain.name</label> | ... | ... |
... | ... | @@ -1180,7 +1180,7 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
1180 | 1180 | var saveRuleChainPromise; |
1181 | 1181 | if (vm.isImport) { |
1182 | 1182 | if (angular.isUndefined(vm.ruleChain.type)) { |
1183 | - vm.ruleChain.type = types.coreRuleChainType; | |
1183 | + vm.ruleChain.type = types.ruleChainType.core; | |
1184 | 1184 | } |
1185 | 1185 | saveRuleChainPromise = ruleChainService.saveRuleChain(vm.ruleChain); |
1186 | 1186 | } else { |
... | ... | @@ -1269,7 +1269,7 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
1269 | 1269 | vm.isDirty = false; |
1270 | 1270 | vm.isImport = false; |
1271 | 1271 | $mdUtil.nextTick(() => { |
1272 | - if (vm.ruleChain.type === vm.types.coreRuleChainType) { | |
1272 | + if (vm.ruleChain.type === vm.types.ruleChainType.core) { | |
1273 | 1273 | $state.go('home.ruleChains.core.ruleChain', {ruleChainId: vm.ruleChain.id.id}); |
1274 | 1274 | } else { |
1275 | 1275 | $state.go('home.ruleChains.edge.ruleChain', {ruleChainId: vm.ruleChain.id.id}); |
... | ... | @@ -1293,7 +1293,7 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
1293 | 1293 | ruleNode.configuration = angular.copy(ruleNode.component.configurationDescriptor.nodeDefinition.defaultConfiguration); |
1294 | 1294 | |
1295 | 1295 | var ruleChainId = vm.ruleChain.id ? vm.ruleChain.id.id : null; |
1296 | - var ruleChainType = vm.ruleChain.type ? vm.ruleChain.type : types.coreRuleChainType; | |
1296 | + var ruleChainType = vm.ruleChain.type ? vm.ruleChain.type : types.ruleChainType.core; | |
1297 | 1297 | |
1298 | 1298 | vm.enableHotKeys = false; |
1299 | 1299 | ... | ... |
... | ... | @@ -22,8 +22,8 @@ import ruleChainFieldsetTemplate from './rulechain-fieldset.tpl.html'; |
22 | 22 | /*@ngInject*/ |
23 | 23 | export default function RuleChainDirective($compile, $templateCache, $mdDialog, $document, $q, $translate, types, toast) { |
24 | 24 | var linker = function (scope, element) { |
25 | - | |
26 | 25 | var template = $templateCache.get(ruleChainFieldsetTemplate); |
26 | + | |
27 | 27 | element.html(template); |
28 | 28 | |
29 | 29 | scope.onRuleChainIdCopied = function() { | ... | ... |
... | ... | @@ -82,7 +82,7 @@ export default function RuleChainRoutes($stateProvider, NodeTemplatePathProvider |
82 | 82 | ruleNodeComponents: |
83 | 83 | /*@ngInject*/ |
84 | 84 | function($stateParams, ruleChainService) { |
85 | - return ruleChainService.getRuleNodeComponents(types.coreRuleChainType); | |
85 | + return ruleChainService.getRuleNodeComponents(types.ruleChainType.core); | |
86 | 86 | } |
87 | 87 | }, |
88 | 88 | data: { |
... | ... | @@ -180,64 +180,7 @@ export default function RuleChainRoutes($stateProvider, NodeTemplatePathProvider |
180 | 180 | ruleNodeComponents: |
181 | 181 | /*@ngInject*/ |
182 | 182 | function($stateParams, ruleChainService) { |
183 | - return ruleChainService.getRuleNodeComponents(types.edgeRuleChainType); | |
184 | - } | |
185 | - }, | |
186 | - data: { | |
187 | - import: false, | |
188 | - searchEnabled: false, | |
189 | - pageTitle: 'edge.rulechain' | |
190 | - }, | |
191 | - ncyBreadcrumb: { | |
192 | - label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' | |
193 | - } | |
194 | - }).state('home.edges.ruleChains', { | |
195 | - url: '/:edgeId/ruleChains', | |
196 | - params: {'topIndex': 0}, | |
197 | - module: 'private', | |
198 | - auth: ['TENANT_ADMIN'], | |
199 | - views: { | |
200 | - "content@home": { | |
201 | - templateUrl: ruleChainsTemplate, | |
202 | - controllerAs: 'vm', | |
203 | - controller: 'RuleChainsController' | |
204 | - } | |
205 | - }, | |
206 | - data: { | |
207 | - searchEnabled: true, | |
208 | - pageTitle: 'edge.rulechains', | |
209 | - ruleChainsType: 'edge' | |
210 | - }, | |
211 | - ncyBreadcrumb: { | |
212 | - label: '{"icon": "settings_ethernet", "label": "rulechain.edge-rulechains"}' | |
213 | - } | |
214 | - }).state('home.edges.ruleChains.ruleChain', { | |
215 | - url: '/:ruleChainId', | |
216 | - reloadOnSearch: false, | |
217 | - module: 'private', | |
218 | - auth: ['SYS_ADMIN', 'TENANT_ADMIN'], | |
219 | - views: { | |
220 | - "content@home": { | |
221 | - templateUrl: ruleChainTemplate, | |
222 | - controller: 'RuleChainController', | |
223 | - controllerAs: 'vm' | |
224 | - } | |
225 | - }, | |
226 | - resolve: { | |
227 | - ruleChain: | |
228 | - /*@ngInject*/ | |
229 | - function($stateParams, ruleChainService) { | |
230 | - return ruleChainService.getRuleChain($stateParams.ruleChainId); | |
231 | - }, | |
232 | - ruleChainMetaData: | |
233 | - /*@ngInject*/ | |
234 | - function($stateParams, ruleChainService) { | |
235 | - return ruleChainService.getRuleChainMetaData($stateParams.ruleChainId); | |
236 | - }, | |
237 | - ruleNodeComponents: | |
238 | - /*@ngInject*/ | |
239 | - function($stateParams, ruleChainService) { | |
240 | - return ruleChainService.getRuleNodeComponents(types.edgeRuleChainType); | |
183 | + return ruleChainService.getRuleNodeComponents(types.ruleChainType.edge); | |
241 | 184 | } |
242 | 185 | }, |
243 | 186 | data: { | ... | ... |
... | ... | @@ -22,8 +22,8 @@ import addRuleChainsToEdgeTemplate from "./add-rulechains-to-edge.tpl.html"; |
22 | 22 | /* eslint-enable import/no-unresolved, import/default */ |
23 | 23 | |
24 | 24 | /*@ngInject*/ |
25 | -export default function RuleChainsController(ruleChainService, userService, edgeService, importExport, $state, | |
26 | - $stateParams, $filter, $translate, $mdDialog, $document, $q, types) { | |
25 | +export default function RuleChainsController(ruleChainService, userService, importExport, $state, $stateParams, $filter, $translate, $mdDialog, types, | |
26 | + $document, $q, edgeService) { | |
27 | 27 | |
28 | 28 | var vm = this; |
29 | 29 | var edgeId = $stateParams.edgeId; |
... | ... | @@ -114,7 +114,7 @@ export default function RuleChainsController(ruleChainService, userService, edge |
114 | 114 | |
115 | 115 | if (vm.ruleChainsScope === 'tenant') { |
116 | 116 | fetchRuleChainsFunction = function (pageLink) { |
117 | - return fetchRuleChains(pageLink, types.coreRuleChainType); | |
117 | + return fetchRuleChains(pageLink, types.ruleChainType.core); | |
118 | 118 | }; |
119 | 119 | deleteRuleChainFunction = function (ruleChainId) { |
120 | 120 | return deleteRuleChain(ruleChainId); |
... | ... | @@ -162,9 +162,9 @@ export default function RuleChainsController(ruleChainService, userService, edge |
162 | 162 | }); |
163 | 163 | vm.ruleChainGridConfig.addItemActions.push({ |
164 | 164 | onAction: function ($event) { |
165 | - importExport.importRuleChain($event, types.coreRuleChainType).then( | |
165 | + importExport.importRuleChain($event, types.ruleChainType.core).then( | |
166 | 166 | function(ruleChainImport) { |
167 | - $state.go('home.ruleChains.importRuleChain', {ruleChainImport:ruleChainImport, ruleChainType: types.coreRuleChainType}); | |
167 | + $state.go('home.ruleChains.importRuleChain', {ruleChainImport:ruleChainImport, ruleChainType: types.ruleChainType.core}); | |
168 | 168 | } |
169 | 169 | ); |
170 | 170 | }, |
... | ... | @@ -175,7 +175,7 @@ export default function RuleChainsController(ruleChainService, userService, edge |
175 | 175 | |
176 | 176 | } else if (vm.ruleChainsScope === 'edges') { |
177 | 177 | fetchRuleChainsFunction = function (pageLink) { |
178 | - return fetchRuleChains(pageLink, types.edgeRuleChainType); | |
178 | + return fetchRuleChains(pageLink, types.ruleChainType.edge); | |
179 | 179 | }; |
180 | 180 | deleteRuleChainFunction = function (ruleChainId) { |
181 | 181 | return deleteRuleChain(ruleChainId); |
... | ... | @@ -203,21 +203,21 @@ export default function RuleChainsController(ruleChainService, userService, edge |
203 | 203 | |
204 | 204 | ruleChainActionsList.push({ |
205 | 205 | onAction: function ($event, item) { |
206 | - vm.grid.deleteItem($event, item); | |
206 | + setDefaultRootEdgeRuleChain($event, item); | |
207 | 207 | }, |
208 | - name: function() { return $translate.instant('action.delete') }, | |
209 | - details: function() { return $translate.instant('rulechain.delete') }, | |
210 | - icon: "delete", | |
208 | + name: function() { return $translate.instant('rulechain.set-default-root-edge') }, | |
209 | + details: function() { return $translate.instant('rulechain.set-default-root-edge') }, | |
210 | + icon: "flag", | |
211 | 211 | isEnabled: isNonRootRuleChain |
212 | 212 | }); |
213 | 213 | |
214 | 214 | ruleChainActionsList.push({ |
215 | 215 | onAction: function ($event, item) { |
216 | - setDefaultRootEdgeRuleChain($event, item); | |
216 | + vm.grid.deleteItem($event, item); | |
217 | 217 | }, |
218 | - name: function() { return $translate.instant('rulechain.set-default-root-edge') }, | |
219 | - details: function() { return $translate.instant('rulechain.set-default-root-edge') }, | |
220 | - icon: "flag", | |
218 | + name: function() { return $translate.instant('action.delete') }, | |
219 | + details: function() { return $translate.instant('rulechain.delete') }, | |
220 | + icon: "delete", | |
221 | 221 | isEnabled: isNonRootRuleChain |
222 | 222 | }); |
223 | 223 | |
... | ... | @@ -243,9 +243,9 @@ export default function RuleChainsController(ruleChainService, userService, edge |
243 | 243 | }); |
244 | 244 | vm.ruleChainGridConfig.addItemActions.push({ |
245 | 245 | onAction: function ($event) { |
246 | - importExport.importRuleChain($event, types.edgeRuleChainType).then( | |
246 | + importExport.importRuleChain($event, types.ruleChainType.edge).then( | |
247 | 247 | function(ruleChainImport) { |
248 | - $state.go('home.ruleChains.importRuleChain', {ruleChainImport:ruleChainImport, ruleChainType: types.edgeRuleChainType}); | |
248 | + $state.go('home.ruleChains.importRuleChain', {ruleChainImport:ruleChainImport, ruleChainType: types.ruleChainType.edge}); | |
249 | 249 | } |
250 | 250 | ); |
251 | 251 | }, |
... | ... | @@ -383,9 +383,9 @@ export default function RuleChainsController(ruleChainService, userService, edge |
383 | 383 | function saveRuleChain(ruleChain) { |
384 | 384 | if (angular.isUndefined(ruleChain.type)) { |
385 | 385 | if (vm.ruleChainsScope === 'edges') { |
386 | - ruleChain.type = types.edgeRuleChainType; | |
386 | + ruleChain.type = types.ruleChainType.edge; | |
387 | 387 | } else { |
388 | - ruleChain.type = types.coreRuleChainType; | |
388 | + ruleChain.type = types.ruleChainType.core; | |
389 | 389 | } |
390 | 390 | } |
391 | 391 | return ruleChainService.saveRuleChain(ruleChain); |
... | ... | @@ -395,13 +395,13 @@ export default function RuleChainsController(ruleChainService, userService, edge |
395 | 395 | if ($event) { |
396 | 396 | $event.stopPropagation(); |
397 | 397 | } |
398 | - | |
398 | + var ruleChainParams = {ruleChainId: ruleChain.id.id}; | |
399 | 399 | if (vm.ruleChainsScope === 'edge') { |
400 | - $state.go('home.edges.ruleChains.ruleChain', {ruleChainId: ruleChain.id.id, edgeId: vm.edge.id.id}); | |
400 | + $state.go('home.edges.ruleChains.ruleChain', Object.assign(ruleChainParams, edgeId = vm.edge.id.id)); | |
401 | 401 | } else if (vm.ruleChainsScope === 'edges') { |
402 | - $state.go('home.ruleChains.edge.ruleChain', {ruleChainId: ruleChain.id.id}); | |
402 | + $state.go('home.ruleChains.edge.ruleChain', ruleChainParams); | |
403 | 403 | } else { |
404 | - $state.go('home.ruleChains.core.ruleChain', {ruleChainId: ruleChain.id.id}); | |
404 | + $state.go('home.ruleChains.core.ruleChain', ruleChainParams); | |
405 | 405 | } |
406 | 406 | } |
407 | 407 | ... | ... |
... | ... | @@ -24,7 +24,6 @@ |
24 | 24 | <md-tab label="{{ 'rulechain.details' | translate }}"> |
25 | 25 | <tb-rule-chain rule-chain="vm.grid.operatingItem()" |
26 | 26 | is-edit="vm.grid.detailsConfig.isDetailsEditMode" |
27 | - rule-chain-scope="vm.ruleChainsScope" | |
28 | 27 | is-read-only="vm.grid.isDetailsReadOnly(vm.grid.operatingItem())" |
29 | 28 | the-form="vm.grid.detailsForm" |
30 | 29 | on-set-root-rule-chain="vm.setRootRuleChain(event, vm.grid.detailsConfig.currentItem)" | ... | ... |