Commit 790da527f4caec5396b9c358daa8d70582442b27

Authored by Artem Babak
1 parent f71aec54

Edge events with translations

@@ -1076,6 +1076,127 @@ export default angular.module('thingsboard.types', []) @@ -1076,6 +1076,127 @@ export default angular.module('thingsboard.types', [])
1076 }, 1076 },
1077 translate: { 1077 translate: {
1078 customTranslationsPrefix: "custom." 1078 customTranslationsPrefix: "custom."
1079 - } 1079 + },
  1080 + edgeEventActionType: {
  1081 + "ADDED": {
  1082 + name: "audit-log.type-added"
  1083 + },
  1084 + "DELETED": {
  1085 + name: "audit-log.type-deleted"
  1086 + },
  1087 + "UPDATED": {
  1088 + name: "audit-log.type-updated"
  1089 + },
  1090 + "ATTRIBUTES_UPDATED": {
  1091 + name: "audit-log.type-attributes-updated"
  1092 + },
  1093 + "ATTRIBUTES_DELETED": {
  1094 + name: "audit-log.type-attributes-deleted"
  1095 + },
  1096 + "RPC_CALL": {
  1097 + name: "audit-log.type-rpc-call"
  1098 + },
  1099 + "CREDENTIALS_UPDATED": {
  1100 + name: "audit-log.type-credentials-updated"
  1101 + },
  1102 + "RELATION_ADD_OR_UPDATE": {
  1103 + name: "audit-log.type-relation-add-or-update"
  1104 + },
  1105 + "RELATION_DELETED": {
  1106 + name: "audit-log.type-relation-delete"
  1107 + },
  1108 + "ALARM_ACK": {
  1109 + name: "audit-log.type-alarm-ack"
  1110 + },
  1111 + "ALARM_CLEAR": {
  1112 + name: "audit-log.type-alarm-clear"
  1113 + },
  1114 + "CREDENTIALS_REQUEST": {
  1115 + name: "edge.credentials-request"
  1116 + },
  1117 + "ATTRIBUTES_REQUEST": {
  1118 + name: "edge.attributes-request"
  1119 + },
  1120 + "TIMESERIES_UPDATED": {
  1121 + name: "edge.timeseries-updated"
  1122 + },
  1123 + "RELATION_REQUEST": {
  1124 + name: "edge.relation-request"
  1125 + },
  1126 + "RULE_CHAIN_METADATA_REQUEST": {
  1127 + name: "edge.rule-chain-metadata-request"
  1128 + },
  1129 + "GROUP_ENTITIES_REQUEST": {
  1130 + name: "edge.group_entities_request"
  1131 + },
  1132 + "GROUP_PERMISSIONS_REQUEST": {
  1133 + name: "edge.group-permissions-request"
  1134 + },
  1135 + "ASSIGNED_TO_EDGE": {
  1136 + name: "audit-log.type-assigned-to-edge"
  1137 + },
  1138 + "UNASSIGNED_FROM_EDGE": {
  1139 + name: "audit-log.type-unassigned-from-edge"
  1140 + }
  1141 + },
  1142 + edgeEventTypeTranslations:{
  1143 + "DASHBOARD": {
  1144 + name: "entity.type-dashboard"
  1145 + },
  1146 + "ASSET": {
  1147 + name: "entity.type-asset"
  1148 + },
  1149 + "DEVICE": {
  1150 + name: "entity.type-device"
  1151 + },
  1152 + "ENTITY_VIEW": {
  1153 + name: "entity.type-entity_view"
  1154 + },
  1155 + "ALARM": {
  1156 + name: "entity.type-alarm"
  1157 + },
  1158 + "RULE_CHAIN": {
  1159 + name: "entity.type-rulechain"
  1160 + },
  1161 + "RULE_CHAIN_META_DATA": {
  1162 + name: "entity.type-rule-chain-metadata"
  1163 + },
  1164 + "EDGE": {
  1165 + name: "entity.type-edge"
  1166 + },
  1167 + "USER": {
  1168 + name: "entity.type-user"
  1169 + },
  1170 + "CUSTOMER": {
  1171 + name: "entity.type-customer"
  1172 + },
  1173 + "RELATION": {
  1174 + name: "entity.type-relation"
  1175 + },
  1176 + "ENTITY_GROUP": {
  1177 + name: "entity.type-entity-group"
  1178 + },
  1179 + "SCHEDULER_EVENT": {
  1180 + name: "entity.type-scheduler-event"
  1181 + },
  1182 + "WHITE_LABELING": {
  1183 + name: "white-labeling.white-labeling"
  1184 + },
  1185 + "LOGIN_WHITE_LABELING": {
  1186 + name: "white-labeling.login-white-labeling"
  1187 + },
  1188 + "CUSTOM_TRANSLATION": {
  1189 + name: "custom-translation.custom-translation",
  1190 + },
  1191 + "WIDGETS_BUNDLE": {
  1192 + name: "widget.widget-bundle"
  1193 + },
  1194 + "WIDGET_TYPE": {
  1195 + name: "widget.type"
  1196 + },
  1197 + "ADMIN_SETTINGS": {
  1198 + name: "permission.resource.display-type.ADMIN_SETTINGS"
  1199 + }
  1200 + },
