Showing
8 changed files
with
283 additions
and
291 deletions
@@ -53,13 +53,7 @@ export default function AddDashboardsToEdgeController(dashboardService, types, $ | @@ -53,13 +53,7 @@ export default function AddDashboardsToEdgeController(dashboardService, types, $ | ||
53 | fetchMoreItems_: function () { | 53 | fetchMoreItems_: function () { |
54 | if (vm.dashboards.hasNext && !vm.dashboards.pending) { | 54 | if (vm.dashboards.hasNext && !vm.dashboards.pending) { |
55 | vm.dashboards.pending = true; | 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 | function success(dashboards) { | 57 | function success(dashboards) { |
64 | vm.dashboards.data = vm.dashboards.data.concat(dashboards.data); | 58 | vm.dashboards.data = vm.dashboards.data.concat(dashboards.data); |
65 | vm.dashboards.nextPageLink = dashboards.nextPageLink; | 59 | vm.dashboards.nextPageLink = dashboards.nextPageLink; |
@@ -708,14 +708,7 @@ export function DashboardsController(userService, dashboardService, customerServ | @@ -708,14 +708,7 @@ export function DashboardsController(userService, dashboardService, customerServ | ||
708 | $event.stopPropagation(); | 708 | $event.stopPropagation(); |
709 | } | 709 | } |
710 | var pageSize = 10; | 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 | function success(_dashboards) { | 712 | function success(_dashboards) { |
720 | var dashboards = { | 713 | var dashboards = { |
721 | pageSize: pageSize, | 714 | pageSize: pageSize, |
@@ -21,6 +21,8 @@ import devicesTemplate from "../device/devices.tpl.html"; | @@ -21,6 +21,8 @@ import devicesTemplate from "../device/devices.tpl.html"; | ||
21 | import assetsTemplate from "../asset/assets.tpl.html"; | 21 | import assetsTemplate from "../asset/assets.tpl.html"; |
22 | import dashboardsTemplate from "../dashboard/dashboards.tpl.html"; | 22 | import dashboardsTemplate from "../dashboard/dashboards.tpl.html"; |
23 | import dashboardTemplate from "../dashboard/dashboard.tpl.html"; | 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 | /* eslint-enable import/no-unresolved, import/default */ | 27 | /* eslint-enable import/no-unresolved, import/default */ |
26 | 28 | ||
@@ -49,8 +51,7 @@ export default function EdgeRoutes($stateProvider, types) { | @@ -49,8 +51,7 @@ export default function EdgeRoutes($stateProvider, types) { | ||
49 | ncyBreadcrumb: { | 51 | ncyBreadcrumb: { |
50 | label: '{"icon": "transform", "label": "edge.edges"}' | 52 | label: '{"icon": "transform", "label": "edge.edges"}' |
51 | } | 53 | } |
52 | - }) | ||
53 | - .state('home.edges.entityViews', { | 54 | + }).state('home.edges.entityViews', { |
54 | url: '/:edgeId/entityViews', | 55 | url: '/:edgeId/entityViews', |
55 | params: {'topIndex': 0}, | 56 | params: {'topIndex': 0}, |
56 | module: 'private', | 57 | module: 'private', |
@@ -72,8 +73,7 @@ export default function EdgeRoutes($stateProvider, types) { | @@ -72,8 +73,7 @@ export default function EdgeRoutes($stateProvider, types) { | ||
72 | ncyBreadcrumb: { | 73 | ncyBreadcrumb: { |
73 | label: '{"icon": "view_quilt", "label": "edge.entity-views"}' | 74 | label: '{"icon": "view_quilt", "label": "edge.entity-views"}' |
74 | } | 75 | } |
75 | - }) | ||
76 | - .state('home.edges.devices', { | 76 | + }).state('home.edges.devices', { |
77 | url: '/:edgeId/devices', | 77 | url: '/:edgeId/devices', |
78 | params: {'topIndex': 0}, | 78 | params: {'topIndex': 0}, |
79 | module: 'private', | 79 | module: 'private', |
@@ -95,8 +95,7 @@ export default function EdgeRoutes($stateProvider, types) { | @@ -95,8 +95,7 @@ export default function EdgeRoutes($stateProvider, types) { | ||
95 | ncyBreadcrumb: { | 95 | ncyBreadcrumb: { |
96 | label: '{"icon": "devices_other", "label": "edge.devices"}' | 96 | label: '{"icon": "devices_other", "label": "edge.devices"}' |
97 | } | 97 | } |
98 | - }) | ||
99 | - .state('home.edges.assets', { | 98 | + }).state('home.edges.assets', { |
100 | url: '/:edgeId/assets', | 99 | url: '/:edgeId/assets', |
101 | params: {'topIndex': 0}, | 100 | params: {'topIndex': 0}, |
102 | module: 'private', | 101 | module: 'private', |
@@ -118,29 +117,27 @@ export default function EdgeRoutes($stateProvider, types) { | @@ -118,29 +117,27 @@ export default function EdgeRoutes($stateProvider, types) { | ||
118 | ncyBreadcrumb: { | 117 | ncyBreadcrumb: { |
119 | label: '{"icon": "domain", "label": "edge.assets"}' | 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 | url: '/:dashboardId?state', | 141 | url: '/:dashboardId?state', |
145 | reloadOnSearch: false, | 142 | reloadOnSearch: false, |
146 | module: 'private', | 143 | module: 'private', |
@@ -161,8 +158,7 @@ export default function EdgeRoutes($stateProvider, types) { | @@ -161,8 +158,7 @@ export default function EdgeRoutes($stateProvider, types) { | ||
161 | ncyBreadcrumb: { | 158 | ncyBreadcrumb: { |
162 | label: '{"icon": "dashboard", "label": "{{ vm.dashboard.title }}", "translate": "false"}' | 159 | label: '{"icon": "dashboard", "label": "{{ vm.dashboard.title }}", "translate": "false"}' |
163 | } | 160 | } |
164 | - }) | ||
165 | - .state('home.customers.edges', { | 161 | + }).state('home.customers.edges', { |
166 | url: '/:customerId/edges', | 162 | url: '/:customerId/edges', |
167 | params: {'topIndex': 0}, | 163 | params: {'topIndex': 0}, |
168 | module: 'private', | 164 | module: 'private', |
@@ -184,5 +180,62 @@ export default function EdgeRoutes($stateProvider, types) { | @@ -184,5 +180,62 @@ export default function EdgeRoutes($stateProvider, types) { | ||
184 | ncyBreadcrumb: { | 180 | ncyBreadcrumb: { |
185 | label: '{"icon": "router", "label": "{{ vm.customerEdgesTitle }}", "translate": "false"}' | 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,12 +16,12 @@ | ||
16 | 16 | ||
17 | --> | 17 | --> |
18 | <div class="tb-cell" flex="20">{{ event.createdTime | date : 'yyyy-MM-dd HH:mm:ss' }}</div> | 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 | <div class="tb-cell" flex="20">{{ event.entityId }}</div> | 21 | <div class="tb-cell" flex="20">{{ event.entityId }}</div> |
22 | <div class="tb-cell" flex="15" ng-style="isPending ? {'color': 'rgba(0, 0, 0, .38)'} : {'color': '#000'}">{{ updateStatus(event.createdTime) | translate }}</div> | 22 | <div class="tb-cell" flex="15" ng-style="isPending ? {'color': 'rgba(0, 0, 0, .38)'} : {'color': '#000'}">{{ updateStatus(event.createdTime) | translate }}</div> |
23 | <div class="tb-cell" flex="10"> | 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 | ng-click="showEdgeEntityContent($event, 'edge.entity-info', 'JSON')" | 25 | ng-click="showEdgeEntityContent($event, 'edge.entity-info', 'JSON')" |
26 | aria-label="{{ 'action.view' | translate }}"> | 26 | aria-label="{{ 'action.view' | translate }}"> |
27 | <md-tooltip md-direction="top"> | 27 | <md-tooltip md-direction="top"> |
1 | -/* | ||
2 | - * Copyright © 2016-2020 The Thingsboard Authors | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -/* eslint-disable import/no-unresolved, import/default */ | ||
17 | - | ||
18 | -import eventErrorDialogTemplate from './event-content-dialog.tpl.html'; | ||
19 | - | ||
20 | -import eventRowLcEventTemplate from './event-row-lc-event.tpl.html'; | ||
21 | -import eventRowStatsTemplate from './event-row-stats.tpl.html'; | ||
22 | -import eventRowErrorTemplate from './event-row-error.tpl.html'; | ||
23 | -import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html'; | ||
24 | -import eventRowEdgeEventTemplate from './event-row-edge-event.tpl.html'; | ||
25 | - | ||
26 | -/* eslint-enable import/no-unresolved, import/default */ | ||
27 | - | ||
28 | -/*@ngInject*/ | ||
29 | -export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, $translate, | ||
30 | - types, utils, toast, entityService, ruleChainService) { | ||
31 | - | ||
32 | - var linker = function (scope, element, attrs) { | ||
33 | - | ||
34 | - var getTemplate = function(eventType) { | ||
35 | - var template = ''; | ||
36 | - switch(eventType) { | ||
37 | - case types.eventType.lcEvent.value: | ||
38 | - template = eventRowLcEventTemplate; | ||
39 | - break; | ||
40 | - case types.eventType.stats.value: | ||
41 | - template = eventRowStatsTemplate; | ||
42 | - break; | ||
43 | - case types.eventType.error.value: | ||
44 | - template = eventRowErrorTemplate; | ||
45 | - break; | ||
46 | - case types.debugEventType.debugRuleNode.value: | ||
47 | - template = eventRowDebugRuleNodeTemplate; | ||
48 | - break; | ||
49 | - case types.debugEventType.debugRuleChain.value: | ||
50 | - template = eventRowDebugRuleNodeTemplate; | ||
51 | - break; | ||
52 | - case types.eventType.edgeEvent.value: | ||
53 | - template = eventRowEdgeEventTemplate; | ||
54 | - break; | ||
55 | - } | ||
56 | - return $templateCache.get(template); | ||
57 | - } | ||
58 | - | ||
59 | - scope.loadTemplate = function() { | ||
60 | - element.html(getTemplate(attrs.eventType)); | ||
61 | - $compile(element.contents())(scope); | ||
62 | - } | ||
63 | - | ||
64 | - attrs.$observe('eventType', function() { | ||
65 | - scope.loadTemplate(); | ||
66 | - }); | ||
67 | - | ||
68 | - scope.types = types; | ||
69 | - | ||
70 | - scope.event = attrs.event; | ||
71 | - | ||
72 | - scope.showContent = function($event, content, title, contentType) { | ||
73 | - var onShowingCallback = { | ||
74 | - onShowing: function(){} | ||
75 | - } | ||
76 | - if (!contentType) { | ||
77 | - contentType = null; | ||
78 | - } | ||
79 | - var sortedContent; | ||
80 | - try { | ||
81 | - sortedContent = angular.toJson(utils.sortObjectKeys(angular.fromJson(content))); | ||
82 | - } | ||
83 | - catch(err) { | ||
84 | - sortedContent = content; | ||
85 | - } | ||
86 | - $mdDialog.show({ | ||
87 | - controller: 'EventContentDialogController', | ||
88 | - controllerAs: 'vm', | ||
89 | - templateUrl: eventErrorDialogTemplate, | ||
90 | - locals: {content: sortedContent, title: title, contentType: contentType, showingCallback: onShowingCallback}, | ||
91 | - parent: angular.element($document[0].body), | ||
92 | - fullscreen: true, | ||
93 | - targetEvent: $event, | ||
94 | - multiple: true, | ||
95 | - onShowing: function(scope, element) { | ||
96 | - onShowingCallback.onShowing(scope, element); | ||
97 | - } | ||
98 | - }); | ||
99 | - } | ||
100 | - | ||
101 | - scope.showEdgeEntityContent = function($event, title, contentType) { | ||
102 | - var onShowingCallback = { | ||
103 | - onShowing: function(){} | ||
104 | - } | ||
105 | - if (!contentType) { | ||
106 | - contentType = null; | ||
107 | - } | ||
108 | - var content = ''; | ||
109 | - switch(scope.event.edgeEventType) { | ||
110 | - case types.edgeEventType.relation: | ||
111 | - content = angular.toJson(scope.event.entityBody); | ||
112 | - showDialog(); | ||
113 | - break; | ||
114 | - case types.edgeEventType.ruleChainMetaData: | ||
115 | - content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {ignoreErrors: true}).then( | ||
116 | - function success(info) { | ||
117 | - showDialog(); | ||
118 | - return angular.toJson(info); | ||
119 | - }, function fail() { | ||
120 | - showError(); | ||
121 | - }); | ||
122 | - break; | ||
123 | - default: | ||
124 | - content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {ignoreErrors: true}).then( | ||
125 | - function success(info) { | ||
126 | - showDialog(); | ||
127 | - return angular.toJson(info); | ||
128 | - }, function fail() { | ||
129 | - showError(); | ||
130 | - }); | ||
131 | - break; | ||
132 | - } | ||
133 | - function showDialog() { | ||
134 | - $mdDialog.show({ | ||
135 | - controller: 'EventContentDialogController', | ||
136 | - controllerAs: 'vm', | ||
137 | - templateUrl: eventErrorDialogTemplate, | ||
138 | - locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback}, | ||
139 | - parent: angular.element($document[0].body), | ||
140 | - fullscreen: true, | ||
141 | - targetEvent: $event, | ||
142 | - multiple: true, | ||
143 | - onShowing: function(scope, element) { | ||
144 | - onShowingCallback.onShowing(scope, element); | ||
145 | - } | ||
146 | - }); | ||
147 | - } | ||
148 | - function showError() { | ||
149 | - toast.showError($translate.instant('edge.load-entity-error')); | ||
150 | - } | ||
151 | - } | ||
152 | - | ||
153 | - scope.checkTooltip = function($event) { | ||
154 | - var el = $event.target; | ||
155 | - var $el = angular.element(el); | ||
156 | - if(el.offsetWidth < el.scrollWidth && !$el.attr('title')){ | ||
157 | - $el.attr('title', $el.text()); | ||
158 | - } | ||
159 | - } | ||
160 | - | ||
161 | - $compile(element.contents())(scope); | ||
162 | - | ||
163 | - scope.updateStatus = function(eventCreatedTime) { | ||
164 | - if (scope.queueStartTs) { | ||
165 | - var status; | ||
166 | - if (eventCreatedTime < scope.queueStartTs) { | ||
167 | - status = $translate.instant('edge.success'); | ||
168 | - scope.isPending = false; | ||
169 | - } else { | ||
170 | - status = $translate.instant('edge.failed'); | ||
171 | - scope.isPending = true; | ||
172 | - } | ||
173 | - return status; | ||
174 | - } | ||
175 | - } | ||
176 | - } | ||
177 | - | ||
178 | - return { | ||
179 | - restrict: "A", | ||
180 | - replace: false, | ||
181 | - link: linker, | ||
182 | - scope: false | ||
183 | - }; | ||
184 | -} | 1 | +/* |
2 | + * Copyright © 2016-2020 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +/* eslint-disable import/no-unresolved, import/default */ | ||
17 | + | ||
18 | +import eventErrorDialogTemplate from './event-content-dialog.tpl.html'; | ||
19 | + | ||
20 | +import eventRowLcEventTemplate from './event-row-lc-event.tpl.html'; | ||
21 | +import eventRowStatsTemplate from './event-row-stats.tpl.html'; | ||
22 | +import eventRowErrorTemplate from './event-row-error.tpl.html'; | ||
23 | +import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html'; | ||
24 | +import eventRowEdgeEventTemplate from './event-row-edge-event.tpl.html'; | ||
25 | + | ||
26 | +/* eslint-enable import/no-unresolved, import/default */ | ||
27 | + | ||
28 | +/*@ngInject*/ | ||
29 | +export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, $translate, | ||
30 | + types, utils, toast, entityService, ruleChainService) { | ||
31 | + | ||
32 | + var linker = function (scope, element, attrs) { | ||
33 | + | ||
34 | + var getTemplate = function(eventType) { | ||
35 | + var template = ''; | ||
36 | + switch(eventType) { | ||
37 | + case types.eventType.lcEvent.value: | ||
38 | + template = eventRowLcEventTemplate; | ||
39 | + break; | ||
40 | + case types.eventType.stats.value: | ||
41 | + template = eventRowStatsTemplate; | ||
42 | + break; | ||
43 | + case types.eventType.error.value: | ||
44 | + template = eventRowErrorTemplate; | ||
45 | + break; | ||
46 | + case types.debugEventType.debugRuleNode.value: | ||
47 | + template = eventRowDebugRuleNodeTemplate; | ||
48 | + break; | ||
49 | + case types.debugEventType.debugRuleChain.value: | ||
50 | + template = eventRowDebugRuleNodeTemplate; | ||
51 | + break; | ||
52 | + case types.eventType.edgeEvent.value: | ||
53 | + template = eventRowEdgeEventTemplate; | ||
54 | + break; | ||
55 | + } | ||
56 | + return $templateCache.get(template); | ||
57 | + } | ||
58 | + | ||
59 | + scope.loadTemplate = function() { | ||
60 | + element.html(getTemplate(attrs.eventType)); | ||
61 | + $compile(element.contents())(scope); | ||
62 | + } | ||
63 | + | ||
64 | + attrs.$observe('eventType', function() { | ||
65 | + scope.loadTemplate(); | ||
66 | + }); | ||
67 | + | ||
68 | + scope.types = types; | ||
69 | + | ||
70 | + scope.event = attrs.event; | ||
71 | + | ||
72 | + scope.showContent = function($event, content, title, contentType) { | ||
73 | + var onShowingCallback = { | ||
74 | + onShowing: function(){} | ||
75 | + } | ||
76 | + if (!contentType) { | ||
77 | + contentType = null; | ||
78 | + } | ||
79 | + var sortedContent; | ||
80 | + try { | ||
81 | + sortedContent = angular.toJson(utils.sortObjectKeys(angular.fromJson(content))); | ||
82 | + } | ||
83 | + catch(err) { | ||
84 | + sortedContent = content; | ||
85 | + } | ||
86 | + $mdDialog.show({ | ||
87 | + controller: 'EventContentDialogController', | ||
88 | + controllerAs: 'vm', | ||
89 | + templateUrl: eventErrorDialogTemplate, | ||
90 | + locals: {content: sortedContent, title: title, contentType: contentType, showingCallback: onShowingCallback}, | ||
91 | + parent: angular.element($document[0].body), | ||
92 | + fullscreen: true, | ||
93 | + targetEvent: $event, | ||
94 | + multiple: true, | ||
95 | + onShowing: function(scope, element) { | ||
96 | + onShowingCallback.onShowing(scope, element); | ||
97 | + } | ||
98 | + }); | ||
99 | + } | ||
100 | + | ||
101 | + scope.showEdgeEntityContent = function($event, title, contentType) { | ||
102 | + var onShowingCallback = { | ||
103 | + onShowing: function(){} | ||
104 | + } | ||
105 | + if (!contentType) { | ||
106 | + contentType = null; | ||
107 | + } | ||
108 | + var content = ''; | ||
109 | + switch(scope.event.type) { | ||
110 | + case types.edgeEventType.relation: | ||
111 | + case types.edgeEventType.whiteLabeling: | ||
112 | + case types.edgeEventType.loginWhiteLabeling: | ||
113 | + case types.edgeEventType.customTranslation: | ||
114 | + content = angular.toJson(scope.event.body); | ||
115 | + showDialog(); | ||
116 | + break; | ||
117 | + case types.edgeEventType.ruleChainMetaData: | ||
118 | + content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {ignoreErrors: true}).then( | ||
119 | + function success(info) { | ||
120 | + showDialog(); | ||
121 | + return angular.toJson(info); | ||
122 | + }, function fail() { | ||
123 | + showError(); | ||
124 | + }); | ||
125 | + break; | ||
126 | + default: | ||
127 | + content = entityService.getEntity(scope.event.type, scope.event.entityId, {ignoreErrors: true}).then( | ||
128 | + function success(info) { | ||
129 | + showDialog(); | ||
130 | + return angular.toJson(info); | ||
131 | + }, function fail() { | ||
132 | + showError(); | ||
133 | + }); | ||
134 | + break; | ||
135 | + } | ||
136 | + function showDialog() { | ||
137 | + $mdDialog.show({ | ||
138 | + controller: 'EventContentDialogController', | ||
139 | + controllerAs: 'vm', | ||
140 | + templateUrl: eventErrorDialogTemplate, | ||
141 | + locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback}, | ||
142 | + parent: angular.element($document[0].body), | ||
143 | + fullscreen: true, | ||
144 | + targetEvent: $event, | ||
145 | + multiple: true, | ||
146 | + onShowing: function(scope, element) { | ||
147 | + onShowingCallback.onShowing(scope, element); | ||
148 | + } | ||
149 | + }); | ||
150 | + } | ||
151 | + function showError() { | ||
152 | + toast.showError($translate.instant('edge.load-entity-error')); | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + scope.checkEdgeEventType = function (edgeEventType) { | ||
157 | + return !(edgeEventType === types.edgeEventType.widgetType || | ||
158 | + edgeEventType === types.edgeEventType.adminSettings || | ||
159 | + edgeEventType === types.edgeEventType.widgetsBundle ); | ||
160 | + } | ||
161 | + | ||
162 | + scope.checkTooltip = function($event) { | ||
163 | + var el = $event.target; | ||
164 | + var $el = angular.element(el); | ||
165 | + if(el.offsetWidth < el.scrollWidth && !$el.attr('title')){ | ||
166 | + $el.attr('title', $el.text()); | ||
167 | + } | ||
168 | + } | ||
169 | + | ||
170 | + $compile(element.contents())(scope); | ||
171 | + | ||
172 | + scope.updateStatus = function(eventCreatedTime) { | ||
173 | + if (scope.queueStartTs) { | ||
174 | + var status; | ||
175 | + if (eventCreatedTime < scope.queueStartTs) { | ||
176 | + status = $translate.instant('edge.success'); | ||
177 | + scope.isPending = false; | ||
178 | + } else { | ||
179 | + status = $translate.instant('edge.failed'); | ||
180 | + scope.isPending = true; | ||
181 | + } | ||
182 | + return status; | ||
183 | + } | ||
184 | + } | ||
185 | + } | ||
186 | + | ||
187 | + return { | ||
188 | + restrict: "A", | ||
189 | + replace: false, | ||
190 | + link: linker, | ||
191 | + scope: false | ||
192 | + }; | ||
193 | +} |
@@ -54,7 +54,7 @@ export default function AddRuleChainsToEdgeController(ruleChainService, $mdDialo | @@ -54,7 +54,7 @@ export default function AddRuleChainsToEdgeController(ruleChainService, $mdDialo | ||
54 | vm.ruleChains.pending = true; | 54 | vm.ruleChains.pending = true; |
55 | ruleChainService.getEdgesRuleChains(vm.ruleChains.nextPageLink).then( | 55 | ruleChainService.getEdgesRuleChains(vm.ruleChains.nextPageLink).then( |
56 | function success(ruleChains) { | 56 | function success(ruleChains) { |
57 | - vm.ruleChains.data = ruleChains.data; | 57 | + vm.ruleChains.data = vm.ruleChains.data.concat(ruleChains.data); |
58 | vm.ruleChains.nextPageLink = ruleChains.nextPageLink; | 58 | vm.ruleChains.nextPageLink = ruleChains.nextPageLink; |
59 | vm.ruleChains.hasNext = ruleChains.hasNext; | 59 | vm.ruleChains.hasNext = ruleChains.hasNext; |
60 | if (vm.ruleChains.hasNext) { | 60 | if (vm.ruleChains.hasNext) { |
@@ -191,62 +191,5 @@ export default function RuleChainRoutes($stateProvider, NodeTemplatePathProvider | @@ -191,62 +191,5 @@ export default function RuleChainRoutes($stateProvider, NodeTemplatePathProvider | ||
191 | ncyBreadcrumb: { | 191 | ncyBreadcrumb: { |
192 | label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' | 192 | label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' |
193 | } | 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.ruleChainType.edge); | ||
241 | - } | ||
242 | - }, | ||
243 | - data: { | ||
244 | - import: false, | ||
245 | - searchEnabled: false, | ||
246 | - pageTitle: 'edge.rulechain' | ||
247 | - }, | ||
248 | - ncyBreadcrumb: { | ||
249 | - label: '{"icon": "settings_ethernet", "label": "{{ vm.ruleChain.name }}", "translate": "false"}' | ||
250 | - } | ||
251 | }); | 194 | }); |
252 | } | 195 | } |
@@ -397,7 +397,7 @@ export default function RuleChainsController(ruleChainService, userService, impo | @@ -397,7 +397,7 @@ export default function RuleChainsController(ruleChainService, userService, impo | ||
397 | } | 397 | } |
398 | var ruleChainParams = {ruleChainId: ruleChain.id.id}; | 398 | var ruleChainParams = {ruleChainId: ruleChain.id.id}; |
399 | if (vm.ruleChainsScope === 'edge') { | 399 | if (vm.ruleChainsScope === 'edge') { |
400 | - $state.go('home.edges.ruleChains.ruleChain', {...ruleChainParams, edgeId: vm.edge.id.id}); | 400 | + $state.go('home.edges.ruleChains.ruleChain', Object.assign(ruleChainParams, edgeId = vm.edge.id.id)); |
401 | } else if (vm.ruleChainsScope === 'edges') { | 401 | } else if (vm.ruleChainsScope === 'edges') { |
402 | $state.go('home.ruleChains.edge.ruleChain', ruleChainParams); | 402 | $state.go('home.ruleChains.edge.ruleChain', ruleChainParams); |
403 | } else { | 403 | } else { |