diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js
index baccf6e300..01e5f02bf6 100644
--- a/awx/ui/static/js/helpers/JobSubmission.js
+++ b/awx/ui/static/js/helpers/JobSubmission.js
@@ -14,25 +14,60 @@
angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition', 'CredentialsListDefinition',
'LookUpHelper', 'JobSubmissionHelper', 'JobTemplateFormDefinition', 'ModalDialog', 'FormGenerator', 'JobVarsPromptFormDefinition'])
-.factory('LaunchJob', ['Rest', 'Wait', 'ProcessErrors',
- function(Rest, Wait, ProcessErrors) {
+.factory('LaunchJob', ['Rest', 'Wait', 'ProcessErrors', 'ToJSON',
+ function(Rest, Wait, ProcessErrors, ToJSON) {
return function(params) {
var scope = params.scope,
- passwords = params.passwords || {},
+ // passwords = params.passwords || {},
callback = params.callback || 'JobLaunched',
- url = params.url;
+ job_launch_data = {},
+ url = params.url,
+ fld;
+
+
+ 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 (fld in scope.job_launch_form){
+ if(scope[fld]){
+ job_launch_data[fld] = scope[fld];
+ }
+ }
+ }
- Wait('start');
Rest.setUrl(url);
- Rest.post(passwords)
+ Rest.post(job_launch_data)
.success(function(data) {
- scope.new_job_id = data.job;
+ Wait('stop');
+ if(!$('#password-modal').is(':hidden')){
+ $('#password-modal').dialog('close');
+ }
scope.$emit(callback, data);
+ scope.$destroy();
})
- .error(function (data, status) {
+ .error(function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
- msg: 'Attempt to start job at ' + url + ' failed. POST returned: ' + status });
+ msg: 'Failed updating job ' + scope.job_template_id + ' with variables. PUT returned: ' + status });
});
+
+
+ // Wait('start');
+ // Rest.setUrl(url);
+ // Rest.post(passwords)
+ // .success(function(data) {
+ // scope.new_job_id = data.job;
+ // scope.$emit(callback, data);
+ // })
+ // .error(function (data, status) {
+ // ProcessErrors(scope, data, status, null, { hdr: 'Error!',
+ // msg: 'Attempt to start job at ' + url + ' failed. POST returned: ' + status });
+ // });
};
}])
@@ -106,16 +141,16 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
.factory('CreateLaunchDialog', ['$compile', 'Rest', 'GetBasePath', 'TextareaResize', 'CreateDialog', 'GenerateForm',
- 'JobVarsPromptForm', 'Wait', 'ProcessErrors', 'ToJSON',
+ 'JobVarsPromptForm', 'Wait',
function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm,
- JobVarsPromptForm, Wait, ProcessErrors, ToJSON) {
+ JobVarsPromptForm, Wait) {
return function(params) {
var buttons,
scope = params.scope,
html = params.html,
- job_launch_data = {},
+ // job_launch_data = {},
callback = params.callback || 'PlaybookLaunchFinished',
- url = params.url,
+ // url = params.url,
e;
// html+='
job_launch_form.$valid = {{job_launch_form.$valid}}
';
@@ -125,46 +160,12 @@ 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() {
- $('password-modal').close();
+ $('#password-modal').dialog('close');
+ // scope.$emit('CancelJob');
+ // scope.$destroy();
},
icon: "fa-times",
"class": "btn btn-default",
@@ -172,7 +173,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
},{
label: "Continue",
onClick: function() {
- scope.jobLaunchFormAccept();
+ scope.$emit(callback);
},
icon: "fa-check",
"class": "btn btn-primary",
@@ -216,7 +217,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
callback = params.callback || 'PasswordsAccepted',
url = params.url,
form = CredentialForm,
- acceptedPasswords = {},
+ // acceptedPasswords = {},
fld, field,
html=params.html || "";
@@ -324,21 +325,21 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
}
};
- scope.passwordAccept = function() {
- if (!scope.password_form.$invalid) {
- scope.passwords.forEach(function(password) {
- acceptedPasswords[password] = scope[password];
- });
- $('#password-modal').dialog('close');
- scope.$emit(callback, acceptedPasswords);
- }
- };
+ // scope.passwordAccept = function() {
+ // if (!scope.password_form.$invalid) {
+ // scope.passwords.forEach(function(password) {
+ // acceptedPasswords[password] = scope[password];
+ // });
+ // $('#password-modal').dialog('close');
+ // scope.$emit(callback, acceptedPasswords);
+ // }
+ // };
- scope.passwordCancel = function() {
- $('#password-modal').dialog('close');
- scope.$emit('CancelJob');
- scope.$destroy();
- };
+ // scope.passwordCancel = function() {
+ // $('#password-modal').dialog('close');
+ // scope.$emit('CancelJob');
+ // scope.$destroy();
+ // };
// Password change
scope.clearPWConfirm = function (fld) {
@@ -368,7 +369,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
// parent_scope = params.scope,
scope = params.scope,
callback = params.callback,
- job = params.job,
+ // job = params.job,
url = params.url,
vars_url = GetBasePath('job_templates')+scope.job_template_id + '/',
// e, helpContainer,
@@ -496,29 +497,29 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
// callback: 'DialogReady'
// });
- scope.varsCancel = function() {
- $('#password-modal').dialog('close');
- scope.$emit('CancelJob');
- scope.$destroy();
- };
+ // scope.varsCancel = function() {
+ // $('#password-modal').dialog('close');
+ // scope.$emit('CancelJob');
+ // scope.$destroy();
+ // };
- scope.varsAccept = function() {
- job.extra_vars = ToJSON(scope.parseType, scope.variables, true);
- Wait('start');
- //Rest.setUrl(GetBasePath('jobs') + job.id + '/');
- Rest.setUrl(url);
- Rest.put(job)
- .success(function() {
- Wait('stop');
- $('#password-modal').dialog('close');
- scope.$emit(callback);
- scope.$destroy();
- })
- .error(function(data, status) {
- ProcessErrors(scope, data, status, null, { hdr: 'Error!',
- msg: 'Failed updating job ' + job.id + ' with variables. PUT returned: ' + status });
- });
- };
+ // scope.varsAccept = function() {
+ // job.extra_vars = ToJSON(scope.parseType, scope.variables, true);
+ // Wait('start');
+ // //Rest.setUrl(GetBasePath('jobs') + job.id + '/');
+ // Rest.setUrl(url);
+ // Rest.put(job)
+ // .success(function() {
+ // Wait('stop');
+ // $('#password-modal').dialog('close');
+ // scope.$emit(callback);
+ // scope.$destroy();
+ // })
+ // .error(function(data, status) {
+ // ProcessErrors(scope, data, status, null, { hdr: 'Error!',
+ // msg: 'Failed updating job ' + job.id + ' with variables. PUT returned: ' + status });
+ // });
+ // };
};
}])
@@ -531,6 +532,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
var html = params.html || "",
id= params.id,
url = params.url,
+ callback=params.callback,
scope = params.scope,
i, j,
requiredAsterisk,
@@ -545,110 +547,88 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
function buildHtml(question, index){
question.index = index;
- if(!$('#taker_'+question.index+':eq(0)').is('div')){
- html+='
Fix the following issues before using the template:
" + html, 'alert-danger'); - } - else { - ProcessErrors(scope, data, status, null, { hdr: 'Error!', - msg: 'Failed to create job. POST returned status: ' + status }); - } - }); - }); + // if (scope.removePostTheJob) { + // scope.removePostTheJob(); + // } + // scope.removePostTheJob = scope.$on('PostTheJob', function() { + // var url = (job_template.related.jobs) ? job_template.related.jobs : job_template.related.job_template + 'jobs/'; + // Wait('start'); + // Rest.setUrl(url); + // Rest.post(job_template) + // .success(function (data) { + // new_job_id = data.id; + // launch_url = data.related.start; + // prompt_for_vars = data.ask_variables_on_launch; + // new_job = data; + // if (data.passwords_needed_to_start.length > 0) { + // scope.$emit('PromptForPasswords', data.passwords_needed_to_start); + // } + // else if (data.ask_variables_on_launch) { + // scope.$emit('PromptForVars'); + // } + // else { + // scope.$emit('StartPlaybookRun'); + // } + // }) + // .error(function (data, status) { + // var key, html; + // if (status === 400) { + // // there's a data problem with the job template + // html = "Fix the following issues before using the template:
" + html, 'alert-danger'); + // } + // else { + // ProcessErrors(scope, data, status, null, { hdr: 'Error!', + // msg: 'Failed to create job. POST returned status: ' + status }); + // } + // }); + // }); if (scope.removeCancelJob) { scope.removeCancelJob(); @@ -902,9 +772,9 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi LaunchJob({ scope: scope, url: url, - callback: 'PlaybookLaunchFinished', - passwords: passwords + callback: 'PlaybookLaunchFinished' }); + }); if (scope.removePromptForPasswords) { @@ -960,18 +830,29 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi scope: scope, id: scope.job_template_id, variables: extra_vars, - callback: 'StartPlaybookRun', + callback: 'CreateModal', url: url, html: html }); } else { - // scope.$emit('StartPlaybookRun'); - CreateLaunchDialog({scope: scope, html: html, url: url}); + scope.$emit('CreateModal', html, url); + // CreateLaunchDialog({scope: scope, html: html, url: url}); } }); + if (scope.removeCreateModal) { + scope.removeCreateModal(); + } + scope.removeCreateModal = scope.$on('CreateModal', function(e, html, url) { + CreateLaunchDialog({ + scope: scope, + html: html, + url: url, + callback: 'StartPlaybookRun' + }); + }); if (scope.removeCredentialReady) { diff --git a/awx/ui/static/less/survey-maker.less b/awx/ui/static/less/survey-maker.less index d7d56e946e..274a74a073 100644 --- a/awx/ui/static/less/survey-maker.less +++ b/awx/ui/static/less/survey-maker.less @@ -64,23 +64,17 @@ margin-bottom: 15px; } -.survey_taker_question{ - margin-bottom: 25px; -} .survey_taker_input{ - margin-top: 5px; - margin-left: 15px; + .mc{ margin-left: 18px; margin-right: 7px; } } - - .survey_taker_description{ - padding-left: 30px; + margin-bottom:10px } .survey_error{