mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 05:55:59 -03:30
Wired up job relaunch for each type of job.
This commit is contained in:
@@ -11,13 +11,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBreadCrumbs, LoadScope, RunningJobsList, CompletedJobsList, QueuedJobsList,
|
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();
|
ClearScope();
|
||||||
|
|
||||||
var e,
|
var e,
|
||||||
completed_scope, running_scope, queued_scope, scheduled_scope,
|
completed_scope, running_scope, queued_scope, scheduled_scope,
|
||||||
choicesCount = 0, listsCount = 0;
|
choicesCount = 0, listsCount = 0, relaunch, getTypeId;
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
@@ -26,6 +26,36 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
e.html(Breadcrumbs({ list: { editTitle: 'Jobs' } , mode: 'edit' }));
|
e.html(Breadcrumbs({ list: { editTitle: 'Jobs' } , mode: 'edit' }));
|
||||||
$compile(e)($scope);
|
$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
|
// After all the lists are loaded
|
||||||
if ($scope.removeListLoaded) {
|
if ($scope.removeListLoaded) {
|
||||||
$scope.removeListLoaded();
|
$scope.removeListLoaded();
|
||||||
@@ -109,6 +139,24 @@ function JobsListController ($scope, $compile, ClearScope, Breadcrumbs, LoadBrea
|
|||||||
callback: 'SchedulesRefresh'
|
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',
|
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,
|
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, JobTemplateForm, GenerateForm, Rest,
|
||||||
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
||||||
@@ -363,7 +412,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
|
|||||||
|
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: GetBasePath('jobs'),
|
url: GetBasePath('unified_jobs'),
|
||||||
field: 'job_type',
|
field: 'job_type',
|
||||||
variable: 'job_type_options',
|
variable: 'job_type_options',
|
||||||
callback: 'choicesReady'
|
callback: 'choicesReady'
|
||||||
@@ -379,7 +428,7 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
|
|||||||
|
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: '/static/sample/data/types/data.json', //GetBasePath('jobs')
|
url: GetBasePath('unified_jobs'), //'/static/sample/data/types/data.json'
|
||||||
field: 'type',
|
field: 'type',
|
||||||
variable: 'type_choices',
|
variable: 'type_choices',
|
||||||
callback: 'choicesReady'
|
callback: 'choicesReady'
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers'])
|
angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'JobSummaryDefinition', 'InventoryHelper', 'GeneratorHelpers',
|
||||||
|
'JobSubmissionHelper'])
|
||||||
|
|
||||||
.factory('JobStatusToolTip', [
|
.factory('JobStatusToolTip', [
|
||||||
function () {
|
function () {
|
||||||
@@ -215,7 +216,7 @@ angular.module('JobsHelper', ['Utilities', 'FormGenerator', 'JobSummaryDefinitio
|
|||||||
if (list.fields.type) {
|
if (list.fields.type) {
|
||||||
parent_scope.type_choices.every(function(choice) {
|
parent_scope.type_choices.every(function(choice) {
|
||||||
if (choice.value === item.type) {
|
if (choice.value === item.type) {
|
||||||
itm.type = choice.label;
|
itm.type_label = choice.label;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
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: {
|
type: {
|
||||||
label: 'Type',
|
label: 'Type',
|
||||||
|
ngBind: 'completed_job.type_label',
|
||||||
link: false,
|
link: false,
|
||||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||||
},
|
},
|
||||||
@@ -101,7 +102,7 @@ angular.module('CompletedJobsDefinition', [])
|
|||||||
submit: {
|
submit: {
|
||||||
icon: 'icon-rocket',
|
icon: 'icon-rocket',
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
ngClick: 'submitJob(completed_job.id, completed_job.summary_fields.job_template.name)',
|
ngClick: 'relaunch(completed_job.id)',
|
||||||
awToolTip: 'Relaunch the job',
|
awToolTip: 'Relaunch the job',
|
||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ angular.module('QueuedJobsDefinition', [])
|
|||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
label: 'Type',
|
label: 'Type',
|
||||||
|
ngBind: 'queued_job.type_label',
|
||||||
link: false,
|
link: false,
|
||||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||||
},
|
},
|
||||||
@@ -78,7 +79,7 @@ angular.module('QueuedJobsDefinition', [])
|
|||||||
submit: {
|
submit: {
|
||||||
icon: 'icon-rocket',
|
icon: 'icon-rocket',
|
||||||
mode: 'all',
|
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',
|
awToolTip: 'Launch another instance of the job',
|
||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ angular.module('RunningJobsDefinition', [])
|
|||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
label: 'Type',
|
label: 'Type',
|
||||||
|
ngBind: 'running_job.type_label',
|
||||||
link: false,
|
link: false,
|
||||||
columnClass: "col-md-2 hidden-sm hidden-xs"
|
columnClass: "col-md-2 hidden-sm hidden-xs"
|
||||||
},
|
},
|
||||||
@@ -81,7 +82,7 @@ angular.module('RunningJobsDefinition', [])
|
|||||||
submit: {
|
submit: {
|
||||||
icon: 'icon-rocket',
|
icon: 'icon-rocket',
|
||||||
mode: 'all',
|
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',
|
awToolTip: 'Launch another instance of the job',
|
||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user