From 4bdab2d2fab15b8673d1117feca4e43b811f3d8c Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Mon, 27 Apr 2015 10:13:25 -0400 Subject: [PATCH] adhoc form fixes added forks input fixed privilege escalation language, it now mimics job template fixed a hanging issue when a non-machine credential is used fixed reset to include the default verbosity setting --- awx/ui/static/js/controllers/Adhoc.js | 46 +++++++---------------- awx/ui/static/js/forms/Adhoc.js | 39 ++++++++++++++----- awx/ui/static/js/forms/JobTemplates.js | 2 +- awx/ui/static/js/helpers/JobSubmission.js | 3 +- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/awx/ui/static/js/controllers/Adhoc.js b/awx/ui/static/js/controllers/Adhoc.js index d4d3501f2d..d9e5779262 100644 --- a/awx/ui/static/js/controllers/Adhoc.js +++ b/awx/ui/static/js/controllers/Adhoc.js @@ -36,6 +36,7 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams, $scope.id = id; $scope.argsPopOver = "

These arguments are used with the" + " specified module.

"; + // fix arguments help popover based on the module selected $scope.moduleChange = function () { // NOTE: for selenium testing link - @@ -64,20 +65,13 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams, $scope.providedHostPatterns = $scope.limit; delete $rootScope.hostPatterns; - if ($scope.removeLookUpInitialize) { - $scope.removeLookUpInitialize(); - } - $scope.removeLookUpInitialize = $scope.$on('lookUpInitialize', function () { - LookUpInit({ - scope: $scope, - form: form, - current_item: (!Empty($scope.credential_id)) ? $scope.credential_id : null, - list: CredentialList, - field: 'credential', - input_type: 'radio' - }); - - Wait('stop'); // END: form population + LookUpInit({ + scope: $scope, + form: form, + current_item: (!Empty($scope.credential_id)) ? $scope.credential_id : null, + list: CredentialList, + field: 'credential', + input_type: 'radio' }); if ($scope.removeChoicesReady) { @@ -87,9 +81,10 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams, choicesReadyCount++; if (choicesReadyCount === 2) { - // this sets the default option as specified by the controller. + // this sets the default options for the selects as specified by the controller. $scope.verbosity = $scope.adhoc_verbosity_options[$scope.verbosity_field.default]; - $scope.$emit('lookUpInitialize'); + $("#forks-number").spinner("value", $scope.forks_field.default); + Wait('stop'); // END: form population } }); @@ -212,23 +207,6 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams, credential: $scope.credential, callback: 'ContinueCred' }); - - // // Launch the adhoc job - // Rest.setUrl(url); - // Rest.post(data) - // .success(function (data) { - // Wait('stop'); - // $location.path("/ad_hoc_commands/" + data.id); - // }) - // .error(function (data, status) { - // ProcessErrors($scope, data, status, form, { hdr: 'Error!', - // msg: 'Failed to launch adhoc command. POST returned status: ' + - // status }); - // // TODO: still need to implement popping up a password prompt - // // if the credential requires it. The way that the current end- - // // point works is that I find out if I need to ask for a - // // password from POST, thus I get an error response. - // }); }; // Remove all data input into the form @@ -239,6 +217,8 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams, } $scope.limit = $scope.providedHostPatterns; KindChange({ scope: $scope, form: form, reset: false }); + $scope.verbosity = $scope.adhoc_verbosity_options[$scope.verbosity_field.default]; + $("#forks-number").spinner("value", $scope.forks_field.default); }; } diff --git a/awx/ui/static/js/forms/Adhoc.js b/awx/ui/static/js/forms/Adhoc.js index 62c66d342a..3c83aa78c8 100644 --- a/awx/ui/static/js/forms/Adhoc.js +++ b/awx/ui/static/js/forms/Adhoc.js @@ -82,14 +82,15 @@ export default } }, become_enabled: { - label: 'Enable Become for Credential', + label: 'Enable Privilege Escalation', type: 'checkbox', - editRequired: false - // awPopOver: '

If checked, user will be become the user ' + - // 'specified by the credential.

', - // dataPlacement: 'right', - // dataTitle: 'Enable Become for Credential', - // dataContainer: 'body' + addRequired: false, + editRequird: false, + column: 2, + awPopOver: "

If enabled, run this playbook as an administrator. This is the equivalent of passing the --become option to the ansible command.

", + dataPlacement: 'right', + dataTitle: 'Become Privilege Escalation', + dataContainer: "body" }, verbosity: { label: 'Verbosity', @@ -104,8 +105,28 @@ export default 'out of the command run that are supported.', dataTitle: 'Module', dataPlacement: 'right', - dataContainer: 'body' - } + dataContainer: 'body', + default: 1 + }, + forks: { + label: 'Forks', + id: 'forks-number', + type: 'number', + integer: true, + min: 0, + spinner: true, + "default": 0, + addRequired: false, + editRequired: false, + 'class': "input-small", + column: 1, + awPopOver: '

The number of parallel or simultaneous processes to use while executing the command. 0 signifies ' + + 'the default value from the ansible configuration file.

', + dataTitle: 'Forks', + dataPlacement: 'right', + dataContainer: "body" + }, }, buttons: { diff --git a/awx/ui/static/js/forms/JobTemplates.js b/awx/ui/static/js/forms/JobTemplates.js index be05435de3..49f3b70f9f 100644 --- a/awx/ui/static/js/forms/JobTemplates.js +++ b/awx/ui/static/js/forms/JobTemplates.js @@ -176,7 +176,7 @@ export default 'class': "input-small", column: 1, awPopOver: '

The number of parallel or simultaneous processes to use while executing the playbook. 0 signifies ' + - 'the default value from the ansible configuration file.

', dataTitle: 'Forks', dataPlacement: 'right', diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index b7db81955b..f0d9f4bc83 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -710,9 +710,8 @@ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm, if(data.vault_password === "ASK"){ passwords.push("vault_password"); } - scope.$emit(callback, passwords); } - + scope.$emit(callback, passwords); }) .error(function (data, status) { ProcessErrors(scope, data, status, null, { hdr: 'Error!',