mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
adding elapsed time for a running job
This commit is contained in:
parent
94ae1fcc94
commit
186c065484
@ -1,4 +1,5 @@
|
||||
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) {
|
||||
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', 'moment',
|
||||
function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope, moment) {
|
||||
|
||||
// used for tag search
|
||||
$scope.job_event_dataset = Dataset.data;
|
||||
@ -169,6 +170,17 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
|
||||
|
||||
$scope.events = {};
|
||||
|
||||
// For elapsed time while a job is running, compute the differnce in seconds,
|
||||
// from the time the job started until now. Moment() returns the current
|
||||
// time as a moment object.
|
||||
var start = ($scope.job.started === null) ? moment() : moment($scope.job.started);
|
||||
if(jobFinished === false){
|
||||
var elapsedInterval = setInterval(function(){
|
||||
let now = moment();
|
||||
$scope.job.elapsed = now.diff(start, 'seconds');
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// EVENT STUFF BELOW
|
||||
|
||||
// This is where the async updates to the UI actually happen.
|
||||
@ -442,6 +454,13 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
|
||||
parseInt($scope.job.id,10)) {
|
||||
// controller is defined, so set the job_status
|
||||
$scope.job_status = data.status;
|
||||
if (data.status === "successful" ||
|
||||
data.status === "failed" ||
|
||||
data.status === "error" ||
|
||||
data.status === "canceled") {
|
||||
clearInterval(elapsedInterval);
|
||||
$state.go('.', null, { reload: true });
|
||||
}
|
||||
} else if (parseInt(data.project_id, 10) ===
|
||||
parseInt($scope.job.project,10)) {
|
||||
// this is a project status update message, so set the
|
||||
|
Loading…
Reference in New Issue
Block a user