diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js
index 440db4f66d..a79c276f2d 100644
--- a/awx/ui/static/js/helpers/JobSubmission.js
+++ b/awx/ui/static/js/helpers/JobSubmission.js
@@ -105,15 +105,17 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
-.factory('CreateLaunchDialog', ['$compile', 'Rest', 'GetBasePath', 'TextareaResize', 'CreateDialog', 'GenerateForm', 'JobVarsPromptForm', 'Wait',
- function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm, JobVarsPromptForm, Wait) {
+.factory('CreateLaunchDialog', ['$compile', 'Rest', 'GetBasePath', 'TextareaResize', 'CreateDialog', 'GenerateForm',
+ 'JobVarsPromptForm', 'Wait', 'ProcessErrors', 'ToJSON',
+ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm,
+ JobVarsPromptForm, Wait, ProcessErrors, ToJSON) {
return function(params) {
var buttons,
scope = params.scope,
html = params.html,
- // callback = params.callback,
- // job = params.job,
- // url = params.url,
+ job_launch_data = {},
+ callback = params.callback || 'PlaybookLaunchFinished',
+ url = params.url,
e;
html+='
job_launch_form.$valid = {{job_launch_form.$valid}}
';
@@ -122,10 +124,46 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
e = angular.element(document.getElementById('password-modal'));
$compile(e)(scope);
+ scope.jobLaunchFormAccept = function(){
+ if(scope.passwords_needed_to_start.length>0){
+ scope.passwords.forEach(function(password) {
+ job_launch_data[password] = scope[password];
+ });
+ }
+ if(scope.prompt_for_vars===true){
+ job_launch_data.extra_vars = ToJSON(scope.parseType, scope.variables, true);
+ }
+ if(scope.survey_enabled===true){
+ for ( var fld in scope.job_launch_form){
+ if(scope[fld]){
+ job_launch_data[fld] = scope[fld];
+ }
+ }
+ }
+
+ Rest.setUrl(url);
+ Rest.post(job_launch_data)
+ .success(function(data) {
+ Wait('stop');
+ $('#password-modal').dialog('close');
+ scope.$emit(callback, data);
+ scope.$destroy();
+ })
+ .error(function(data, status) {
+ ProcessErrors(scope, data, status, null, { hdr: 'Error!',
+ msg: 'Failed updating job ' + scope.job_template_id + ' with variables. PUT returned: ' + status });
+ });
+
+ };
+
+
+
+
+
buttons = [{
label: "Cancel",
onClick: function() {
- scope.passwordCancel();
+ $('password-modal').close();
},
icon: "fa-times",
"class": "btn btn-default",
@@ -133,7 +171,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
},{
label: "Continue",
onClick: function() {
- scope.passwordAccept();
+ scope.jobLaunchFormAccept();
},
icon: "fa-check",
"class": "btn btn-primary",
@@ -175,6 +213,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
return function(params) {
var scope = params.scope,
callback = params.callback || 'PasswordsAccepted',
+ url = params.url,
form = CredentialForm,
acceptedPasswords = {},
fld, field,
@@ -239,7 +278,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
// $('#password-modal').empty().html(buildHtml);
// e = angular.element(document.getElementById('password-modal'));
// $compile(e)(scope);
- scope.$emit(callback, html);
+ scope.$emit(callback, html, url);
// CreateLaunchDialog({scope: scope})
// buttons = [{
// label: "Cancel",
@@ -320,9 +359,9 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
}])
.factory('PromptForVars', ['$compile', 'Rest', 'GetBasePath', 'TextareaResize', 'CreateLaunchDialog', 'GenerateForm', 'JobVarsPromptForm', 'Wait',
- 'ParseVariableString', 'ToJSON', 'ProcessErrors',
+ 'ParseVariableString', 'ToJSON', 'ProcessErrors', '$routeParams' ,
function($compile, Rest, GetBasePath, TextareaResize,CreateLaunchDialog, GenerateForm, JobVarsPromptForm, Wait,
- ParseVariableString, ToJSON, ProcessErrors) {
+ ParseVariableString, ToJSON, ProcessErrors, $routeParams) {
return function(params) {
var
// parent_scope = params.scope,
@@ -330,27 +369,61 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
callback = params.callback,
job = params.job,
url = params.url,
+ vars_url = GetBasePath('job_templates')+scope.job_template_id + '/',
// e, helpContainer,
html = params.html || "";
- html += GenerateForm.buildHTML(JobVarsPromptForm, { mode: 'edit', modal: true, scope: scope });
- scope.helpContainer = "
After defining any extra variables, click Continue to start the job. Otherwise, click cancel to abort.
" + - "Extra variables are passed as command line variables to the playbook run. It is equivalent to the -e or --extra-vars " + - "command line parameter for ansible-playbook. Provide key/value pairs using either YAML or JSON.
" + - "JSON:{\n" + - "YAML:
\"somevar\": \"somevalue\",
\"password\": \"magic\"
}
---\n" + - " \n"; + function buildHtml(extra_vars){ + // html += GenerateForm.buildHTML(JobVarsPromptForm, { mode: 'edit', scope: scope }); + // scope.helpContainer = "
somevar: somevalue
password: magic
After defining any extra variables, click Continue to start the job. Otherwise, click cancel to abort.
" + + // "Extra variables are passed as command line variables to the playbook run. It is equivalent to the -e or --extra-vars " + + // "command line parameter for ansible-playbook. Provide key/value pairs using either YAML or JSON.
" + + // "JSON:{\n" + + // "YAML:
\"somevar\": \"somevalue\",
\"password\": \"magic\"
}
---\n" + + // " \n"; + + //
somevar: somevalue
password: magic