Skip to content

Commit

Permalink
#1633 Refresh the job report on observable import from report
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Nov 12, 2020
1 parent f4a4a78 commit 625fadf
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 28 deletions.
88 changes: 63 additions & 25 deletions frontend/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,33 +125,71 @@
$scope.similarArtifactsLimit = $scope.similarArtifactsLimit + 10;
};

$scope.showReport = function (jobId) {
$scope.refreshCurrentJob = function() {
$scope.loadReport($scope.currentJob);
};

$scope.loadReport = function(jobId) {
$scope.report = {};

CortexSrv.getJob(jobId, true).then(function(response) {
var job = response.data;
$scope.report = {
template: job.analyzerDefinition,
content: job.report,
status: job.status,
startDate: job.startDate,
endDate: job.endDate
};

$scope.currentJob = jobId;

$timeout(function() {
var reportEl = angular.element('#analysis-report')[0];

// Scrolling hack using jQuery stuff
$('html,body').animate({
scrollTop: $(reportEl).offset().top
}, 'fast');
}, 500);

}, function(/*err*/) {
NotificationSrv.error('An expected error occured while fetching the job report');
});
return CortexSrv.getJob(jobId, true)
.then(function(response) {
var job = response.data;
$scope.report = {
template: job.analyzerDefinition,
content: job.report,
status: job.status,
startDate: job.startDate,
endDate: job.endDate
};

$scope.currentJob = jobId;
});
};

$scope.showReport = function (jobId) {

$scope.loadReport(jobId)
.then(function(){
$timeout(function() {
var reportEl = angular.element('#analysis-report')[0];

// Scrolling hack using jQuery stuff
$('html,body').animate({
scrollTop: $(reportEl).offset().top
}, 'fast');
}, 500);
})
.catch(function(/*err*/) {
NotificationSrv.error('An expected error occured while fetching the job report');
});

// $scope.report = {};

// CortexSrv.getJob(jobId, true).then(function(response) {
// var job = response.data;
// $scope.report = {
// template: job.analyzerDefinition,
// content: job.report,
// status: job.status,
// startDate: job.startDate,
// endDate: job.endDate
// };
//
// $scope.currentJob = jobId;
//
// $timeout(function() {
// var reportEl = angular.element('#analysis-report')[0];
//
// // Scrolling hack using jQuery stuff
// $('html,body').animate({
// scrollTop: $(reportEl).offset().top
// }, 'fast');
// }, 500);
//
// }, function(/*err*/) {
// NotificationSrv.error('An expected error occured while fetching the job report');
// });
};

$scope.openArtifact = function (a) {
Expand Down
7 changes: 6 additions & 1 deletion frontend/app/scripts/directives/report-observables.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
observables: '=',
analyzer: '=',
caseId: '=',
permissions: '='
permissions: '=',
onRefresh: '&?'
},
templateUrl: 'views/directives/report-observables.html',
link: function(scope) {
Expand Down Expand Up @@ -117,6 +118,10 @@
item.imported = true;
item.selected = false;
});

if($scope.onRefresh) {
$scope.onRefresh();
}
});
});

Expand Down
4 changes: 2 additions & 2 deletions frontend/app/views/directives/report-observables.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
offset: (pagination.currentPage-1)*pagination.pageSize |
limitTo: pagination.pageSize ">
<td>
<input type="checkbox" ng-model="observable.selected" ng-change="selectObservable(observable)" ng-disabled="!!observable.stats.observableId">
<input type="checkbox" ng-model="observable.selected" ng-change="selectObservable(observable)" ng-disabled="!!observable.imported">
</td>
<td>
<observable-flags observable="observable" inline="true" hide-seen="true" hide-similarity="true"></observable-flags>
</td>
<td align="center">
<span uib-tooltip="Observable already imported" tooltip-popup-delay="500" tooltip-placement="right" ng-if="!!observable.stats.observableId" class="fa fa-check"></span>
<span uib-tooltip="Observable already imported" tooltip-popup-delay="500" tooltip-placement="right" ng-if="!!observable.imported" class="fa fa-check"></span>
</td>
<td>{{observable.dataType}}</td>
<td class="wrap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ <h4 class="pad10 text-primary">
observables="report.content.artifacts"
analyzer="report.template"
permissions="userPermissions"
on-refresh="refreshCurrentJob()"

></report-observables>
</div>
</div>
Expand Down

0 comments on commit 625fadf

Please sign in to comment.