From d4cd9d355fad50e5ae1cf71c809ad9f217d4f6c9 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Fri, 10 Mar 2017 15:08:06 -0500 Subject: [PATCH] add ui support for specifying extra vars for ad-hoc commands see: #1744 --- .../manage/adhoc/adhoc.controller.js | 11 ++++++++-- .../inventories/manage/adhoc/adhoc.form.js | 21 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js b/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js index dec6b6397a..e264f83ba7 100644 --- a/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js +++ b/awx/ui/client/src/inventories/manage/adhoc/adhoc.controller.js @@ -12,7 +12,7 @@ function adhocController($q, $scope, $location, $stateParams, $state, CheckPasswords, PromptForPasswords, CreateLaunchDialog, CreateSelect2, adhocForm, GenerateForm, Rest, ProcessErrors, ClearScope, GetBasePath, GetChoices, - KindChange, CredentialList, Empty, Wait) { + KindChange, CredentialList, ParseTypeChange, Empty, Wait) { ClearScope(); @@ -162,6 +162,12 @@ function adhocController($q, $scope, $location, $stateParams, privateFn.initializeForm(id, urls, hostPattern); + // init codemirror + $scope.extra_vars = '---'; + $scope.parseType = 'yaml'; + $scope.envParseType = 'yaml'; + ParseTypeChange({ scope: $scope, field_id: 'adhoc_extra_vars' , variable: "extra_vars"}); + $scope.formCancel = function(){ $state.go('inventoryManage'); }; @@ -199,6 +205,7 @@ function adhocController($q, $scope, $location, $stateParams, "module_args": "", "forks": 0, "verbosity": 0, + "extra_vars": "", "privilege_escalation": "" }; @@ -297,5 +304,5 @@ function adhocController($q, $scope, $location, $stateParams, export default ['$q', '$scope', '$location', '$stateParams', '$state', 'CheckPasswords', 'PromptForPasswords', 'CreateLaunchDialog', 'CreateSelect2', 'adhocForm', 'GenerateForm', 'Rest', 'ProcessErrors', 'ClearScope', 'GetBasePath', - 'GetChoices', 'KindChange', 'CredentialList', 'Empty', 'Wait', + 'GetChoices', 'KindChange', 'CredentialList', 'ParseTypeChange', 'Empty', 'Wait', adhocController]; diff --git a/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js b/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js index f3233cac50..c58068deb6 100644 --- a/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js +++ b/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js @@ -10,7 +10,7 @@ * @description This form is for executing an adhoc command */ -export default function() { +export default ['i18n', function(i18n) { return { addTitle: 'EXECUTE COMMAND', name: 'adhoc', @@ -121,6 +121,23 @@ export default function() { dataPlacement: 'right', dataContainer: "body" }, + extra_vars: { + label: i18n._('Extra Variables'), + type: 'textarea', + class: 'Form-textAreaLabel Form-formGroup--fullWidth', + rows: 6, + "default": "---", + column: 2, + awPopOver: "

" + i18n.sprintf(i18n._("Pass extra command line variables. This is the %s or %s command line parameter " + + "for %s. Provide key/value pairs using either YAML or JSON."), '-e', '--extra-vars', 'ansible') + "

" + + "JSON:
\n" + + "
{
 \"somevar\": \"somevalue\",
 \"password\": \"magic\"
}
\n" + + "YAML:
\n" + + "
---
somevar: somevalue
password: magic
\n", + dataTitle: i18n._('Extra Variables'), + dataPlacement: 'right', + dataContainer: "body" + } }, buttons: { reset: { @@ -139,4 +156,4 @@ export default function() { related: {} }; -} +}];