Browse Source

Added Downlink edge tab. UI data implementation

pull/2436/head
deaflynx 6 years ago
parent
commit
5ac2ca3a26
  1. 4
      ui/src/app/common/types.constant.js
  2. 23
      ui/src/app/event/event-header-edge-event.tpl.html
  3. 4
      ui/src/app/event/event-header.directive.js
  4. 36
      ui/src/app/event/event-row-edge-event.tpl.html
  5. 36
      ui/src/app/event/event-row.directive.js
  6. 31
      ui/src/app/event/event-table.directive.js
  7. 7
      ui/src/app/locale/locale.constant-en_US.json

4
ui/src/app/common/types.constant.js

@ -600,6 +600,10 @@ export default angular.module('thingsboard.types', [])
stats: {
value: "STATS",
name: "event.type-stats"
},
edgeEvent: {
value: "EDGE_EVENT",
name: "event.type-edge-event"
}
},
debugEventType: {

23
ui/src/app/event/event-header-edge-event.tpl.html

@ -0,0 +1,23 @@
<!--
Copyright © 2016-2020 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div translate class="tb-cell" flex="30">event.event-time</div>
<div translate class="tb-cell" flex="20">event.event-type</div>
<div translate class="tb-cell" flex="20">edge.entity-id</div>
<div translate class="tb-cell" flex="20">edge.event-action</div>
<div translate class="tb-cell" flex="20">event.success</div>
<div translate class="tb-cell" flex="20">edge.entity-info</div>

4
ui/src/app/event/event-header.directive.js

@ -19,6 +19,7 @@ import eventHeaderLcEventTemplate from './event-header-lc-event.tpl.html';
import eventHeaderStatsTemplate from './event-header-stats.tpl.html';
import eventHeaderErrorTemplate from './event-header-error.tpl.html';
import eventHeaderDebugRuleNodeTemplate from './event-header-debug-rulenode.tpl.html';
import eventHeaderEdgeEventTemplate from './event-header-edge-event.tpl.html'
/* eslint-enable import/no-unresolved, import/default */
@ -45,6 +46,9 @@ export default function EventHeaderDirective($compile, $templateCache, types) {
case types.debugEventType.debugRuleChain.value:
template = eventHeaderDebugRuleNodeTemplate;
break;
case types.eventType.edgeEvent.value:
template = eventHeaderEdgeEventTemplate;
break;
}
return $templateCache.get(template);
}

36
ui/src/app/event/event-row-edge-event.tpl.html

@ -0,0 +1,36 @@
<!--
Copyright © 2016-2020 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="tb-cell" flex="30">{{event.createdTime | date : 'yyyy-MM-dd HH:mm:ss'}}</div>
<div class="tb-cell" flex="20">{{event.edgeEventAction}}</div>
<div class="tb-cell" flex="20">{{event.entityId}}</div>
<div class="tb-cell" flex="20">{{event.entityType}}</div>
<div translate class="tb-cell" flex="20">{{event.success ? 'event.success' : 'event.failed'}}</div>
<div class="tb-cell" flex="20">
<md-button class="md-icon-button md-primary"
ng-click="showEdgeEntityContent($event, 'edge.entity-info', 'JSON')"
aria-label="{{ 'action.view' | translate }}">
<md-tooltip md-direction="top">
{{ 'action.view' | translate }}
</md-tooltip>
<md-icon aria-label="{{ 'action.view' | translate }}"
class="material-icons">
more_horiz
</md-icon>
</md-button>
</div>

36
ui/src/app/event/event-row.directive.js

