mirror of
https://github.com/ansible/awx.git
synced 2026-02-12 15:14:45 -03:30
57 lines
2.0 KiB
JavaScript
57 lines
2.0 KiB
JavaScript
/*************************************************
|
|
* Copyright (c) 2015 Ansible, Inc.
|
|
*
|
|
* All Rights Reserved
|
|
*************************************************/
|
|
|
|
export default ['$scope', '$filter',
|
|
function ($scope, $filter) {
|
|
|
|
var recentJobs = $scope.jobs;
|
|
|
|
function isFailureState(status) {
|
|
return status === 'failed' || status === 'error' || status === 'canceled';
|
|
}
|
|
|
|
var sparkData =
|
|
_.sortBy(recentJobs.map(function(job) {
|
|
|
|
var data = {};
|
|
|
|
if (job.status === 'successful') {
|
|
data.value = 1;
|
|
} else if (isFailureState(job.status)) {
|
|
data.value = -1;
|
|
} else {
|
|
data.value = 0;
|
|
}
|
|
|
|
data.jobId = job.id;
|
|
data.smartStatus = job.status;
|
|
data.finished = $filter('longDate')(job.finished) || "running";
|
|
|
|
return data;
|
|
}), "finished").reverse();
|
|
|
|
$scope.sparkArray = _.pluck(sparkData, 'value');
|
|
$scope.jobIds = _.pluck(sparkData, 'jobId');
|
|
$scope.smartStatus = _.pluck(sparkData, 'smartStatus');
|
|
$scope.finished = _.pluck(sparkData, 'finished');
|
|
|
|
}];
|
|
|
|
//
|
|
//
|
|
// JOB_STATUS_CHOICES = [
|
|
// ('new', _('New')), # Job has been created, but not started.
|
|
// ('pending', _('Pending')), # Job has been queued, but is not yet running.
|
|
// ('waiting', _('Waiting')), # Job is waiting on an update/dependency.
|
|
// ('running', _('Running')), # Job is currently running.
|
|
// ('successful', _('Successful')), # Job completed successfully.
|
|
// ('failed', _('Failed')), # Job completed, but with failures.
|
|
// ('error', _('Error')), # The job was unable to run.
|
|
// ('canceled', _('Canceled')), # The job was canceled before completion.
|
|
// final states only*****
|
|
// ]
|
|
//
|