From 35429c942b5e448423b1839cdad313fb88aed8b6 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Tue, 7 Jul 2020 12:32:29 +0300 Subject: [PATCH] Refactored EdgeEvents, cleaned mistakes in code --- ui/src/app/event/event-row.directive.js | 37 +++++++++++++---------- ui/src/app/event/event-table.directive.js | 10 +++--- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ui/src/app/event/event-row.directive.js b/ui/src/app/event/event-row.directive.js index 9e8a5f8bb5..2690323d0a 100644 --- a/ui/src/app/event/event-row.directive.js +++ b/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', diff --git a/ui/src/app/event/event-table.directive.js b/ui/src/app/event/event-table.directive.js index 812a8afd23..38ae0d162b 100644 --- a/ui/src/app/event/event-table.directive.js +++ b/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: '=' } }; }