Skip to content

Commit

Permalink
#127 Refactor job report fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Feb 22, 2017
1 parent b3c920e commit a40449c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 16 additions & 9 deletions ui/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('theHiveControllers').controller('CaseObservablesItemCtrl',
function ($scope, $state, $stateParams, $q, $timeout, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, JobSrv, AlertSrv, VersionSrv, appConfig) {
function ($scope, $state, $stateParams, $q, $timeout, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, AlertSrv, VersionSrv, appConfig) {
var observableId = $stateParams.itemId,
observableName = 'observable-' + observableId;

Expand Down Expand Up @@ -101,14 +101,21 @@
});
};

$scope.showReport = function (job) {
$scope.report = {
template: job.analyzerId,
content: job.report,
status: job.status,
startDate: job.startDate,
endDate: job.endDate
};
$scope.showReport = function (jobId) {
$scope.report = {};

CortexSrv.getJob(jobId).then(function(response) {
var job = response.data;
$scope.report = {
template: job.analyzerId,
content: job.report,
status: job.status,
startDate: job.startDate,
endDate: job.endDate
};
}, function(err) {
AlertSrv.log('An expected error occured while fetching the job report');
});
};

$scope.similarArtifacts = CaseArtifactSrv.api().similar({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3 class="pad10 text-primary">
<i class="glyphicon" ng-class="{ Failure:'glyphicon-warning-sign text-warning', Success:'glyphicon-ok text-success', InProgress:'fa fa-cog fa-spin'}[job.status]"></i>
</span>

<a href ng-click="showReport(job)" uib-tooltip="View report">{{(job.endDate || job.startDate) | showDate}}</a>
<a href ng-click="showReport(job.id)" uib-tooltip="View report">{{(job.endDate || job.startDate) | showDate}}</a>
</li>
</ul>
</td>
Expand Down

0 comments on commit a40449c

Please sign in to comment.