Commit 5ac2ca3a26292f38f143875b7c728e20cd82fc36
1 parent
cd2e89e8
Added Downlink edge tab. UI data implementation
Showing
7 changed files
with
136 additions
and
5 deletions
... | ... | @@ -600,6 +600,10 @@ export default angular.module('thingsboard.types', []) |
600 | 600 | stats: { |
601 | 601 | value: "STATS", |
602 | 602 | name: "event.type-stats" |
603 | + }, | |
604 | + edgeEvent: { | |
605 | + value: "EDGE_EVENT", | |
606 | + name: "event.type-edge-event" | |
603 | 607 | } |
604 | 608 | }, |
605 | 609 | debugEventType: { | ... | ... |
1 | +<!-- | |
2 | + | |
3 | + Copyright © 2016-2020 The Thingsboard Authors | |
4 | + | |
5 | + Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | + you may not use this file except in compliance with the License. | |
7 | + You may obtain a copy of the License at | |
8 | + | |
9 | + http://www.apache.org/licenses/LICENSE-2.0 | |
10 | + | |
11 | + Unless required by applicable law or agreed to in writing, software | |
12 | + distributed under the License is distributed on an "AS IS" BASIS, | |
13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | + See the License for the specific language governing permissions and | |
15 | + limitations under the License. | |
16 | + | |
17 | +--> | |
18 | +<div translate class="tb-cell" flex="30">event.event-time</div> | |
19 | +<div translate class="tb-cell" flex="20">event.event-type</div> | |
20 | +<div translate class="tb-cell" flex="20">edge.entity-id</div> | |
21 | +<div translate class="tb-cell" flex="20">edge.event-action</div> | |
22 | +<div translate class="tb-cell" flex="20">event.success</div> | |
23 | +<div translate class="tb-cell" flex="20">edge.entity-info</div> | ... | ... |
... | ... | @@ -19,6 +19,7 @@ import eventHeaderLcEventTemplate from './event-header-lc-event.tpl.html'; |
19 | 19 | import eventHeaderStatsTemplate from './event-header-stats.tpl.html'; |
20 | 20 | import eventHeaderErrorTemplate from './event-header-error.tpl.html'; |
21 | 21 | import eventHeaderDebugRuleNodeTemplate from './event-header-debug-rulenode.tpl.html'; |
22 | +import eventHeaderEdgeEventTemplate from './event-header-edge-event.tpl.html' | |
22 | 23 | |
23 | 24 | /* eslint-enable import/no-unresolved, import/default */ |
24 | 25 | |
... | ... | @@ -45,6 +46,9 @@ export default function EventHeaderDirective($compile, $templateCache, types) { |
45 | 46 | case types.debugEventType.debugRuleChain.value: |
46 | 47 | template = eventHeaderDebugRuleNodeTemplate; |
47 | 48 | break; |
49 | + case types.eventType.edgeEvent.value: | |
50 | + template = eventHeaderEdgeEventTemplate; | |
51 | + break; | |
48 | 52 | } |
49 | 53 | return $templateCache.get(template); |
50 | 54 | } | ... | ... |
1 | +<!-- | |
2 | + | |
3 | + Copyright © 2016-2020 The Thingsboard Authors | |
4 | + | |
5 | + Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | + you may not use this file except in compliance with the License. | |
7 | + You may obtain a copy of the License at | |
8 | + | |
9 | + http://www.apache.org/licenses/LICENSE-2.0 | |
10 | + | |
11 | + Unless required by applicable law or agreed to in writing, software | |
12 | + distributed under the License is distributed on an "AS IS" BASIS, | |
13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | + See the License for the specific language governing permissions and | |
15 | + limitations under the License. | |
16 | + | |
17 | +--> | |
18 | +<div class="tb-cell" flex="30">{{event.createdTime | date : 'yyyy-MM-dd HH:mm:ss'}}</div> | |
19 | +<div class="tb-cell" flex="20">{{event.edgeEventAction}}</div> | |
20 | +<div class="tb-cell" flex="20">{{event.entityId}}</div> | |
21 | +<div class="tb-cell" flex="20">{{event.entityType}}</div> | |
22 | +<div translate class="tb-cell" flex="20">{{event.success ? 'event.success' : 'event.failed'}}</div> | |
23 | +<div class="tb-cell" flex="20"> | |
24 | + <md-button class="md-icon-button md-primary" | |
25 | + ng-click="showEdgeEntityContent($event, 'edge.entity-info', 'JSON')" | |
26 | + aria-label="{{ 'action.view' | translate }}"> | |
27 | + <md-tooltip md-direction="top"> | |
28 | + {{ 'action.view' | translate }} | |
29 | + </md-tooltip> | |
30 | + <md-icon aria-label="{{ 'action.view' | translate }}" | |
31 | + class="material-icons"> | |
32 | + more_horiz | |
33 | + </md-icon> | |
34 | + </md-button> | |
35 | +</div> | |
36 | + | ... | ... |
... | ... | @@ -21,11 +21,12 @@ import eventRowLcEventTemplate from './event-row-lc-event.tpl.html'; |
21 | 21 | import eventRowStatsTemplate from './event-row-stats.tpl.html'; |
22 | 22 | import eventRowErrorTemplate from './event-row-error.tpl.html'; |
23 | 23 | import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html'; |
24 | +import eventRowEdgeEventTemplate from './event-row-edge-event.tpl.html'; | |
24 | 25 | |
25 | 26 | /* eslint-enable import/no-unresolved, import/default */ |
26 | 27 | |
27 | 28 | /*@ngInject*/ |
28 | -export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, types) { | |
29 | +export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, $translate, types, toast, entityService) { | |
29 | 30 | |
30 | 31 | var linker = function (scope, element, attrs) { |
31 | 32 | |
... | ... | @@ -47,6 +48,9 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $ |
47 | 48 | case types.debugEventType.debugRuleChain.value: |
48 | 49 | template = eventRowDebugRuleNodeTemplate; |
49 | 50 | break; |
51 | + case types.eventType.edgeEvent.value: | |
52 | + template = eventRowEdgeEventTemplate; | |
53 | + break; | |
50 | 54 | } |
51 | 55 | return $templateCache.get(template); |
52 | 56 | } |
... | ... | @@ -86,6 +90,36 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $ |
86 | 90 | }); |
87 | 91 | } |
88 | 92 | |
93 | + scope.showEdgeEntityContent = function($event, title, contentType) { | |
94 | + var onShowingCallback = { | |
95 | + onShowing: function(){} | |
96 | + } | |
97 | + if (!contentType) { | |
98 | + contentType = null; | |
99 | + } | |
100 | + entityService.getEntity(scope.event.entityType, scope.event.entityId, {}).then( | |
101 | + function success(info) { | |
102 | + var content = angular.toJson(info); | |
103 | + $mdDialog.show({ | |
104 | + controller: 'EventContentDialogController', | |
105 | + controllerAs: 'vm', | |
106 | + templateUrl: eventErrorDialogTemplate, | |
107 | + locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback}, | |
108 | + parent: angular.element($document[0].body), | |
109 | + fullscreen: true, | |
110 | + targetEvent: $event, | |
111 | + multiple: true, | |
112 | + onShowing: function(scope, element) { | |
113 | + onShowingCallback.onShowing(scope, element); | |
114 | + } | |
115 | + }); | |
116 | + }, | |
117 | + function fail() { | |
118 | + toast.showError($translate.instant('edge.load-entity-error')); | |
119 | + } | |
120 | + ); | |
121 | + } | |
122 | + | |
89 | 123 | scope.checkTooltip = function($event) { |
90 | 124 | var el = $event.target; |
91 | 125 | var $el = angular.element(el); | ... | ... |
... | ... | @@ -24,6 +24,27 @@ import eventTableTemplate from './event-table.tpl.html'; |
24 | 24 | /*@ngInject*/ |
25 | 25 | export default function EventTableDirective($compile, $templateCache, $rootScope, types, eventService) { |
26 | 26 | |
27 | + var edgeData = [ | |
28 | + { | |
29 | + "createdTime": 1593592774537, | |
30 | + "tenantId": "63746950-bb76-11ea-9f96-69d7782607f7", | |
31 | + "edgeId": "85bb84b0-bb78-11ea-8472-c3dbdeb0fd97", | |
32 | + "edgeEventAction": "ASSIGNED_TO_EDGE", | |
33 | + "entityId": "640055a0-bb76-11ea-9f96-69d7782607f7", | |
34 | + "entityType": "DEVICE", | |
35 | + "success": true, | |
36 | + }, | |
37 | + { | |
38 | + "createdTime": 1593592774538, | |
39 | + "tenantId": "63746950-bb76-11ea-9f96-69d7782607f7", | |
40 | + "edgeId": "85bb84b0-bb78-11ea-8472-c3dbdeb0fd97", | |
41 | + "edgeEventAction": "CREDENTIALS_UPDATED", | |
42 | + "entityId": "640055a0-bb76-11ea-9f96-69d7782607f8", | |
43 | + "entityType": "DEVICE", | |
44 | + "success": false | |
45 | + } | |
46 | + ] | |
47 | + | |
27 | 48 | var linker = function (scope, element, attrs) { |
28 | 49 | |
29 | 50 | var template = $templateCache.get(eventTableTemplate); |
... | ... | @@ -98,7 +119,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
98 | 119 | }, |
99 | 120 | |
100 | 121 | fetchMoreItems_: function () { |
101 | - if (scope.events.hasNext && !scope.events.pending) { | |
122 | + if (scope.events.hasNext && !scope.events.pending && scope.eventType !== "EDGE_EVENT") { | |
102 | 123 | if (scope.entityType && scope.entityId && scope.eventType && scope.tenantId) { |
103 | 124 | var promise = eventService.getEvents(scope.entityType, scope.entityId, |
104 | 125 | scope.eventType, scope.tenantId, scope.events.nextPageLink); |
... | ... | @@ -125,12 +146,16 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
125 | 146 | scope.events.hasNext = false; |
126 | 147 | } |
127 | 148 | } |
149 | + if (scope.eventType === "EDGE_EVENT") { | |
150 | + scope.events.data = edgeData; | |
151 | + scope.events.nextPageLink = false; | |
152 | + scope.events.hasNext = null; | |
153 | + } | |
128 | 154 | } |
129 | 155 | }; |
130 | 156 | |
131 | 157 | scope.$watch("entityId", function(newVal, prevVal) { |
132 | 158 | if (newVal && !angular.equals(newVal, prevVal)) { |
133 | - scope.resetFilter(); | |
134 | 159 | scope.reload(); |
135 | 160 | } |
136 | 161 | }); |
... | ... | @@ -141,7 +166,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
141 | 166 | } |
142 | 167 | }); |
143 | 168 | |
144 | - scope.$watch("timewindow", function(newVal, prevVal) { | |
169 | + scope.$watch("createdTime", function(newVal, prevVal) { | |
145 | 170 | if (newVal && !angular.equals(newVal, prevVal)) { |
146 | 171 | scope.reload(); |
147 | 172 | } | ... | ... |
... | ... | @@ -791,14 +791,17 @@ |
791 | 791 | "name": "Name", |
792 | 792 | "name-required": "Name is required.", |
793 | 793 | "description": "Description", |
794 | - "events": "Events", | |
794 | + "entity-info": "Entity info", | |
795 | 795 | "details": "Details", |
796 | + "events": "Events", | |
796 | 797 | "copy-id": "Copy Edge Id", |
797 | 798 | "id-copied-message": "Edge Id has been copied to clipboard", |
798 | 799 | "permissions": "Permissions", |
799 | 800 | "edge-required": "Edge required", |
800 | 801 | "edge-type": "Edge type", |
801 | 802 | "edge-type-required": "Edge type is required.", |
803 | + "event-action": "Event action", | |
804 | + "entity-id": "Entity ID", | |
802 | 805 | "select-edge-type": "Select edge type", |
803 | 806 | "assign-to-customer": "Assign to customer", |
804 | 807 | "assign-to-customer-text": "Please select the customer to assign the edge(s)", |
... | ... | @@ -818,6 +821,7 @@ |
818 | 821 | "make-private-edge-text": "After the confirmation the edge and all its data will be made private and won't be accessible by others.", |
819 | 822 | "import": "Import edge", |
820 | 823 | "label": "Label", |
824 | + "load-entity-error": "Could not load entity info", | |
821 | 825 | "assign-new-edge": "Assign new edge", |
822 | 826 | "manage-edge-dashboards": "Manage edge dashboards", |
823 | 827 | "unassign-from-edge": "Unassign from edge", |
... | ... | @@ -1082,6 +1086,7 @@ |
1082 | 1086 | "type-debug-rule-chain": "Debug", |
1083 | 1087 | "no-events-prompt": "No events found", |
1084 | 1088 | "error": "Error", |
1089 | + "type-edge-event": "Downlink", | |
1085 | 1090 | "alarm": "Alarm", |
1086 | 1091 | "event-time": "Event time", |
1087 | 1092 | "server": "Server", | ... | ... |