1080 } 1201 }
1081 ).name; 1202 ).name;
@@ -16,8 +16,8 @@ @@ -16,8 +16,8 @@
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.type }}</div>  
20 -<div class="tb-cell" flex="40">{{ event.action }}</div> 19 +<div class="tb-cell" flex="20">{{ event.edgeEventTypeText }}</div>
  20 +<div class="tb-cell" flex="40">{{ event.edgeEventActionText }}</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="{'color': statusColor}">{{ updateStatus(event.createdTime) }}</div> 22 <div class="tb-cell" flex="15" ng-style="{'color': statusColor}">{{ updateStatus(event.createdTime) }}</div>
23 <div class="tb-cell" flex="10"> 23 <div class="tb-cell" flex="10">
@@ -22,7 +22,7 @@ import eventTableTemplate from './event-table.tpl.html'; @@ -22,7 +22,7 @@ import eventTableTemplate from './event-table.tpl.html';
22 /* eslint-enable import/no-unresolved, import/default */ 22 /* eslint-enable import/no-unresolved, import/default */
23 23
24 /*@ngInject*/ 24 /*@ngInject*/
25 -export default function EventTableDirective($compile, $templateCache, $rootScope, types, 25 +export default function EventTableDirective($compile, $templateCache, $rootScope, $translate, types,
26 eventService, edgeService, attributeService) { 26 eventService, edgeService, attributeService) {
27 27
28 var linker = function (scope, element, attrs) { 28 var linker = function (scope, element, attrs) {
@@ -118,7 +118,11 @@ export default function EventTableDirective($compile, $templateCache, $rootScope @@ -118,7 +118,11 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
118 scope.events.pending = true; 118 scope.events.pending = true;
119 promise.then( 119 promise.then(
120 function success(events) { 120 function success(events) {
121 - scope.events.data = scope.events.data.concat(events.data); 121 + if (scope.eventType === types.eventType.edgeEvent.value) {
  122 + scope.events.data = scope.events.data.concat(prepareEdgeEventData(events.data));
  123 + } else {
  124 + scope.events.data = scope.events.data.concat(events.data);
  125 + }
122 scope.events.nextPageLink = events.nextPageLink; 126 scope.events.nextPageLink = events.nextPageLink;
123 scope.events.hasNext = events.hasNext; 127 scope.events.hasNext = events.hasNext;
124 if (scope.events.hasNext) { 128 if (scope.events.hasNext) {
@@ -266,6 +270,16 @@ export default function EventTableDirective($compile, $templateCache, $rootScope @@ -266,6 +270,16 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
266 270
267 $compile(element.contents())(scope); 271 $compile(element.contents())(scope);
268 } 272 }
  273 +
  274 + function prepareEdgeEventData(data) {
  275 + data.forEach(
  276 + edgeEvent => {
  277 + edgeEvent.edgeEventActionText = $translate.instant(types.edgeEventActionType[edgeEvent.action].name);
  278 + edgeEvent.edgeEventTypeText = $translate.instant(types.edgeEventTypeTranslations[edgeEvent.edgeId.entityType].name);
  279 + }
  280 + );
  281 + return data;
  282 + }
269 283
270 return { 284 return {
271 restrict: "E", 285 restrict: "E",
@@ -854,7 +854,17 @@ @@ -854,7 +854,17 @@
854 "edge-type-list-empty": "No edge types selected.", 854 "edge-type-list-empty": "No edge types selected.",
855 "edge-types": "Edge types", 855 "edge-types": "Edge types",
856 "license-key-hint": "To obtain your license please navigate to the <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'>pricing page</a> and select the best license option for your case.", 856 "license-key-hint": "To obtain your license please navigate to the <a href='https://thingsboard.io/pricing/?active=thingsboard-edge' target='_blank'>pricing page</a> and select the best license option for your case.",
857 - "cloud-endpoint-hint": "Edge requires HTTP(s) access to Cloud (ThingsBoard CE/PE) to verify the license key. Please specify Cloud URL that Edge is able to connect to." 857 + "cloud-endpoint-hint": "Edge requires HTTP(s) access to Cloud (ThingsBoard CE/PE) to verify the license key. Please specify Cloud URL that Edge is able to connect to.",
  858 +
  859 + "set-edge-template-root-rulechain": "Make rule chain edge template root",
  860 + "set-edge-template-root-rulechain-title": "Are you sure you want to make the rule chain '{{ruleChainName}}' edge template root?",
  861 + "set-edge-template-root-rulechain-text": "After the confirmation the rule chain will become edge template root and will be root rule chain for a newly created edges.",
  862 + "set-auto-assign-to-edge": "Assign rule chain to edge(s) on creation",
  863 + "set-auto-assign-to-edge-title": "Are you sure you want to assign the edge rule chain '{{ruleChainName}}' to edge(s) on creation?",
  864 + "set-auto-assign-to-edge-text": "After the confirmation the edge rule chain will be automatically assigned to edge(s) on creation.",
  865 + "unset-auto-assign-to-edge": "Unset assign rule chain to edge(s) on creation",
  866 + "unset-auto-assign-to-edge-title": "Are you sure you want to unset assign the edge rule chain '{{ruleChainName}}' to edge(s) on creation?",
  867 + "unset-auto-assign-to-edge-text": "After the confirmation the edge rule chain will no longer be automatically assigned to edge(s) on creation."
858 }, 868 },
859 "error": { 869 "error": {
860 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.", 870 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.",