Add prompt on launch for 'verbosity' JT field (#6475)

This commit is contained in:
Jake McDermott 2017-06-12 13:30:20 -04:00 committed by GitHub
parent c0d70ca1ad
commit 8adb501eb8
9 changed files with 81 additions and 9 deletions

View File

@ -66,6 +66,10 @@ export default
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){
for (var i=0; i < scope.survey_questions.length; i++){
var fld = scope.survey_questions[i].variable;

View File

@ -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
// 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.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;
@ -180,8 +180,38 @@ export default
$scope.other_prompt_data = {};
if($scope.ask_job_type_on_launch) {
$scope.other_prompt_data.job_type = (data.defaults && data.defaults.job_type) ? data.defaults.job_type : "";
let getChoices = (options, lookup) => {
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) {

View File

@ -50,6 +50,11 @@ export default [ 'templateUrl', 'CreateDialog', 'Wait', 'CreateSelect2', 'ParseT
multiple: false
});
CreateSelect2({
element: '#job_launch_verbosity',
multiple: false
});
if(scope.step === 'otherprompts' && scope.ask_variables_on_launch) {
ParseTypeChange({
scope: scope,

View File

@ -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>
</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">
<label for="job_type">
<span class="Form-inputLabel prepend-asterisk" translate> Job Type</span>
</label>
<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>
<option value="" class="" selected="selected" translate>Choose a job type</option>
<option label="Run" value="run" selected="selected" translate>Run</option>
<option label="Check" value="check" translate>Check</option>
<select
id="job_launch_job_type"
ng-options="v.label for v in other_prompt_data.job_type_options track by v.value"
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>
</div>
</div>

View File

@ -790,7 +790,7 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
.error(function(data, status) {
ProcessErrors(scope, data, status, null, {
hdr: 'Error!',
msg: 'Failed to get ' + url + '. GET status: ' + status
msg: 'Failed to get ' + url + '. OPTIONS status: ' + status
});
});
} else {

View File

@ -241,7 +241,11 @@ function(NotificationsList, CompletedJobsList, i18n) {
dataTitle: i18n._('Verbosity'),
dataPlacement: 'right',
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: {
label: i18n._('Instance Groups'),

View File

@ -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_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_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_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;

View File

@ -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_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_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_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;

View File

@ -103,6 +103,9 @@ export default
scope.ask_variables_on_launch = (data.ask_variables_on_launch) ? true : false;
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;
master.ask_limit_on_launch = scope.ask_limit_on_launch;