mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 00:47:29 -02:30
Merge pull request #1207 from mabashian/survey-buttons-checkbox
Survey buttons and checkbox
This commit is contained in:
@@ -221,29 +221,6 @@ export default
|
|||||||
dataTitle: 'Prompt for Extra Variables',
|
dataTitle: 'Prompt for Extra Variables',
|
||||||
dataContainer: "body"
|
dataContainer: "body"
|
||||||
},
|
},
|
||||||
survey_enabled: {
|
|
||||||
label: 'Enable Survey',
|
|
||||||
type: 'checkbox',
|
|
||||||
addRequired: false,
|
|
||||||
editRequird: false,
|
|
||||||
awFeature: 'surveys',
|
|
||||||
ngChange: "surveyEnabled()",
|
|
||||||
ngHide: "job_type.value === 'scan'",
|
|
||||||
column: 2,
|
|
||||||
awPopOver: "<p>If checked, user will be prompted at job launch with a series of questions related to the job.</p>",
|
|
||||||
dataPlacement: 'right',
|
|
||||||
dataTitle: 'Enable Survey',
|
|
||||||
dataContainer: "body"
|
|
||||||
},
|
|
||||||
create_survey: {
|
|
||||||
type: 'custom',
|
|
||||||
column: 2,
|
|
||||||
ngHide: "job_type.value === 'scan'" ,
|
|
||||||
control: '<button type="button" class="btn btn-sm btn-primary" id="job_templates_create_survey_btn" ng-show="survey_enabled" ng-click="addSurvey()"><i class="fa fa-pencil"></i> Create Survey</button>'+
|
|
||||||
'<button style="display:none;" type="button" class="btn btn-sm btn-primary" id="job_templates_edit_survey_btn" ng-show="survey_enabled" ng-click="editSurvey()"><i class="fa fa-pencil"></i> Edit Survey</button>'+
|
|
||||||
'<button style="display:none;margin-left:5px" type="button" class="btn btn-sm btn-primary" id="job_templates_delete_survey_btn" ng-show="survey_enabled" ng-click="deleteSurvey()"><i class="fa fa-trash-o"></i> Delete Survey</button>'+
|
|
||||||
'<div class="error ng-hide" id="job-template-survey-error" ng-show="invalid_survey">A survey is enabled but it does not exist. Create a survey or uncheck the Enable Survey box to disable the survey. </div>'
|
|
||||||
},
|
|
||||||
become_enabled: {
|
become_enabled: {
|
||||||
label: 'Enable Privilege Escalation',
|
label: 'Enable Privilege Escalation',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
@@ -294,6 +271,13 @@ export default
|
|||||||
dataPlacement: 'right',
|
dataPlacement: 'right',
|
||||||
dataTitle: "Host Config Key",
|
dataTitle: "Host Config Key",
|
||||||
dataContainer: "body"
|
dataContainer: "body"
|
||||||
|
},
|
||||||
|
survey: {
|
||||||
|
type: 'custom',
|
||||||
|
column: 2,
|
||||||
|
ngHide: "job_type.value === 'scan'" ,
|
||||||
|
control: '<button type="button" class="btn btn-sm Form-buttonDefault" id="job_templates_create_survey_btn" ng-show="!survey_exists" ng-click="addSurvey()">ADD SURVEY</button>'+
|
||||||
|
'<button type="button" class="btn btn-sm Form-buttonDefault" id="job_templates_edit_survey_btn" ng-show="survey_exists" ng-click="editSurvey()">EDIT SURVEY</button>'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', listGenerator.name,
|
|||||||
minWidth: 400,
|
minWidth: 400,
|
||||||
title: 'Host Properties',
|
title: 'Host Properties',
|
||||||
id: 'host-modal-dialog',
|
id: 'host-modal-dialog',
|
||||||
clonseOnEscape: false,
|
closeOnEscape: false,
|
||||||
form: form_scope.host_form,
|
form: form_scope.host_form,
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|||||||
@@ -92,17 +92,7 @@ angular.module('JobTemplatesHelper', ['Utilities'])
|
|||||||
} else {
|
} else {
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
if(fld ==='survey_enabled'){
|
if(fld ==='survey_enabled'){
|
||||||
// $scope.$emit('EnableSurvey', fld);
|
if(!Empty(data.summary_fields.survey)) {
|
||||||
$('#job_templates_survey_enabled_chbox').attr('checked', scope[fld]);
|
|
||||||
if(Empty(data.summary_fields.survey)) {
|
|
||||||
$('#job_templates_delete_survey_btn').hide();
|
|
||||||
$('#job_templates_edit_survey_btn').hide();
|
|
||||||
$('#job_templates_create_survey_btn').show();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$('#job_templates_delete_survey_btn').show();
|
|
||||||
$('#job_templates_edit_survey_btn').show();
|
|
||||||
$('#job_templates_create_survey_btn').hide();
|
|
||||||
scope.survey_exists = true;
|
scope.survey_exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export default
|
|||||||
minWidth: 400,
|
minWidth: 400,
|
||||||
title: 'Inventory Properties',
|
title: 'Inventory Properties',
|
||||||
id: 'inventory-edit-modal-dialog',
|
id: 'inventory-edit-modal-dialog',
|
||||||
clonseOnEscape: false,
|
closeOnEscape: false,
|
||||||
form: form_scope.inventory_form,
|
form: form_scope.inventory_form,
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|||||||
@@ -299,11 +299,6 @@
|
|||||||
Wait('stop');
|
Wait('stop');
|
||||||
$scope.survey_exists = true;
|
$scope.survey_exists = true;
|
||||||
$scope.invalid_survey = false;
|
$scope.invalid_survey = false;
|
||||||
$('#job_templates_survey_enabled_chbox').attr('checked', true);
|
|
||||||
$('#job_templates_delete_survey_btn').show();
|
|
||||||
$('#job_templates_edit_survey_btn').show();
|
|
||||||
$('#job_templates_create_survey_btn').hide();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -316,16 +316,8 @@ export default
|
|||||||
Rest.setUrl(defaultUrl + id+ '/survey_spec/');
|
Rest.setUrl(defaultUrl + id+ '/survey_spec/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
if(!data || !data.name){
|
if(data && data.name){
|
||||||
$('#job_templates_delete_survey_btn').hide();
|
|
||||||
$('#job_templates_edit_survey_btn').hide();
|
|
||||||
$('#job_templates_create_survey_btn').show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scope.survey_exists = true;
|
$scope.survey_exists = true;
|
||||||
$('#job_templates_delete_survey_btn').show();
|
|
||||||
$('#job_templates_edit_survey_btn').show();
|
|
||||||
$('#job_templates_create_survey_btn').hide();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
@@ -343,11 +335,6 @@ export default
|
|||||||
Wait('stop');
|
Wait('stop');
|
||||||
$scope.survey_exists = true;
|
$scope.survey_exists = true;
|
||||||
$scope.invalid_survey = false;
|
$scope.invalid_survey = false;
|
||||||
$('#job_templates_survey_enabled_chbox').attr('checked', true);
|
|
||||||
$('#job_templates_delete_survey_btn').show();
|
|
||||||
$('#job_templates_edit_survey_btn').show();
|
|
||||||
$('#job_templates_create_survey_btn').hide();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($scope.removeLoadJobs) {
|
if ($scope.removeLoadJobs) {
|
||||||
@@ -564,33 +551,5 @@ export default
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// handler for 'Enable Survey' button
|
|
||||||
$scope.surveyEnabled = function(){
|
|
||||||
Rest.setUrl(defaultUrl + id+ '/');
|
|
||||||
Rest.patch({"survey_enabled": $scope.survey_enabled})
|
|
||||||
.success(function (data) {
|
|
||||||
|
|
||||||
if(Empty(data.summary_fields.survey)){
|
|
||||||
$('#job_templates_delete_survey_btn').hide();
|
|
||||||
$('#job_templates_edit_survey_btn').hide();
|
|
||||||
$('#job_templates_create_survey_btn').show();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$scope.survey_exists = true;
|
|
||||||
$('#job_templates_delete_survey_btn').show();
|
|
||||||
$('#job_templates_edit_survey_btn').show();
|
|
||||||
$('#job_templates_create_survey_btn').hide();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors($scope, data, status, form, {
|
|
||||||
hdr: 'Error!',
|
|
||||||
msg: 'Failed to retrieve save survey_enabled: ' + $stateParams.template_id + '. GET status: ' + status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user