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) { if (!contentType) {
contentType = null; contentType = null;
} }
if (scope.event.edgeEventType === 'RELATION') { var content = '';
var content = angular.toJson(scope.event.entityBody); switch(scope.event.edgeEventType) {
} else if (scope.event.edgeEventType === 'RULE_CHAIN_METADATA') { case 'RELATION':
content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {}).then( content = angular.toJson(scope.event.entityBody);
function success(info) { break;
return angular.toJson(info); case 'RULE_CHAIN_METADATA':
}, function fail() { content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {}).then(
toast.showError($translate.instant('edge.load-entity-error')); function success(info) {
}); return angular.toJson(info);
} else { }, function fail() {
content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {}).then( toast.showError($translate.instant('edge.load-entity-error'));
function success(info) { });
return angular.toJson(info); break;
}, function fail() { default:
toast.showError($translate.instant('edge.load-entity-error')); 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({ $mdDialog.show({
controller: 'EventContentDialogController', 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 */ /* eslint-enable import/no-unresolved, import/default */
/*@ngInject*/ /*@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); var template = $templateCache.get(eventTableTemplate);
@ -134,6 +134,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.resetFilter();
scope.reload(); 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)) { if (newVal && !angular.equals(newVal, prevVal)) {
scope.reload(); scope.reload();
} }
@ -221,8 +222,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope
scope: { scope: {
entityType: '=', entityType: '=',
entityId: '=', entityId: '=',
tenantId: '=', tenantId: '='
edge: '=?'
} }
}; };
} }

Loading…
Cancel
Save