@ -21,11 +21,12 @@ import eventRowLcEventTemplate from './event-row-lc-event.tpl.html';
import eventRowStatsTemplate from './event-row-stats.tpl.html';
import eventRowErrorTemplate from './event-row-error.tpl.html';
import eventRowDebugRuleNodeTemplate from './event-row-debug-rulenode.tpl.html';
import eventRowEdgeEventTemplate from './event-row-edge-event.tpl.html';
/* eslint-enable import/no-unresolved, import/default */
/*@ngInject*/
export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, types) {
export default function EventRowDirective($compile, $templateCache, $mdDialog, $document, $translate, types, toast, entityService) {
var linker = function (scope, element, attrs) {
@ -47,6 +48,9 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $
case types.debugEventType.debugRuleChain.value:
template = eventRowDebugRuleNodeTemplate;
break;
case types.eventType.edgeEvent.value:
template = eventRowEdgeEventTemplate;
break;
}
return $templateCache.get(template);
}
@ -86,6 +90,36 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $
});
}
scope.showEdgeEntityContent = function($event, title, contentType) {
var onShowingCallback = {
onShowing: function(){}
}
if (!contentType) {
contentType = null;
}
entityService.getEntity(scope.event.entityType, scope.event.entityId, {}).then(
function success(info) {
var content = angular.toJson(info);
$mdDialog.show({
controller: 'EventContentDialogController',
controllerAs: 'vm',
templateUrl: eventErrorDialogTemplate,
locals: {content: content, title: title, contentType: contentType, showingCallback: onShowingCallback},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event,
multiple: true,
onShowing: function(scope, element) {
onShowingCallback.onShowing(scope, element);
}
});
},
function fail() {
toast.showError($translate.instant('edge.load-entity-error'));
}
);
}
scope.checkTooltip = function($event) {
var el = $event.target;
var $el = angular.element(el);

31
ui/src/app/event/event-table.directive.js

@ -24,6 +24,27 @@ import eventTableTemplate from './event-table.tpl.html';
/*@ngInject*/
export default function EventTableDirective($compile, $templateCache, $rootScope, types, eventService) {
var edgeData = [
{
"createdTime": 1593592774537,
"tenantId": "63746950-bb76-11ea-9f96-69d7782607f7",
"edgeId": "85bb84b0-bb78-11ea-8472-c3dbdeb0fd97",
"edgeEventAction": "ASSIGNED_TO_EDGE",
"entityId": "640055a0-bb76-11ea-9f96-69d7782607f7",
"entityType": "DEVICE",
"success": true,
},
{
"createdTime": 1593592774538,
"tenantId": "63746950-bb76-11ea-9f96-69d7782607f7",
"edgeId": "85bb84b0-bb78-11ea-8472-c3dbdeb0fd97",
"edgeEventAction": "CREDENTIALS_UPDATED",
"entityId": "640055a0-bb76-11ea-9f96-69d7782607f8",
"entityType": "DEVICE",
"success": false
}
]
var linker = function (scope, element, attrs) {
var template = $templateCache.get(eventTableTemplate);
@ -98,7 +119,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
},
fetchMoreItems_: function () {
if (scope.events.hasNext && !scope.events.pending) {
if (scope.events.hasNext && !scope.events.pending && scope.eventType !== "EDGE_EVENT") {
if (scope.entityType && scope.entityId && scope.eventType && scope.tenantId) {
var promise = eventService.getEvents(scope.entityType, scope.entityId,
scope.eventType, scope.tenantId, scope.events.nextPageLink);
@ -125,12 +146,16 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
scope.events.hasNext = false;
}
}
if (scope.eventType === "EDGE_EVENT") {
scope.events.data = edgeData;
scope.events.nextPageLink = false;
scope.events.hasNext = null;
}
}
};
scope.$watch("entityId", function(newVal, prevVal) {
if (newVal && !angular.equals(newVal, prevVal)) {
scope.resetFilter();
scope.reload();
}
});
@ -141,7 +166,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
}
});
scope.$watch("timewindow", function(newVal, prevVal) {
scope.$watch("createdTime", function(newVal, prevVal) {
if (newVal && !angular.equals(newVal, prevVal)) {
scope.reload();
}

7
ui/src/app/locale/locale.constant-en_US.json

@ -791,14 +791,17 @@
"name": "Name",
"name-required": "Name is required.",
"description": "Description",
"events": "Events",
"entity-info": "Entity info",
"details": "Details",
"events": "Events",
"copy-id": "Copy Edge Id",
"id-copied-message": "Edge Id has been copied to clipboard",
"permissions": "Permissions",
"edge-required": "Edge required",
"edge-type": "Edge type",
"edge-type-required": "Edge type is required.",
"event-action": "Event action",
"entity-id": "Entity ID",
"select-edge-type": "Select edge type",
"assign-to-customer": "Assign to customer",
"assign-to-customer-text": "Please select the customer to assign the edge(s)",
@ -818,6 +821,7 @@
"make-private-edge-text": "After the confirmation the edge and all its data will be made private and won't be accessible by others.",
"import": "Import edge",
"label": "Label",
"load-entity-error": "Could not load entity info",
"assign-new-edge": "Assign new edge",
"manage-edge-dashboards": "Manage edge dashboards",
"unassign-from-edge": "Unassign from edge",
@ -1082,6 +1086,7 @@
"type-debug-rule-chain": "Debug",
"no-events-prompt": "No events found",
"error": "Error",
"type-edge-event": "Downlink",
"alarm": "Alarm",
"event-time": "Event time",
"server": "Server",

Loading…
Cancel
Save