mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
Wired up job relaunch for each type of job.
This commit is contained in:
parent
b2f0c1214f
commit
b47aed5bdb
@ -11,13 +11,13 @@
|
||||
'use strict';
|
||||
|
||||
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
||||
ScheduledJobsList, GetChoices, GetBasePath, Wait, DeleteJob, Find, DeleteSchedule, ToggleSchedule) {
|
||||
ScheduledJobsList, GetChoices, GetBasePath, Wait, DeleteJob, Find, DeleteSchedule, ToggleSchedule, RelaunchInventory, RelaunchPlaybook, RelaunchSCM) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
var e,
|
||||
completed_scope, running_scope, queued_scope, scheduled_scope,
|
||||
choicesCount = 0, listsCount = 0;
|
||||
choicesCount = 0, listsCount = 0, relaunch, getTypeId;
|
||||
|
||||
LoadBreadCrumbs();
|
||||
|
||||
@ -26,6 +26,36 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
e.html(Breadcrumbs({ list: { editTitle: 'Jobs' } , mode: 'edit' }));
|
||||
$compile(e)($scope);
|
||||
|
||||
relaunch = function(params) {
|
||||
var scope = params.scope,
|
||||
id = params.id,
|
||||
type = params.type,
|
||||
name = params.name;
|
||||
if (type === 'inventory_sync') {
|
||||
RelaunchInventory({ scope: scope, id: id});
|
||||
}
|
||||
else if (type === 'playbook_run') {
|
||||
RelaunchPlaybook({ scope: scope, id: id, name: name });
|
||||
}
|
||||
else if (type === 'scm_sync') {
|
||||
RelaunchSCM({ });
|
||||
}
|
||||
};
|
||||
|
||||
getTypeId = function(job) {
|
||||
var type_id;
|
||||
if (job.type === 'inventory_sync') {
|
||||
type_id = job.inventory_source;
|
||||
}
|
||||
else if (job.type === 'scm_sync') {
|
||||
type_id = job.poject;
|
||||
}
|
||||
else if (job.type === 'playbook_run') {
|
||||
type_id = job.id;
|
||||
}
|
||||
return type_id;
|
||||
};
|
||||
|
||||
// After all the lists are loaded
|
||||
if ($scope.removeListLoaded) {
|
||||
$scope.removeListLoaded();
|
||||
@ -109,6 +139,24 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
callback: 'SchedulesRefresh'
|
||||
});
|
||||
};
|
||||
|
||||
completed_scope.relaunch = function(id) {
|
||||
var job = Find({ list: completed_scope.completed_jobs, key: 'id', val: id }),
|
||||
type_id = getTypeId(job);
|
||||
relaunch({ scope: completed_scope, id: type_id, type: job.type, name: job.name });
|
||||
};
|
||||
|
||||
running_scope.relaunch = function(id) {
|
||||
var job = Find({ list: running_scope.running_jobs, key: 'id', val: id }),
|
||||
type_id = getTypeId(job);
|
||||
relaunch({ scope: running_scope, id: type_id, type: job.type, name: job.name });
|
||||
};
|
||||
|
||||
queued_scope.relaunch = function(id) {
|
||||
var job = Find({ list: queued_scope.queued_jobs, key: 'id', val: id }),
|
||||
type_id = getTypeId(job);
|
||||
relaunch({ scope: queued_scope, id: type_id, type: job.type, name: job.name });
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
@ -143,7 +191,8 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
||||
}
|
||||
|
||||
JobsListController.$inject = ['$scope', '$compile', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'LoadScope', 'RunningJobsList', 'CompletedJobsList',
|
||||
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'DeleteJob', 'Find', 'DeleteSchedule', 'ToggleSchedule'];
|
||||
'QueuedJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', 'DeleteJob', 'Find', 'DeleteSchedule', 'ToggleSchedule', 'RelaunchInventory',
|
||||
'RelaunchPlaybook', 'RelaunchSCM'];
|
||||
|
||||
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest,
|
||||
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
||||
@ -363,7 +412,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('jobs'),
|
||||
url: GetBasePath('unified_jobs'),
|
||||
field: 'job_type',
|
||||
variable: 'job_type_options',
|
||||
callback: 'choicesReady'
|
||||
@ -379,7 +428,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: '/static/sample/data/types/data.json', //GetBasePath('jobs')
|
||||
url: GetBasePath('unified_jobs'), //'/static/sample/data/types/data.json'
|
||||
field: 'type',
|
||||
variable: 'type_choices',
|
||||
callback: 'choicesReady'
|
||||
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers'])
|
||||
angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers',
|
||||
'JobSubmissionHelper'])
|
||||
|
||||
.factory('JobStatusToolTip', [
|
||||
function () {
|
||||
@ -215,7 +216,7 @@ angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinitio
|
||||
if (list.fields.type) {
|
||||
parent_scope.type_choices.every(function(choice) {
|
||||
if (choice.value === item.type) {
|
||||
itm.type = choice.label;
|
||||
itm.type_label = choice.label;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -326,4 +327,48 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt){
|
||||
});
|
||||
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('RelaunchInventory', ['Find', 'Wait', 'Rest', 'InventoryUpdate', 'ProcessErrors', 'GetBasePath',
|
||||
function(Find, Wait, Rest, InventoryUpdate, ProcessErrors, GetBasePath) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
id = params.id,
|
||||
url = GetBasePath('inventory_sources') + id + '/';
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success(function (data) {
|
||||
InventoryUpdate({
|
||||
scope: scope,
|
||||
url: data.related.update,
|
||||
group_name: data.summary_fields.group.name,
|
||||
group_source: data.source,
|
||||
tree_id: null,
|
||||
group_id: data.group
|
||||
});
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' +
|
||||
url + ' POST returned status: ' + status });
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('RelaunchPlaybook', ['SubmitJob', function(SubmitJob) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
id = params.id,
|
||||
name = params.name;
|
||||
SubmitJob({ scope: scope, id: id, template: name });
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('RelaunchSCM', ['ProjectUpdate', function(ProjectUpdate) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
id = params.id;
|
||||
ProjectUpdate({ scope: scope, id: id });
|
||||
};
|
||||
}]);
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ angular.module('CompletedJobsDefinition', [])
|
||||
},
|
||||
type: {
|
||||
label: 'Type',
|
||||
ngBind: 'completed_job.type_label',
|
||||
link: false,
|
||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||
},
|
||||
@ -101,7 +102,7 @@ angular.module('CompletedJobsDefinition', [])
|
||||
submit: {
|
||||
icon: 'icon-rocket',
|
||||
mode: 'all',
|
||||
ngClick: 'submitJob(completed_job.id, completed_job.summary_fields.job_template.name)',
|
||||
ngClick: 'relaunch(completed_job.id)',
|
||||
awToolTip: 'Relaunch the job',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
|
||||
@ -47,6 +47,7 @@ angular.module('QueuedJobsDefinition', [])
|
||||
},
|
||||
type: {
|
||||
label: 'Type',
|
||||
ngBind: 'queued_job.type_label',
|
||||
link: false,
|
||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||
},
|
||||
@ -78,7 +79,7 @@ angular.module('QueuedJobsDefinition', [])
|
||||
submit: {
|
||||
icon: 'icon-rocket',
|
||||
mode: 'all',
|
||||
ngClick: 'submitJob(queued_job.id, queued_job.summary_fields.job_template.name)',
|
||||
ngClick: 'relaunch(queued_job.id)',
|
||||
awToolTip: 'Launch another instance of the job',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
|
||||
@ -47,6 +47,7 @@ angular.module('RunningJobsDefinition', [])
|
||||
},
|
||||
type: {
|
||||
label: 'Type',
|
||||
ngBind: 'running_job.type_label',
|
||||
link: false,
|
||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||
},
|
||||
@ -81,7 +82,7 @@ angular.module('RunningJobsDefinition', [])
|
||||
submit: {
|
||||
icon: 'icon-rocket',
|
||||
mode: 'all',
|
||||
ngClick: 'submitJob(running_job.id, running_job.summary_fields.job_template.name)',
|
||||
ngClick: 'relaunch(running_job.id)',
|
||||
awToolTip: 'Launch another instance of the job',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user