mirror of
https://github.com/ansible/awx.git
synced 2026-03-28 14:25:05 -02:30
Add prompt on launch for 'verbosity' JT field (#6475)
This commit is contained in:
@@ -66,6 +66,10 @@ export default
|
|||||||
job_launch_data.job_type = scope.other_prompt_data.job_type;
|
job_launch_data.job_type = scope.other_prompt_data.job_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(scope.ask_verbosity_on_launch && scope.other_prompt_data && scope.other_prompt_data.verbosity) {
|
||||||
|
job_launch_data.verbosity = scope.other_prompt_data.verbosity;
|
||||||
|
}
|
||||||
|
|
||||||
if(scope.survey_enabled===true){
|
if(scope.survey_enabled===true){
|
||||||
for (var i=0; i < scope.survey_questions.length; i++){
|
for (var i=0; i < scope.survey_questions.length; i++){
|
||||||
var fld = scope.survey_questions[i].variable;
|
var fld = scope.survey_questions[i].variable;
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ export default
|
|||||||
|
|
||||||
// General catch-all for "other prompts" - used in this link function and to hide the Other Prompts tab when
|
// General catch-all for "other prompts" - used in this link function and to hide the Other Prompts tab when
|
||||||
// it should be hidden
|
// it should be hidden
|
||||||
$scope.has_other_prompts = (data.ask_job_type_on_launch || data.ask_limit_on_launch || data.ask_tags_on_launch || data.ask_skip_tags_on_launch || data.ask_variables_on_launch) ? true : false;
|
$scope.has_other_prompts = (data.ask_verbosity_on_launch || data.ask_job_type_on_launch || data.ask_limit_on_launch || data.ask_tags_on_launch || data.ask_skip_tags_on_launch || data.ask_variables_on_launch) ? true : false;
|
||||||
$scope.password_needed = data.passwords_needed_to_start && data.passwords_needed_to_start.length > 0;
|
$scope.password_needed = data.passwords_needed_to_start && data.passwords_needed_to_start.length > 0;
|
||||||
$scope.has_default_inventory = data.defaults && data.defaults.inventory && data.defaults.inventory.id;
|
$scope.has_default_inventory = data.defaults && data.defaults.inventory && data.defaults.inventory.id;
|
||||||
$scope.has_default_credential = data.defaults && data.defaults.credential && data.defaults.credential.id;
|
$scope.has_default_credential = data.defaults && data.defaults.credential && data.defaults.credential.id;
|
||||||
@@ -180,8 +180,38 @@ export default
|
|||||||
|
|
||||||
$scope.other_prompt_data = {};
|
$scope.other_prompt_data = {};
|
||||||
|
|
||||||
if($scope.ask_job_type_on_launch) {
|
let getChoices = (options, lookup) => {
|
||||||
$scope.other_prompt_data.job_type = (data.defaults && data.defaults.job_type) ? data.defaults.job_type : "";
|
return _.get(options, lookup, []).map(c => ({label: c[1], value: c[0]}));
|
||||||
|
};
|
||||||
|
|
||||||
|
let getChoiceFromValue = (choices, value) => {
|
||||||
|
return _.find(choices, item => item.value === value);
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($scope.has_other_prompts) {
|
||||||
|
Rest.options()
|
||||||
|
.success(options => {
|
||||||
|
if ($scope.ask_job_type_on_launch) {
|
||||||
|
let choices = getChoices(options, 'actions.POST.job_type.choices');
|
||||||
|
let initialValue = _.get(data, 'defaults.job_type');
|
||||||
|
let initialChoice = getChoiceFromValue(choices, initialValue);
|
||||||
|
$scope.other_prompt_data.job_type_options = choices;
|
||||||
|
$scope.other_prompt_data.job_type = initialChoice;
|
||||||
|
}
|
||||||
|
if ($scope.ask_verbosity_on_launch) {
|
||||||
|
let choices = getChoices(options, 'actions.POST.verbosity.choices');
|
||||||
|
let initialValue = _.get(data, 'defaults.verbosity');
|
||||||
|
let initialChoice = getChoiceFromValue(choices, initialValue);
|
||||||
|
$scope.other_prompt_data.verbosity_options = choices;
|
||||||
|
$scope.other_prompt_data.verbosity = initialChoice;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error((err, status) => {
|
||||||
|
ProcessErrors($scope, err, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: `Failed to get ${launch_url}. OPTIONS status: ${status}`
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if($scope.ask_limit_on_launch) {
|
if($scope.ask_limit_on_launch) {
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ export default [ 'templateUrl', 'CreateDialog', 'Wait', 'CreateSelect2', 'ParseT
|
|||||||
multiple: false
|
multiple: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CreateSelect2({
|
||||||
|
element: '#job_launch_verbosity',
|
||||||
|
multiple: false
|
||||||
|
});
|
||||||
|
|
||||||
if(scope.step === 'otherprompts' && scope.ask_variables_on_launch) {
|
if(scope.step === 'otherprompts' && scope.ask_variables_on_launch) {
|
||||||
ParseTypeChange({
|
ParseTypeChange({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
|
|||||||
@@ -144,15 +144,39 @@
|
|||||||
<textarea rows="6" ng-model="other_prompt_data.extra_vars" name="variables" class="form-control Form-textArea Form-textAreaLabel" id="job_launch_variables" aw-watch=""></textarea>
|
<textarea rows="6" ng-model="other_prompt_data.extra_vars" name="variables" class="form-control Form-textArea Form-textAreaLabel" id="job_launch_variables" aw-watch=""></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ask_verbosity_on_launch">
|
||||||
|
<label for="verbosity">
|
||||||
|
<span class="Form-inputLabel prepend-asterisk"> Verbosity</span>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<select
|
||||||
|
id="job_launch_verbosity"
|
||||||
|
ng-options="v.label for v in other_prompt_data.verbosity_options track by v.value"
|
||||||
|
ng-model="other_prompt_data.verbosity"
|
||||||
|
class="form-control Form-dropDown"
|
||||||
|
name="verbosity"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-hidden="true"
|
||||||
|
required>
|
||||||
|
<option value="" class="" selected="selected">Choose a verbosity</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ask_job_type_on_launch">
|
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ask_job_type_on_launch">
|
||||||
<label for="job_type">
|
<label for="job_type">
|
||||||
<span class="Form-inputLabel prepend-asterisk" translate> Job Type</span>
|
<span class="Form-inputLabel prepend-asterisk" translate> Job Type</span>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<select ng-model="other_prompt_data.job_type" name="job_type" class="form-control Form-dropDown" id="job_launch_job_type" tabindex="-1" aria-hidden="true" required>
|
<select
|
||||||
<option value="" class="" selected="selected" translate>Choose a job type</option>
|
id="job_launch_job_type"
|
||||||
<option label="Run" value="run" selected="selected" translate>Run</option>
|
ng-options="v.label for v in other_prompt_data.job_type_options track by v.value"
|
||||||
<option label="Check" value="check" translate>Check</option>
|
ng-model="other_prompt_data.job_type"
|
||||||
|
class="form-control Form-dropDown"
|
||||||
|
name="job_type"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-hidden="true"
|
||||||
|
required>
|
||||||
|
<option value="" class="" selected="selected">Choose a job type</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -790,7 +790,7 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
|||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
ProcessErrors(scope, data, status, null, {
|
ProcessErrors(scope, data, status, null, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to get ' + url + '. GET status: ' + status
|
msg: 'Failed to get ' + url + '. OPTIONS status: ' + status
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -241,7 +241,11 @@ function(NotificationsList, CompletedJobsList, i18n) {
|
|||||||
dataTitle: i18n._('Verbosity'),
|
dataTitle: i18n._('Verbosity'),
|
||||||
dataPlacement: 'right',
|
dataPlacement: 'right',
|
||||||
dataContainer: "body",
|
dataContainer: "body",
|
||||||
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)'
|
subCheckbox: {
|
||||||
|
variable: 'ask_verbosity_on_launch',
|
||||||
|
text: i18n._('Prompt on launch')
|
||||||
|
},
|
||||||
|
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
||||||
},
|
},
|
||||||
instance_groups: {
|
instance_groups: {
|
||||||
label: i18n._('Instance Groups'),
|
label: i18n._('Instance Groups'),
|
||||||
|
|||||||
@@ -408,6 +408,7 @@
|
|||||||
data.ask_skip_tags_on_launch = $scope.ask_skip_tags_on_launch ? $scope.ask_skip_tags_on_launch : false;
|
data.ask_skip_tags_on_launch = $scope.ask_skip_tags_on_launch ? $scope.ask_skip_tags_on_launch : false;
|
||||||
data.ask_limit_on_launch = $scope.ask_limit_on_launch ? $scope.ask_limit_on_launch : false;
|
data.ask_limit_on_launch = $scope.ask_limit_on_launch ? $scope.ask_limit_on_launch : false;
|
||||||
data.ask_job_type_on_launch = $scope.ask_job_type_on_launch ? $scope.ask_job_type_on_launch : false;
|
data.ask_job_type_on_launch = $scope.ask_job_type_on_launch ? $scope.ask_job_type_on_launch : false;
|
||||||
|
data.ask_verbosity_on_launch = $scope.ask_verbosity_on_launch ? $scope.ask_verbosity_on_launch : false;
|
||||||
data.ask_inventory_on_launch = $scope.ask_inventory_on_launch ? $scope.ask_inventory_on_launch : false;
|
data.ask_inventory_on_launch = $scope.ask_inventory_on_launch ? $scope.ask_inventory_on_launch : false;
|
||||||
data.ask_variables_on_launch = $scope.ask_variables_on_launch ? $scope.ask_variables_on_launch : false;
|
data.ask_variables_on_launch = $scope.ask_variables_on_launch ? $scope.ask_variables_on_launch : false;
|
||||||
data.ask_credential_on_launch = $scope.ask_credential_on_launch ? $scope.ask_credential_on_launch : false;
|
data.ask_credential_on_launch = $scope.ask_credential_on_launch ? $scope.ask_credential_on_launch : false;
|
||||||
|
|||||||
@@ -577,6 +577,7 @@ export default
|
|||||||
data.ask_skip_tags_on_launch = $scope.ask_skip_tags_on_launch ? $scope.ask_skip_tags_on_launch : false;
|
data.ask_skip_tags_on_launch = $scope.ask_skip_tags_on_launch ? $scope.ask_skip_tags_on_launch : false;
|
||||||
data.ask_limit_on_launch = $scope.ask_limit_on_launch ? $scope.ask_limit_on_launch : false;
|
data.ask_limit_on_launch = $scope.ask_limit_on_launch ? $scope.ask_limit_on_launch : false;
|
||||||
data.ask_job_type_on_launch = $scope.ask_job_type_on_launch ? $scope.ask_job_type_on_launch : false;
|
data.ask_job_type_on_launch = $scope.ask_job_type_on_launch ? $scope.ask_job_type_on_launch : false;
|
||||||
|
data.ask_verbosity_on_launch = $scope.ask_verbosity_on_launch ? $scope.ask_verbosity_on_launch : false;
|
||||||
data.ask_inventory_on_launch = $scope.ask_inventory_on_launch ? $scope.ask_inventory_on_launch : false;
|
data.ask_inventory_on_launch = $scope.ask_inventory_on_launch ? $scope.ask_inventory_on_launch : false;
|
||||||
data.ask_variables_on_launch = $scope.ask_variables_on_launch ? $scope.ask_variables_on_launch : false;
|
data.ask_variables_on_launch = $scope.ask_variables_on_launch ? $scope.ask_variables_on_launch : false;
|
||||||
data.ask_credential_on_launch = $scope.ask_credential_on_launch ? $scope.ask_credential_on_launch : false;
|
data.ask_credential_on_launch = $scope.ask_credential_on_launch ? $scope.ask_credential_on_launch : false;
|
||||||
|
|||||||
@@ -103,6 +103,9 @@ export default
|
|||||||
scope.ask_variables_on_launch = (data.ask_variables_on_launch) ? true : false;
|
scope.ask_variables_on_launch = (data.ask_variables_on_launch) ? true : false;
|
||||||
master.ask_variables_on_launch = scope.ask_variables_on_launch;
|
master.ask_variables_on_launch = scope.ask_variables_on_launch;
|
||||||
|
|
||||||
|
scope.ask_verbosity_on_launch = (data.ask_verbosity_on_launch) ? true : false;
|
||||||
|
master.ask_verbosity_on_launch = scope.ask_verbosity_on_launch;
|
||||||
|
|
||||||
scope.ask_limit_on_launch = (data.ask_limit_on_launch) ? true : false;
|
scope.ask_limit_on_launch = (data.ask_limit_on_launch) ? true : false;
|
||||||
master.ask_limit_on_launch = scope.ask_limit_on_launch;
|
master.ask_limit_on_launch = scope.ask_limit_on_launch;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user