From efaca8e7f232a43268400141db7189ae724c9284 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Wed, 28 Oct 2020 19:33:42 +0200 Subject: [PATCH] Code clean up --- ui/src/app/event/event-table.directive.js | 30 +++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/ui/src/app/event/event-table.directive.js b/ui/src/app/event/event-table.directive.js index 9c7c57d5d7..b706a80f67 100644 --- a/ui/src/app/event/event-table.directive.js +++ b/ui/src/app/event/event-table.directive.js @@ -221,39 +221,37 @@ export default function EventTableDirective($compile, $templateCache, $rootScope } scope.subscriptionId = null; - scope.queueStartTs; + scope.queueStartTs = 0; scope.loadEdgeInfo = function() { - attributeService.getEntityAttributesValues(scope.entityType, scope.entityId, types.attributesScope.server.value, - types.edgeAttributeKeys.queueStartTs, {}) + attributeService.getEntityAttributesValues( + scope.entityType, + scope.entityId, + types.attributesScope.server.value, + types.edgeAttributeKeys.queueStartTs, + {}) .then(function success(attributes) { - scope.onUpdate(attributes); + scope.onEdgeAttributesUpdate(attributes); }); scope.checkSubscription(); - - attributeService.getEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value, {order: '', limit: 1, page: 1, search: ''}, - function (attributes) { - if (attributes && attributes.data) { - scope.onUpdate(attributes.data); - } - }); } - scope.onUpdate = function(attributes) { - let edge = attributes.reduce(function (map, attribute) { + scope.onEdgeAttributesUpdate = function(attributes) { + let edgeAttributes = attributes.reduce(function (map, attribute) { map[attribute.key] = attribute; return map; }, {}); - if (edge.queueStartTs) { - scope.queueStartTs = edge.queueStartTs.lastUpdateTs; + if (edgeAttributes.queueStartTs) { + scope.queueStartTs = edgeAttributes.queueStartTs.lastUpdateTs; } } scope.checkSubscription = function() { var newSubscriptionId = null; if (scope.entityId && scope.entityType && types.attributesScope.server.value) { - newSubscriptionId = attributeService.subscribeForEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value); + newSubscriptionId = + attributeService.subscribeForEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value); } if (scope.subscriptionId && scope.subscriptionId != newSubscriptionId) { attributeService.unsubscribeForEntityAttributes(scope.subscriptionId);