-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#131 Open job reports on a modal dialog from observables list
- Loading branch information
Showing
6 changed files
with
136 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,86 @@ | ||
(function () { | ||
(function() { | ||
'use strict'; | ||
angular.module('theHiveServices') | ||
.factory('CortexSrv', function ($q, $http, $rootScope, $uibModal, StatSrv, StreamSrv, AnalyzerSrv, PSearchSrv) { | ||
angular.module('theHiveServices').factory('CortexSrv', function($q, $http, $rootScope, $uibModal, StatSrv, StreamSrv, AnalyzerSrv, PSearchSrv) { | ||
|
||
var baseUrl = './api/connector/cortex'; | ||
var baseUrl = './api/connector/cortex'; | ||
|
||
var factory = { | ||
list: function (scope, caseId, observableId, callback) { | ||
return PSearchSrv(undefined, 'connector/cortex/job', { | ||
scope: scope, | ||
sort: '-startDate', | ||
loadAll: false, | ||
pageSize: 200, | ||
onUpdate: callback || angular.noop, | ||
streamObjectType: 'case_artifact_job', | ||
filter: { | ||
_parent: { | ||
_type: 'case_artifact', | ||
_query: { | ||
_id: observableId | ||
} | ||
var factory = { | ||
list: function(scope, caseId, observableId, callback) { | ||
return PSearchSrv(undefined, 'connector/cortex/job', { | ||
scope: scope, | ||
sort: '-startDate', | ||
loadAll: false, | ||
pageSize: 200, | ||
onUpdate: callback || angular.noop, | ||
streamObjectType: 'case_artifact_job', | ||
filter: { | ||
_parent: { | ||
_type: 'case_artifact', | ||
_query: { | ||
_id: observableId | ||
} | ||
} | ||
}); | ||
}, | ||
} | ||
}); | ||
}, | ||
|
||
getJobs: function(caseId, observableId, analyzerId, limit) { | ||
return $http.post(baseUrl + '/job/_search', { | ||
sort: '-startDate', | ||
range: '0-' + (limit || 10), | ||
query: { | ||
_and: [ | ||
{ | ||
_parent: { | ||
_type: 'case_artifact', | ||
_query: { | ||
_id: observableId | ||
} | ||
} | ||
}, { | ||
analyzerId: analyzerId | ||
} | ||
] | ||
} | ||
}) | ||
}, | ||
|
||
getJob: function (jobId) { | ||
return $http.get(baseUrl + '/job/' + jobId); | ||
}, | ||
getJob: function(jobId) { | ||
return $http.get(baseUrl + '/job/' + jobId); | ||
}, | ||
|
||
createJob: function (job) { | ||
return $http.post(baseUrl + '/job', job); | ||
}, | ||
createJob: function(job) { | ||
return $http.post(baseUrl + '/job', job); | ||
}, | ||
|
||
getServers: function (analyzerIds) { | ||
return AnalyzerSrv.serversFor(analyzerIds) | ||
.then(function (servers) { | ||
if (servers.length === 1) { | ||
return $q.resolve(servers[0]); | ||
} else { | ||
return factory.promptForInstance(servers); | ||
} | ||
}); | ||
}, | ||
getServers: function(analyzerIds) { | ||
return AnalyzerSrv.serversFor(analyzerIds).then(function(servers) { | ||
if (servers.length === 1) { | ||
return $q.resolve(servers[0]); | ||
} else { | ||
return factory.promptForInstance(servers); | ||
} | ||
}); | ||
}, | ||
|
||
promptForInstance: function (servers) { | ||
var modalInstance = $uibModal.open({ | ||
templateUrl: 'views/partials/cortex/choose-instance-dialog.html', | ||
controller: 'CortexInstanceDialogCtrl', | ||
controllerAs: 'vm', | ||
size: '', | ||
resolve: { | ||
servers: function () { | ||
return servers; | ||
} | ||
promptForInstance: function(servers) { | ||
var modalInstance = $uibModal.open({ | ||
templateUrl: 'views/partials/cortex/choose-instance-dialog.html', | ||
controller: 'CortexInstanceDialogCtrl', | ||
controllerAs: 'vm', | ||
size: '', | ||
resolve: { | ||
servers: function() { | ||
return servers; | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
return modalInstance.result; | ||
} | ||
}; | ||
return modalInstance.result; | ||
} | ||
}; | ||
|
||
return factory; | ||
}); | ||
return factory; | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
ui/app/views/partials/observables/list/job-report-dialog.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="modal-header bg-primary"> | ||
<h3 class="modal-title">Report of #{{$vm.report.job.analyzerId}} analysis</h3> | ||
</div> | ||
<div class="modal-body"> | ||
<report artifact="$vm.observable" | ||
content="$vm.report.content.full || $vm.report.content" | ||
report-type="long" | ||
name="$vm.report.template" | ||
status="$vm.report.status" | ||
success="$vm.report.content.success" | ||
></report> | ||
</div> | ||
<div class="modal-footer text-left"> | ||
<button class="btn btn-primary pull-right" type="button" ng-click="$vm.close()">Close</button> | ||
</div> |