1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

actually fix relaunch status value issue

This commit is contained in:
John Mitchell 2016-12-16 12:39:49 -05:00
parent 9ed4777556
commit bd5885ec6b
3 changed files with 35 additions and 10 deletions

View File

@ -1,8 +1,4 @@
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet) {
// if the job_status hasn't been set by the websocket, set it now
if (!$scope.job_status) {
$scope.job_status = jobData.status;
}
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope) {
// used for tag search
$scope.job_event_dataset = Dataset.data;
@ -52,7 +48,6 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
}
};
$scope.status_label = getTowerLabel('status');
$scope.type_label = getTowerLabel('job_type');
$scope.verbosity_label = getTowerLabel('verbosity');
};
@ -68,6 +63,27 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
$scope.labels = jobLabels;
$scope.jobFinished = jobFinished;
// update label in left pane and tooltip in right pane when the job_status
// changes
$scope.$watch('job_status', function(status) {
if (status) {
$scope.status_label = $scope.jobOptions.status.choices
.filter(val => val[0] === status)
.map(val => val[1])[0];
$scope.status_tooltip = "Job " + $scope.status_label;
}
});
// 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
// made before some socket events come in for the job status
if ($rootScope['lastSocketStatus' + jobData.id]) {
$scope.job_status = $rootScope['lastSocketStatus' + jobData.id];
delete $rootScope['lastSocketStatus' + jobData.id];
} else {
$scope.job_status = jobData.status;
}
// turn related api browser routes into tower routes
getTowerLinks();
@ -424,13 +440,19 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
$scope.$on(`ws-jobs`, function(e, data) {
if (parseInt(data.unified_job_id, 10) ===
parseInt($scope.job.id,10)) {
// controller is defined, so set the job_status
$scope.job_status = data.status;
}
if (parseInt(data.project_id, 10) ===
} else if (parseInt(data.project_id, 10) ===
parseInt($scope.job.project,10)) {
// this is a project status update message, so set the
// project status in the left pane
$scope.project_status = data.status;
$scope.project_update_link = `/#/scm_update/${data
.unified_job_id}`;
} else {
// controller was previously defined, but is not yet defined
// for this job. cache the socket status on root scope
$rootScope['lastSocketStatus' + data.unified_job_id] = data.status;
}
});
}];

View File

@ -70,7 +70,7 @@
<div class="JobResults-resultRowText">
<i class="JobResults-statusResultIcon
fa
icon-job-{{ job.status }}">
icon-job-{{ job_status }}">
</i> {{ status_label }}
</div>
</div>
@ -415,6 +415,7 @@
<i class="JobResults-statusResultIcon
fa icon-job-{{ job_status }}"
aw-tool-tip="Job {{status_label}}"
data-tip-watch="status_tooltip"
aw-tip-placement="top"
data-original-title>
</i>

View File

@ -35,8 +35,9 @@ export default {
resolve: {
// the GET for the particular job
jobData: ['Rest', 'GetBasePath', '$stateParams', '$q', '$state', 'Alert', function(Rest, GetBasePath, $stateParams, $q, $state, Alert) {
Rest.setUrl(GetBasePath('jobs') + $stateParams.id);
var val = $q.defer();
Rest.setUrl(GetBasePath('jobs') + $stateParams.id);
Rest.get()
.then(function(data) {
val.resolve(data.data);
@ -51,6 +52,7 @@ export default {
$state.go('jobs');
});
return val.promise;
}],
Dataset: ['QuerySet', '$stateParams', 'jobData',