Commit 35429c942b5e448423b1839cdad313fb88aed8b6
1 parent
bdc37d3e
Refactored EdgeEvents, cleaned mistakes in code
Showing
2 changed files
with
26 additions
and
21 deletions
... | ... | @@ -98,22 +98,27 @@ export default function EventRowDirective($compile, $templateCache, $mdDialog, $ |
98 | 98 | if (!contentType) { |
99 | 99 | contentType = null; |
100 | 100 | } |
101 | - if (scope.event.edgeEventType === 'RELATION') { | |
102 | - var content = angular.toJson(scope.event.entityBody); | |
103 | - } else if (scope.event.edgeEventType === 'RULE_CHAIN_METADATA') { | |
104 | - content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {}).then( | |
105 | - function success(info) { | |
106 | - return angular.toJson(info); | |
107 | - }, function fail() { | |
108 | - toast.showError($translate.instant('edge.load-entity-error')); | |
109 | - }); | |
110 | - } else { | |
111 | - content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {}).then( | |
112 | - function success(info) { | |
113 | - return angular.toJson(info); | |
114 | - }, function fail() { | |
115 | - toast.showError($translate.instant('edge.load-entity-error')); | |
116 | - }); | |
101 | + var content = ''; | |
102 | + switch(scope.event.edgeEventType) { | |
103 | + case 'RELATION': | |
104 | + content = angular.toJson(scope.event.entityBody); | |
105 | + break; | |
106 | + case 'RULE_CHAIN_METADATA': | |
107 | + content = ruleChainService.getRuleChainMetaData(scope.event.entityId, {}).then( | |
108 | + function success(info) { | |
109 | + return angular.toJson(info); | |
110 | + }, function fail() { | |
111 | + toast.showError($translate.instant('edge.load-entity-error')); | |
112 | + }); | |
113 | + break; | |
114 | + default: | |
115 | + content = entityService.getEntity(scope.event.edgeEventType, scope.event.entityId, {}).then( | |
116 | + function success(info) { | |
117 | + return angular.toJson(info); | |
118 | + }, function fail() { | |
119 | + toast.showError($translate.instant('edge.load-entity-error')); | |
120 | + }); | |
121 | + break; | |
117 | 122 | } |
118 | 123 | $mdDialog.show({ |
119 | 124 | controller: 'EventContentDialogController', | ... | ... |
... | ... | @@ -22,9 +22,9 @@ import eventTableTemplate from './event-table.tpl.html'; |
22 | 22 | /* eslint-enable import/no-unresolved, import/default */ |
23 | 23 | |
24 | 24 | /*@ngInject*/ |
25 | -export default function EventTableDirective($compile, $templateCache, $rootScope, $stateParams, types, eventService, edgeService) { | |
25 | +export default function EventTableDirective($compile, $templateCache, $rootScope, types, eventService, edgeService) { | |
26 | 26 | |
27 | - var linker = function (scope, element, attrs) { | |
27 | + var linker = function (scope, element, attrs) { | |
28 | 28 | |
29 | 29 | var template = $templateCache.get(eventTableTemplate); |
30 | 30 | |
... | ... | @@ -134,6 +134,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
134 | 134 | |
135 | 135 | scope.$watch("entityId", function(newVal, prevVal) { |
136 | 136 | if (newVal && !angular.equals(newVal, prevVal)) { |
137 | + scope.resetFilter(); | |
137 | 138 | scope.reload(); |
138 | 139 | } |
139 | 140 | }); |
... | ... | @@ -144,7 +145,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
144 | 145 | } |
145 | 146 | }); |
146 | 147 | |
147 | - scope.$watch("createdTime", function(newVal, prevVal) { | |
148 | + scope.$watch("timewindow", function(newVal, prevVal) { | |
148 | 149 | if (newVal && !angular.equals(newVal, prevVal)) { |
149 | 150 | scope.reload(); |
150 | 151 | } |
... | ... | @@ -221,8 +222,7 @@ export default function EventTableDirective($compile, $templateCache, $rootScope |
221 | 222 | scope: { |
222 | 223 | entityType: '=', |
223 | 224 | entityId: '=', |
224 | - tenantId: '=', | |
225 | - edge: '=?' | |
225 | + tenantId: '=' | |
226 | 226 | } |
227 | 227 | }; |
228 | 228 | } | ... | ... |