Skip to content

Commit

Permalink
#212 Fix observables list refresh after job success
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 8, 2017
1 parent 7c7a8c7 commit 173e65a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion ui/app/scripts/controllers/case/CaseObservablesCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('theHiveControllers').controller('CaseObservablesCtrl',
function ($scope, $q, $state, $stateParams, $uibModal, CaseTabsSrv, PSearchSrv, CaseArtifactSrv, NotificationSrv, AnalyzerSrv, CortexSrv, ObservablesUISrv, VersionSrv, Tlp) {
function ($scope, $q, $state, $stateParams, $uibModal, StreamSrv, CaseTabsSrv, PSearchSrv, CaseArtifactSrv, NotificationSrv, AnalyzerSrv, CortexSrv, ObservablesUISrv, VersionSrv, Tlp) {

CaseTabsSrv.activateTab($state.current.data.tab);

Expand Down Expand Up @@ -42,6 +42,29 @@
nstats: true
});

// Add a listener to refresh observables list on job finish
StreamSrv.addListener({
scope: $scope,
rootId: $scope.caseId,
objectType: 'case_artifact_job',
callback: function(data) {
var successFound = false;
var i = 0;
var ln = data.length;

while(!successFound && i < ln) {
if(data[i].base.operation === 'Update' && data[i].base.details.status === 'Success') {
successFound = true;
}
i++;
}

if(successFound) {
$scope.artifacts.update();
}
}
});

$scope.$watchCollection('artifacts.pageSize', function (newValue) {
$scope.uiSrv.setPageSize(newValue);
});
Expand Down

0 comments on commit 173e65a

Please sign in to comment.