Code clean up
This commit is contained in:
parent
23d4c5ee99
commit
efaca8e7f2
@ -221,39 +221,37 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.subscriptionId = null;
|
scope.subscriptionId = null;
|
||||||
scope.queueStartTs;
|
scope.queueStartTs = 0;
|
||||||
|
|
||||||
scope.loadEdgeInfo = function() {
|
scope.loadEdgeInfo = function() {
|
||||||
attributeService.getEntityAttributesValues(scope.entityType, scope.entityId, types.attributesScope.server.value,
|
attributeService.getEntityAttributesValues(
|
||||||
types.edgeAttributeKeys.queueStartTs, {})
|
scope.entityType,
|
||||||
|
scope.entityId,
|
||||||
|
types.attributesScope.server.value,
|
||||||
|
types.edgeAttributeKeys.queueStartTs,
|
||||||
|
{})
|
||||||
.then(function success(attributes) {
|
.then(function success(attributes) {
|
||||||
scope.onUpdate(attributes);
|
scope.onEdgeAttributesUpdate(attributes);
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.checkSubscription();
|
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) {
|
scope.onEdgeAttributesUpdate = function(attributes) {
|
||||||
let edge = attributes.reduce(function (map, attribute) {
|
let edgeAttributes = attributes.reduce(function (map, attribute) {
|
||||||
map[attribute.key] = attribute;
|
map[attribute.key] = attribute;
|
||||||
return map;
|
return map;
|
||||||
}, {});
|
}, {});
|
||||||
if (edge.queueStartTs) {
|
if (edgeAttributes.queueStartTs) {
|
||||||
scope.queueStartTs = edge.queueStartTs.lastUpdateTs;
|
scope.queueStartTs = edgeAttributes.queueStartTs.lastUpdateTs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.checkSubscription = function() {
|
scope.checkSubscription = function() {
|
||||||
var newSubscriptionId = null;
|
var newSubscriptionId = null;
|
||||||
if (scope.entityId && scope.entityType && types.attributesScope.server.value) {
|
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) {
|
if (scope.subscriptionId && scope.subscriptionId != newSubscriptionId) {
|
||||||
attributeService.unsubscribeForEntityAttributes(scope.subscriptionId);
|
attributeService.unsubscribeForEntityAttributes(scope.subscriptionId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user