...
|
...
|
@@ -22,7 +22,8 @@ import eventTableTemplate from './event-table.tpl.html'; |
22
|
22
|
/* eslint-enable import/no-unresolved, import/default */
|
23
|
23
|
|
24
|
24
|
/*@ngInject*/
|
25
|
|
-export default function EventTableDirective($compile, $templateCache, $rootScope, types, eventService, edgeService) {
|
|
25
|
+export default function EventTableDirective($compile, $templateCache, $rootScope, types, eventService, edgeService,
|
|
26
|
+ attributeService) {
|
26
|
27
|
|
27
|
28
|
var linker = function (scope, element, attrs) {
|
28
|
29
|
|
...
|
...
|
@@ -106,6 +107,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
106
|
107
|
scope.eventType, scope.tenantId, scope.events.nextPageLink);
|
107
|
108
|
} else {
|
108
|
109
|
promise = edgeService.getEdgeEvents(scope.entityId, scope.events.nextPageLink);
|
|
110
|
+ scope.loadEdgeInfo();
|
109
|
111
|
}
|
110
|
112
|
if (promise) {
|
111
|
113
|
scope.events.pending = true;
|
...
|
...
|
@@ -135,6 +137,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
135
|
137
|
|
136
|
138
|
scope.$watch("entityId", function(newVal, prevVal) {
|
137
|
139
|
if (newVal && !angular.equals(newVal, prevVal)) {
|
|
140
|
+ scope.loadEdgeInfo();
|
138
|
141
|
scope.resetFilter();
|
139
|
142
|
scope.reload();
|
140
|
143
|
}
|
...
|
...
|
@@ -212,6 +215,53 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
212
|
215
|
return false;
|
213
|
216
|
}
|
214
|
217
|
|
|
218
|
+ scope.subscriptionId = null;
|
|
219
|
+ scope.queueStartTs;
|
|
220
|
+
|
|
221
|
+ scope.loadEdgeInfo = function() {
|
|
222
|
+ attributeService.getEntityAttributesValues(scope.entityType, scope.entityId, types.attributesScope.server.value,
|
|
223
|
+ ["queueStartTs"], {})
|
|
224
|
+ .then(function success(attributes) {
|
|
225
|
+ scope.onUpdate(attributes);
|
|
226
|
+ });
|
|
227
|
+
|
|
228
|
+ scope.checkSubscription();
|
|
229
|
+
|
|
230
|
+ attributeService.getEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value, {order: '', limit: 1, page: 1, search: ''},
|
|
231
|
+ function (attributes) {
|
|
232
|
+ if (attributes && attributes.data) {
|
|
233
|
+ scope.onUpdate(attributes.data);
|
|
234
|
+ }
|
|
235
|
+ });
|
|
236
|
+ }
|
|
237
|
+
|
|
238
|
+ scope.onUpdate = function(attributes) {
|
|
239
|
+ let edge = attributes.reduce(function (map, attribute) {
|
|
240
|
+ map[attribute.key] = attribute;
|
|
241
|
+ return map;
|
|
242
|
+ }, {});
|
|
243
|
+ if (edge.queueStartTs) {
|
|
244
|
+ scope.queueStartTs = edge.queueStartTs.lastUpdateTs;
|
|
245
|
+ }
|
|
246
|
+ }
|
|
247
|
+
|
|
248
|
+ scope.checkSubscription = function() {
|
|
249
|
+ var newSubscriptionId = null;
|
|
250
|
+ if (scope.entityId && scope.entityType && types.attributesScope.server.value) {
|
|
251
|
+ newSubscriptionId = attributeService.subscribeForEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value);
|
|
252
|
+ }
|
|
253
|
+ if (scope.subscriptionId && scope.subscriptionId != newSubscriptionId) {
|
|
254
|
+ attributeService.unsubscribeForEntityAttributes(scope.subscriptionId);
|
|
255
|
+ }
|
|
256
|
+ scope.subscriptionId = newSubscriptionId;
|
|
257
|
+ }
|
|
258
|
+
|
|
259
|
+ scope.$on('$destroy', function () {
|
|
260
|
+ if (scope.subscriptionId) {
|
|
261
|
+ attributeService.unsubscribeForEntityAttributes(scope.subscriptionId);
|
|
262
|
+ }
|
|
263
|
+ });
|
|
264
|
+
|
215
|
265
|
scope.reload();
|
216
|
266
|
|
217
|
267
|
$compile(element.contents())(scope);
|
...
|
...
|
|