Browse Source

Refactored EdgeEvents, cleaned mistakes in code

pull/2436/head
deaflynx 6 years ago
parent
commit
35429c942b
  1. 37
      ui/src/app/event/event-row.directive.js
  2. 10
      ui/src/app/event/event-table.directive.js

37
ui/src/app/event/event-row.directive.js

@ -98,22 +98,27 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $
if (!contentType) {
contentType = null;
}
if (scope.event.edgeEventType === 'RELATION') {
var content = angular.toJson(scope.event.entityBody);
} else if (scope.event.edgeEventType === 'RULE_CHAIN_METADATA') {
content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {}).then(
function success(info) {
return angular.toJson(info);
}, function fail() {
toast.showError($translate.instant('edge.load-entity-error'));
});
} else {
content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {}).then(
function success(info) {
return angular.toJson(info);
}, function fail() {
toast.showError($translate.instant('edge.load-entity-error'));
});
var content = '';
switch(scope.event.edgeEventType) {
case 'RELATION':
content = angular.toJson(scope.event.entityBody);
break;
case 'RULE_CHAIN_METADATA':
content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {}).then(
function success(info) {
return angular.toJson(info);
}, function fail() {
toast.showError($translate.instant('edge.load-entity-error'));
});
break;
default:
content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {}).then(
function success(info) {
return angular.toJson(info);
}, function fail() {
toast.showError($translate.instant('edge.load-entity-error'));
});
break;
}
$mdDialog.show({
controller: 'EventContentDialogController',

10
ui/src/app/event/event-table.directive.js

@ -22,9 +22,9 @@ import eventTableTemplate from './event-table.tpl.html';
/* eslint-enable import/no-unresolved, import/default */
/*@ngInject*/
export default function EventTableDirective($compile, $templateCache, $rootScope, $stateParams, types, eventService, edgeService) {
export default function EventTableDirective($compile, $templateCache, $rootScope, types, eventService, edgeService) {
var linker = function (scope, element, attrs) {
var linker = function (scope, element, attrs) {
var template = $templateCache.get(eventTableTemplate);
@ -134,6 +134,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
scope.$watch("entityId", function(newVal, prevVal) {
if (newVal && !angular.equals(newVal, prevVal)) {
scope.resetFilter();
scope.reload();
}
});
@ -144,7 +145,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
}
});
scope.$watch("createdTime", function(newVal, prevVal) {
scope.$watch("timewindow", function(newVal, prevVal) {
if (newVal && !angular.equals(newVal, prevVal)) {
scope.reload();
}
@ -221,8 +222,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
scope: {
entityType: '=',
entityId: '=',
tenantId: '=',
edge: '=?'
tenantId: '='
}
};
}

Loading…
Cancel
Save