Commit efaca8e7f232a43268400141db7189ae724c9284

Authored by Volodymyr Babak
1 parent 23d4c5ee

Code clean up

@@ -221,39 +221,37 @@ export default function EventTableDirective($compile, $templateCache, $rootScope @@ -221,39 +221,37 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
221 } 221 }
222 222
223 scope.subscriptionId = null; 223 scope.subscriptionId = null;
224 - scope.queueStartTs; 224 + scope.queueStartTs = 0;
225 225
226 scope.loadEdgeInfo = function() { 226 scope.loadEdgeInfo = function() {
227 - attributeService.getEntityAttributesValues(scope.entityType, scope.entityId, types.attributesScope.server.value,  
228 - types.edgeAttributeKeys.queueStartTs, {}) 227 + attributeService.getEntityAttributesValues(
  228 + scope.entityType,
  229 + scope.entityId,
  230 + types.attributesScope.server.value,
  231 + types.edgeAttributeKeys.queueStartTs,
  232 + {})
229 .then(function success(attributes) { 233 .then(function success(attributes) {
230 - scope.onUpdate(attributes); 234 + scope.onEdgeAttributesUpdate(attributes);
231 }); 235 });
232 236
233 scope.checkSubscription(); 237 scope.checkSubscription();
234 -  
235 - attributeService.getEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value, {order: '', limit: 1, page: 1, search: ''},  
236 - function (attributes) {  
237 - if (attributes && attributes.data) {  
238 - scope.onUpdate(attributes.data);  
239 - }  
240 - });  
241 } 238 }
242 239
243 - scope.onUpdate = function(attributes) {  
244 - let edge = attributes.reduce(function (map, attribute) { 240 + scope.onEdgeAttributesUpdate = function(attributes) {
  241 + let edgeAttributes = attributes.reduce(function (map, attribute) {
245 map[attribute.key] = attribute; 242 map[attribute.key] = attribute;
246 return map; 243 return map;
247 }, {}); 244 }, {});
248 - if (edge.queueStartTs) {  
249 - scope.queueStartTs = edge.queueStartTs.lastUpdateTs; 245 + if (edgeAttributes.queueStartTs) {
  246 + scope.queueStartTs = edgeAttributes.queueStartTs.lastUpdateTs;
250 } 247 }
251 } 248 }
252 249
253 scope.checkSubscription = function() { 250 scope.checkSubscription = function() {
254 var newSubscriptionId = null; 251 var newSubscriptionId = null;
255 if (scope.entityId && scope.entityType && types.attributesScope.server.value) { 252 if (scope.entityId && scope.entityType && types.attributesScope.server.value) {
256 - newSubscriptionId = attributeService.subscribeForEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value); 253 + newSubscriptionId =
  254 + attributeService.subscribeForEntityAttributes(scope.entityType, scope.entityId, types.attributesScope.server.value);
257 } 255 }
258 if (scope.subscriptionId && scope.subscriptionId != newSubscriptionId) { 256 if (scope.subscriptionId && scope.subscriptionId != newSubscriptionId) {
259 attributeService.unsubscribeForEntityAttributes(scope.subscriptionId); 257 attributeService.unsubscribeForEntityAttributes(scope.subscriptionId);