Merge pull request #4950 from jaredevantabor/job-explanation

Fix for job results explanation and traceback
This commit is contained in:
Jared Tabor
2017-01-26 14:49:18 -08:00
committed by GitHub
3 changed files with 57 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', 'fieldChoices', 'fieldLabels',
function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope, moment, $stateParams, i18n) { function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope, moment, $stateParams, i18n, fieldChoices, fieldLabels) {
var toDestroy = []; var toDestroy = [];
var cancelRequests = false; var cancelRequests = false;
@@ -106,6 +106,38 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
} }
})); }));
$scope.previousTaskFailed = false;
toDestroy.push($scope.$watch('job.job_explanation', function(explanation) {
if (explanation && explanation.split(":")[0] === "Previous Task Failed") {
$scope.previousTaskFailed = true;
var taskObj = JSON.parse(explanation.substring(explanation.split(":")[0].length + 1));
// return a promise from the options request with the permission type choices (including adhoc) as a param
var fieldChoice = fieldChoices({
$scope: $scope,
url: 'api/v1/unified_jobs/',
field: 'type'
});
// manipulate the choices from the options request to be set on
// scope and be usable by the list form
fieldChoice.then(function (choices) {
choices =
fieldLabels({
choices: choices
});
$scope.explanation_fail_type = choices[taskObj.job_type];
$scope.explanation_fail_name = taskObj.job_name;
$scope.explanation_fail_id = taskObj.job_id;
$scope.task_detail = $scope.explanation_fail_type + " failed for " + $scope.explanation_fail_name + " with ID " + $scope.explanation_fail_id + ".";
});
} else {
$scope.previousTaskFailed = false;
}
}));
// update the job_status value. Use the cached rootScope value if there // update the job_status value. Use the cached rootScope value if there
// is one. This is a workaround when the rest call for the jobData is // is one. This is a workaround when the rest call for the jobData is
// made before some socket events come in for the job status // made before some socket events come in for the job status
@@ -141,6 +173,7 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
if(jobData.result_traceback) { if(jobData.result_traceback) {
$scope.job.result_traceback = jobData.result_traceback.trim().split('\n').join('<br />'); $scope.job.result_traceback = jobData.result_traceback.trim().split('\n').join('<br />');
} }
// use options labels to manipulate display of details // use options labels to manipulate display of details
getTowerLabels(); getTowerLabels();

View File

@@ -104,14 +104,30 @@
<label class="JobResults-resultRowLabel"> <label class="JobResults-resultRowLabel">
Explanation Explanation
</label> </label>
<div class="JobResults-resultRowText"> <div class="JobResults-resultRowText"
{{job.job_explanation}} ng-show="!previousTaskFailed">
{{job.job_explanation}}
</div>
<div class="JobDetail-resultRowText "
ng-show="previousTaskFailed">Previous Task Failed
<a
href=""
id="explanation_help"
aw-pop-over="{{ task_detail }}"
aw-pop-over-watch="task_detail"
data-placement="bottom"
data-container="body" class="help-link" over-title="Failure Detail"
title=""
tabindex="-1">
<i class="fa fa-question-circle">
</i>
</a>
</div> </div>
</div> </div>
<!-- RESULTS TRACEBACK DETAIL --> <!-- RESULTS TRACEBACK DETAIL -->
<div class="JobResults-resultRow" <div class="JobResults-resultRow"
ng-show="job.result_traceback"> ng-show="job.result_traceback && !previousTaskFailed">
<label class="JobResults-resultRowLabel"> <label class="JobResults-resultRowLabel">
Results Traceback Results Traceback
</label> </label>

View File

@@ -4,7 +4,7 @@ describe('Controller: jobResultsController', () => {
// Setup // Setup
let jobResultsController; let jobResultsController;
let jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, eventResolve, populateResolve, $rScope, q, $log, Dataset, Rest, $state, QuerySet, i18n; let jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, eventResolve, populateResolve, $rScope, q, $log, Dataset, Rest, $state, QuerySet, i18n,fieldChoices, fieldLabels;
jobData = { jobData = {
related: {} related: {}
@@ -78,6 +78,8 @@ describe('Controller: jobResultsController', () => {
$provide.value('$state', $state); $provide.value('$state', $state);
$provide.value('QuerySet', QuerySet); $provide.value('QuerySet', QuerySet);
$provide.value('i18n', i18n); $provide.value('i18n', i18n);
$provide.value('fieldChoices', fieldChoices);
$provide.value('fieldLabels', fieldLabels);
}); });
}; };