|
|
@ -22,7 +22,8 @@ import eventTableTemplate from './event-table.tpl.html'; |
|
|
/* eslint-enable import/no-unresolved, import/default */ |
|
|
/* eslint-enable import/no-unresolved, import/default */ |
|
|
|
|
|
|
|
|
/*@ngInject*/ |
|
|
/*@ngInject*/ |
|
|
export default function EventTableDirective($compile, $templateCache, $rootScope, types, eventService, edgeService) { |
|
|
export default function EventTableDirective($compile, $templateCache, $rootScope, types, |
|
|
|
|
|
eventService, edgeService, attributeService) { |
|
|
|
|
|
|
|
|
var linker = function (scope, element, attrs) { |
|
|
var linker = function (scope, element, attrs) { |
|
|
|
|
|
|
|
|
@ -30,11 +31,16 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
|
|
|
|
|
|
|
|
element.html(template); |
|
|
element.html(template); |
|
|
|
|
|
|
|
|
|
|
|
scope.eventTypeScope = angular.copy(types.eventType); |
|
|
|
|
|
if (scope.entityType !== types.entityType.edge) { |
|
|
|
|
|
delete scope.eventTypeScope.edgeEvent; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (attrs.disabledEventTypes) { |
|
|
if (attrs.disabledEventTypes) { |
|
|
var disabledEventTypes = attrs.disabledEventTypes.split(','); |
|
|
var disabledEventTypes = attrs.disabledEventTypes.split(','); |
|
|
scope.eventTypes = {}; |
|
|
scope.eventTypes = {}; |
|
|
for (var type in types.eventType) { |
|
|
for (var type in scope.eventTypeScope) { |
|
|
var eventType = types.eventType[type]; |
|
|
var eventType = scope.eventTypeScope[type]; |
|
|
var enabled = true; |
|
|
var enabled = true; |
|
|
for (var i=0;i<disabledEventTypes.length;i++) { |
|
|
for (var i=0;i<disabledEventTypes.length;i++) { |
|
|
if (eventType.value === disabledEventTypes[i]) { |
|
|
if (eventType.value === disabledEventTypes[i]) { |
|
|
@ -47,7 +53,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
scope.eventTypes = angular.copy(types.eventType); |
|
|
scope.eventTypes = angular.copy(scope.eventTypeScope); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (attrs.debugEventTypes) { |
|
|
if (attrs.debugEventTypes) { |
|
|
@ -106,6 +112,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
|
|
scope.eventType, scope.tenantId, scope.events.nextPageLink); |
|
|
scope.eventType, scope.tenantId, scope.events.nextPageLink); |
|
|
} else { |
|
|
} else { |
|
|
promise = edgeService.getEdgeEvents(scope.entityId, scope.events.nextPageLink); |
|
|
promise = edgeService.getEdgeEvents(scope.entityId, scope.events.nextPageLink); |
|
|
|
|
|
scope.loadEdgeInfo(); |
|
|
} |
|
|
} |
|
|
if (promise) { |
|
|
if (promise) { |
|
|
scope.events.pending = true; |
|
|
scope.events.pending = true; |
|
|
@ -135,6 +142,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
|
|
|
|
|
|
|
|
scope.$watch("entityId", function(newVal, prevVal) { |
|
|
scope.$watch("entityId", function(newVal, prevVal) { |
|
|
if (newVal && !angular.equals(newVal, prevVal)) { |
|
|
if (newVal && !angular.equals(newVal, prevVal)) { |
|
|
|
|
|
scope.loadEdgeInfo(); |
|
|
scope.resetFilter(); |
|
|
scope.resetFilter(); |
|
|
scope.reload(); |
|
|
scope.reload(); |
|
|
} |
|
|
} |
|
|
@ -212,6 +220,53 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
scope.subscriptionId = null; |
|
|
|
|
|
scope.queueStartTs; |
|
|
|
|
|
|
|
|
|
|
|
scope.loadEdgeInfo = function() { |
|
|
|
|
|
attributeService.getEntityAttributesValues(scope.entityType, scope.entityId, types.attributesScope.server.value, |
|
|
|
|
|
types.edgeAttributeKeys.queueStartTs, {}) |
|
|
|
|
|
.then(function success(attributes) { |
|
|
|
|
|
scope.onUpdate(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) { |
|
|
|
|
|
map[attribute.key] = attribute; |
|
|
|
|
|
return map; |
|
|
|
|
|
}, {}); |
|
|
|
|
|
if (edge.queueStartTs) { |
|
|
|
|
|
scope.queueStartTs = edge.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); |
|
|
|
|
|
} |
|
|
|
|
|
if (scope.subscriptionId && scope.subscriptionId != newSubscriptionId) { |
|
|
|
|
|
attributeService.unsubscribeForEntityAttributes(scope.subscriptionId); |
|
|
|
|
|
} |
|
|
|
|
|
scope.subscriptionId = newSubscriptionId; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
scope.$on('$destroy', function () { |
|
|
|
|
|
if (scope.subscriptionId) { |
|
|
|
|
|
attributeService.unsubscribeForEntityAttributes(scope.subscriptionId); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
scope.reload(); |
|
|
scope.reload(); |
|
|
|
|
|
|
|
|
$compile(element.contents())(scope); |
|
|
$compile(element.contents())(scope); |
|
|
|