1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

Merge pull request #6795 from jaredevantabor/skip-tags-job-tags

Skip tags job tags
This commit is contained in:
Jared Tabor 2017-06-29 11:10:26 -07:00 committed by GitHub
commit 112230081e
8 changed files with 123 additions and 12 deletions

View File

@ -50,12 +50,20 @@ export default
}
if(scope.ask_tags_on_launch && scope.other_prompt_data && typeof scope.other_prompt_data.job_tags === 'string'){
job_launch_data.job_tags = scope.other_prompt_data.job_tags;
if(scope.ask_tags_on_launch && scope.other_prompt_data && Array.isArray(scope.other_prompt_data.job_tags)){
scope.job_tags = _.map(scope.job_tags, function(i){return i.value;});
$("#job_launch_job_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
scope.job_tags.push(option.title);
});
job_launch_data.job_tags = (Array.isArray(scope.job_tags)) ? _.uniq(scope.job_tags).join() : "";
}
if(scope.ask_skip_tags_on_launch && scope.other_prompt_data && typeof scope.other_prompt_data.skip_tags === 'string'){
job_launch_data.skip_tags = scope.other_prompt_data.skip_tags;
if(scope.ask_skip_tags_on_launch && scope.other_prompt_data && Array.isArray(scope.other_prompt_data.skip_tags)){
scope.skip_tags = _.map(scope.skip_tags, function(i){return i.value;});
$("#job_launch_skip_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
scope.skip_tags.push(option.title);
});
job_launch_data.skip_tags = (Array.isArray(scope.skip_tags)) ? _.uniq(scope.skip_tags).join() : "";
}
if(scope.ask_limit_on_launch && scope.other_prompt_data && scope.other_prompt_data.limit){

View File

@ -219,11 +219,15 @@ export default
}
if($scope.ask_tags_on_launch) {
$scope.other_prompt_data.job_tags = (data.defaults && data.defaults.job_tags) ? data.defaults.job_tags : "";
$scope.other_prompt_data.job_tags_options = (data.defaults && data.defaults.job_tags) ? data.defaults.job_tags.split(',')
.map((i) => ({name: i, label: i, value: i})) : [];
$scope.other_prompt_data.job_tags = $scope.other_prompt_data.job_tags_options;
}
if($scope.ask_skip_tags_on_launch) {
$scope.other_prompt_data.skip_tags = (data.defaults && data.defaults.skip_tags) ? data.defaults.skip_tags : "";
$scope.other_prompt_data.skip_tags_options = (data.defaults && data.defaults.skip_tags) ? data.defaults.skip_tags.split(',')
.map((i) => ({name: i, label: i, value: i})) : [];
$scope.other_prompt_data.skip_tags = $scope.other_prompt_data.skip_tags_options;
}
if($scope.ask_variables_on_launch) {

View File

@ -61,6 +61,18 @@ export default [ 'templateUrl', 'CreateDialog', 'Wait', 'CreateSelect2', 'ParseT
placeholder: i18n._('Select a credential')
});
CreateSelect2({
element: '#job_launch_job_tags',
multiple: true,
addNew: true
});
CreateSelect2({
element: '#job_launch_skip_tags',
multiple: true,
addNew: true
});
if(scope.step === 'otherprompts' && scope.ask_variables_on_launch) {
ParseTypeChange({
scope: scope,

View File

@ -214,7 +214,16 @@
<span class="Form-inputLabel" translate>Job Tags</span>
</label>
<div>
<textarea rows="5" ng-model="other_prompt_data.job_tags" name="tags" class="form-control Form-textArea Form-textInput"></textarea>
<select
id="job_launch_job_tags"
ng-options="v.label for v in other_prompt_data.job_tags_options track by v.value"
ng-model="other_prompt_data.job_tags"
class="form-control Form-dropDown"
name="verbosity"
tabindex="-1"
aria-hidden="true"
multiple>
</select>
</div>
</div>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ask_skip_tags_on_launch">
@ -222,7 +231,17 @@
<span class="Form-inputLabel" translate>Skip Tags</span>
</label>
<div>
<textarea rows="5" ng-model="other_prompt_data.skip_tags" name="skip_tags" class="form-control Form-textArea Form-textInput"></textarea>
<!-- <textarea rows="5" ng-model="other_prompt_data.skip_tags" name="skip_tags" class="form-control Form-textArea Form-textInput"></textarea> -->
<select
id="job_launch_skip_tags"
ng-options="v.label for v in other_prompt_data.skip_tags_options track by v.value"
ng-model="other_prompt_data.skip_tags"
class="form-control Form-dropDown"
name="verbosity"
tabindex="-1"
aria-hidden="true"
multiple>
</select>
</div>
</div>
</form>

View File

@ -89,6 +89,17 @@
element:'#job_template_verbosity',
multiple: false
});
CreateSelect2({
element:'#job_template_job_tags',
multiple: true,
addNew: true
});
CreateSelect2({
element:'#job_template_skip_tags',
multiple: true,
addNew: true
});
}
});
@ -260,6 +271,8 @@
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;
data.job_tags = (Array.isArray($scope.job_tags)) ? $scope.job_tags.join() : "";
data.skip_tags = (Array.isArray($scope.skip_tags)) ? $scope.skip_tags.join() : "";
if ($scope.selectedCredentials && $scope.selectedCredentials
.machine && $scope.selectedCredentials
.machine) {
@ -296,6 +309,19 @@
.filter("[data-label-is-present=true]")
.map((i, val) => ({name: $(val).text()}));
$scope.job_tags = _.map($scope.job_tags, function(i){return i.value;});
$("#job_template_job_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
$scope.job_tags.push(option.title);
});
$scope.skip_tags = _.map($scope.skip_tags, function(i){return i.value;});
$("#job_template_skip_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
$scope.skip_tags.push(option.title);
});
data.job_tags = (Array.isArray($scope.job_tags)) ? _.uniq($scope.job_tags).join() : "";
data.skip_tags = (Array.isArray($scope.skip_tags)) ? _.uniq($scope.skip_tags).join() : "";
Rest.setUrl(defaultUrl);
Rest.post(data)
.then(({data}) => {

View File

@ -55,6 +55,8 @@ export default
$scope.instance_groups = InstanceGroupsData;
$scope.credentialNotPresent = false;
$scope.surveyTooltip = i18n._('Surveys allow users to be prompted at job launch with a series of questions related to the job. This allows for variables to be defined that affect the playbook run at time of launch.');
$scope.job_tag_options = [];
$scope.skip_tag_options = [];
SurveyControllerInit({
scope: $scope,
@ -175,6 +177,18 @@ export default
element:'#playbook-select',
multiple: false
});
CreateSelect2({
element:'#job_template_job_tags',
multiple: true,
addNew: true
});
CreateSelect2({
element:'#job_template_skip_tags',
multiple: true,
addNew: true
});
}
$scope.jobTypeChange = function() {
@ -469,6 +483,8 @@ export default
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;
data.job_tags = (Array.isArray($scope.job_tags)) ? $scope.job_tags.join() : "";
data.skip_tags = (Array.isArray($scope.skip_tags)) ? $scope.skip_tags.join() : "";
if ($scope.selectedCredentials && $scope.selectedCredentials
.machine && $scope.selectedCredentials
.machine) {
@ -505,6 +521,20 @@ export default
.filter("[data-label-is-present=true]")
.map((i, val) => ({name: $(val).text()}));
$scope.job_tags = _.map($scope.job_tags, function(i){return i.value;});
$("#job_template_job_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
$scope.job_tags.push(option.title);
});
$scope.skip_tags = _.map($scope.skip_tags, function(i){return i.value;});
$("#job_template_skip_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
$scope.skip_tags.push(option.title);
});
data.job_tags = (Array.isArray($scope.job_tags)) ? _.uniq($scope.job_tags).join() : "";
data.skip_tags = (Array.isArray($scope.skip_tags)) ? _.uniq($scope.skip_tags).join() : "";
Rest.setUrl(defaultUrl + $state.params.job_template_id);
Rest.put(data)
.success(function (data) {

View File

@ -113,6 +113,16 @@ export default
scope.ask_skip_tags_on_launch = (data.ask_skip_tags_on_launch) ? true : false;
master.ask_skip_tags_on_launch = scope.ask_skip_tags_on_launch;
scope.job_tag_options = (data.job_tags) ? data.job_tags.split(',')
.map((i) => ({name: i, label: i, value: i})) : [];
scope.job_tags = scope.job_tag_options;
master.job_tags = scope.job_tags;
scope.skip_tag_options = (data.skip_tags) ? data.skip_tags.split(',')
.map((i) => ({name: i, label: i, value: i})) : [];
scope.skip_tags = scope.skip_tag_options;
master.skip_tags = scope.skip_tags;
scope.ask_job_type_on_launch = (data.ask_job_type_on_launch) ? true : false;
master.ask_job_type_on_launch = scope.ask_job_type_on_launch;

View File

@ -212,9 +212,10 @@ function(NotificationsList, CompletedJobsList, i18n) {
},
job_tags: {
label: i18n._('Job Tags'),
type: 'textarea',
rows: 5,
type: 'select',
multiSelect: true,
'elementClass': 'Form-textInput',
ngOptions: 'tag.label for tag in job_tag_options track by tag.value',
column: 2,
awPopOver: "<p>" + i18n._("Provide a comma separated list of tags.") + "</p>\n" +
"<p>" + i18n._("Tags are useful when you have a large playbook, and you want to run a specific part of a play or task.") + "</p>" +
@ -230,9 +231,10 @@ function(NotificationsList, CompletedJobsList, i18n) {
},
skip_tags: {
label: i18n._('Skip Tags'),
type: 'textarea',
rows: 5,
type: 'select',
multiSelect: true,
'elementClass': 'Form-textInput',
ngOptions: 'tag.label for tag in skip_tag_options track by tag.value',
column: 2,
awPopOver: "<p>" + i18n._("Provide a comma separated list of tags.") + "</p>\n" +
"<p>" + i18n._("Skip tags are useful when you have a large playbook, and you want to skip specific parts of a play or task.") + "</p>" +