mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 18:50:04 -03:30
Remove scan jobs logic from job template form
This commit is contained in:
@@ -55,15 +55,13 @@ function(NotificationsList, CompletedJobsList, i18n) {
|
|||||||
" on the selected hosts."), "<em>run</em>") + "</p> <p>" +
|
" on the selected hosts."), "<em>run</em>") + "</p> <p>" +
|
||||||
i18n.sprintf(i18n._("Setting the type to %s will not execute the playbook."), "<em>check</em>") + " " +
|
i18n.sprintf(i18n._("Setting the type to %s will not execute the playbook."), "<em>check</em>") + " " +
|
||||||
i18n.sprintf(i18n._("Instead, %s will check playbook " +
|
i18n.sprintf(i18n._("Instead, %s will check playbook " +
|
||||||
" syntax, test environment setup and report problems."), "<code>ansible</code>") + "</p> <p>" +
|
" syntax, test environment setup and report problems."), "<code>ansible</code>") + "</p> <p>",
|
||||||
i18n.sprintf(i18n._("Setting the type to %s will execute the playbook and store any " +
|
|
||||||
" scanned facts for use with Tower's System Tracking feature."), "<em>scan</em>") + "</p>",
|
|
||||||
dataTitle: i18n._('Job Type'),
|
dataTitle: i18n._('Job Type'),
|
||||||
dataPlacement: 'right',
|
dataPlacement: 'right',
|
||||||
dataContainer: "body",
|
dataContainer: "body",
|
||||||
subCheckbox: {
|
subCheckbox: {
|
||||||
variable: 'ask_job_type_on_launch',
|
variable: 'ask_job_type_on_launch',
|
||||||
ngShow: "!job_type.value || job_type.value !== 'scan'",
|
ngShow: true,
|
||||||
text: i18n._('Prompt on launch'),
|
text: i18n._('Prompt on launch'),
|
||||||
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)'
|
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)'
|
||||||
},
|
},
|
||||||
@@ -90,7 +88,7 @@ function(NotificationsList, CompletedJobsList, i18n) {
|
|||||||
subCheckbox: {
|
subCheckbox: {
|
||||||
variable: 'ask_inventory_on_launch',
|
variable: 'ask_inventory_on_launch',
|
||||||
ngChange: 'job_template_form.inventory_name.$validate()',
|
ngChange: 'job_template_form.inventory_name.$validate()',
|
||||||
ngShow: "!job_type.value || job_type.value !== 'scan'",
|
ngShow: true,
|
||||||
text: i18n._('Prompt on launch')
|
text: i18n._('Prompt on launch')
|
||||||
},
|
},
|
||||||
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)'
|
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)'
|
||||||
@@ -100,7 +98,6 @@ function(NotificationsList, CompletedJobsList, i18n) {
|
|||||||
labelAction: {
|
labelAction: {
|
||||||
label: i18n._('RESET'),
|
label: i18n._('RESET'),
|
||||||
ngClick: 'resetProjectToDefault()',
|
ngClick: 'resetProjectToDefault()',
|
||||||
'class': "{{!(job_type.value === 'scan' && project_name !== 'Default') ? 'hidden' : ''}}",
|
|
||||||
},
|
},
|
||||||
type: 'lookup',
|
type: 'lookup',
|
||||||
list: 'ProjectList',
|
list: 'ProjectList',
|
||||||
@@ -122,7 +119,7 @@ function(NotificationsList, CompletedJobsList, i18n) {
|
|||||||
label: i18n._('Playbook'),
|
label: i18n._('Playbook'),
|
||||||
type:'select',
|
type:'select',
|
||||||
ngOptions: 'book for book in playbook_options track by book',
|
ngOptions: 'book for book in playbook_options track by book',
|
||||||
ngDisabled: "(job_type.value === 'scan' && project_name === 'Default') || !(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate) || disablePlaybookBecausePermissionDenied",
|
ngDisabled: "!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate) || disablePlaybookBecausePermissionDenied",
|
||||||
id: 'playbook-select',
|
id: 'playbook-select',
|
||||||
awRequiredWhen: {
|
awRequiredWhen: {
|
||||||
reqExpression: "playbookrequired",
|
reqExpression: "playbookrequired",
|
||||||
@@ -477,13 +474,13 @@ function(NotificationsList, CompletedJobsList, i18n) {
|
|||||||
view_survey: {
|
view_survey: {
|
||||||
ngClick: 'editSurvey()',
|
ngClick: 'editSurvey()',
|
||||||
awFeature: 'surveys',
|
awFeature: 'surveys',
|
||||||
ngShow: '($state.is(\'templates.addJobTemplate\') || $state.is(\'templates.editJobTemplate\')) && job_type.value !== "scan" && survey_exists && !(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
ngShow: '($state.is(\'templates.addJobTemplate\') || $state.is(\'templates.editJobTemplate\')) && survey_exists && !(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
||||||
label: i18n._('View Survey'),
|
label: i18n._('View Survey'),
|
||||||
class: 'Form-primaryButton'
|
class: 'Form-primaryButton'
|
||||||
},
|
},
|
||||||
add_survey: {
|
add_survey: {
|
||||||
ngClick: 'addSurvey()',
|
ngClick: 'addSurvey()',
|
||||||
ngShow: '($state.is(\'templates.addJobTemplate\') || $state.is(\'templates.editJobTemplate\')) && job_type.value !== "scan" && !survey_exists && (job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
ngShow: '($state.is(\'templates.addJobTemplate\') || $state.is(\'templates.editJobTemplate\')) && !survey_exists && (job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
||||||
awFeature: 'surveys',
|
awFeature: 'surveys',
|
||||||
awToolTip: '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.',
|
awToolTip: '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.',
|
||||||
dataPlacement: 'top',
|
dataPlacement: 'top',
|
||||||
@@ -493,7 +490,7 @@ function(NotificationsList, CompletedJobsList, i18n) {
|
|||||||
edit_survey: {
|
edit_survey: {
|
||||||
ngClick: 'editSurvey()',
|
ngClick: 'editSurvey()',
|
||||||
awFeature: 'surveys',
|
awFeature: 'surveys',
|
||||||
ngShow: '($state.is(\'templates.addJobTemplate\') || $state.is(\'templates.editJobTemplate\')) && job_type.value !== "scan" && survey_exists && (job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
ngShow: '($state.is(\'templates.addJobTemplate\') || $state.is(\'templates.editJobTemplate\')) && survey_exists && (job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
||||||
label: i18n._('Edit Survey'),
|
label: i18n._('Edit Survey'),
|
||||||
class: 'Form-primaryButton'
|
class: 'Form-primaryButton'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,24 +80,6 @@
|
|||||||
}
|
}
|
||||||
$scope.job_type = $scope.job_type_options[form.fields.job_type.default];
|
$scope.job_type = $scope.job_type_options[form.fields.job_type.default];
|
||||||
|
|
||||||
// if you're getting to the form from the scan job section on inventories,
|
|
||||||
// set the job type select to be scan
|
|
||||||
if ($stateParams.inventory_id) {
|
|
||||||
// This means that the job template form was accessed via inventory prop's
|
|
||||||
// This also means the job is a scan job.
|
|
||||||
$scope.job_type.value = 'scan';
|
|
||||||
$scope.jobTypeChange();
|
|
||||||
$scope.inventory = $stateParams.inventory_id;
|
|
||||||
Rest.setUrl(GetBasePath('inventory') + $stateParams.inventory_id + '/');
|
|
||||||
Rest.get()
|
|
||||||
.success(function (data) {
|
|
||||||
$scope.inventory_name = data.name;
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to lookup inventory: ' + data.id + '. GET returned status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
CreateSelect2({
|
CreateSelect2({
|
||||||
element:'#job_template_job_type',
|
element:'#job_template_job_type',
|
||||||
multiple: false
|
multiple: false
|
||||||
@@ -162,13 +144,7 @@
|
|||||||
// Update playbook select whenever project value changes
|
// Update playbook select whenever project value changes
|
||||||
selectPlaybook = function (oldValue, newValue) {
|
selectPlaybook = function (oldValue, newValue) {
|
||||||
var url;
|
var url;
|
||||||
if($scope.job_type.value === 'scan' && $scope.project_name === "Default"){
|
if (oldValue !== newValue) {
|
||||||
$scope.playbook_options = ['Default'];
|
|
||||||
$scope.playbook = 'Default';
|
|
||||||
sync_playbook_select2();
|
|
||||||
Wait('stop');
|
|
||||||
}
|
|
||||||
else if (oldValue !== newValue) {
|
|
||||||
if ($scope.project) {
|
if ($scope.project) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
url = GetBasePath('projects') + $scope.project + '/playbooks/';
|
url = GetBasePath('projects') + $scope.project + '/playbooks/';
|
||||||
@@ -191,29 +167,12 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let last_non_scan_project_name = null;
|
|
||||||
let last_non_scan_playbook = "";
|
|
||||||
let last_non_scan_playbook_options = [];
|
|
||||||
$scope.jobTypeChange = function() {
|
$scope.jobTypeChange = function() {
|
||||||
if ($scope.job_type) {
|
if ($scope.job_type && $scope.project_name === "Default") {
|
||||||
if ($scope.job_type.value === 'scan') {
|
$scope.project_name = null;
|
||||||
if ($scope.project_name !== "Default") {
|
$scope.playbook_options = [];
|
||||||
last_non_scan_project_name = $scope.project_name;
|
$scope.playbook = "";
|
||||||
last_non_scan_playbook = $scope.playbook;
|
$scope.job_template_form.playbook.$setPristine();
|
||||||
last_non_scan_playbook_options = $scope.playbook_options;
|
|
||||||
}
|
|
||||||
// If the job_type is 'scan' then we don't want the user to be
|
|
||||||
// able to prompt for job type or inventory
|
|
||||||
$scope.ask_job_type_on_launch = false;
|
|
||||||
$scope.ask_inventory_on_launch = false;
|
|
||||||
$scope.resetProjectToDefault();
|
|
||||||
}
|
|
||||||
else if ($scope.project_name === "Default") {
|
|
||||||
$scope.project_name = last_non_scan_project_name;
|
|
||||||
$scope.playbook_options = last_non_scan_playbook_options;
|
|
||||||
$scope.playbook = last_non_scan_playbook;
|
|
||||||
$scope.job_template_form.playbook.$setPristine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sync_playbook_select2();
|
sync_playbook_select2();
|
||||||
};
|
};
|
||||||
@@ -402,14 +361,9 @@
|
|||||||
var fld, data = {};
|
var fld, data = {};
|
||||||
$scope.invalid_survey = false;
|
$scope.invalid_survey = false;
|
||||||
|
|
||||||
// users can't save a survey with a scan job
|
|
||||||
if($scope.job_type.value === "scan" &&
|
|
||||||
$scope.survey_enabled === true){
|
|
||||||
$scope.survey_enabled = false;
|
|
||||||
}
|
|
||||||
// Can't have a survey enabled without a survey
|
// Can't have a survey enabled without a survey
|
||||||
if($scope.survey_enabled === true &&
|
if($scope.survey_enabled === true &&
|
||||||
$scope.survey_exists!==true){
|
$scope.survey_exists !== true){
|
||||||
$scope.survey_enabled = false;
|
$scope.survey_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,11 +401,7 @@
|
|||||||
|
|
||||||
data.extra_vars = ToJSON($scope.parseType,
|
data.extra_vars = ToJSON($scope.parseType,
|
||||||
$scope.variables, true);
|
$scope.variables, true);
|
||||||
if(data.job_type === 'scan' &&
|
|
||||||
$scope.default_scan === true){
|
|
||||||
data.project = "";
|
|
||||||
data.playbook = "";
|
|
||||||
}
|
|
||||||
// We only want to set the survey_enabled flag to
|
// We only want to set the survey_enabled flag to
|
||||||
// true for this job template if a survey exists
|
// true for this job template if a survey exists
|
||||||
// and it's been enabled. By default,
|
// and it's been enabled. By default,
|
||||||
|
|||||||
@@ -86,13 +86,7 @@ export default
|
|||||||
$scope.playbook_options = [$scope.playbook];
|
$scope.playbook_options = [$scope.playbook];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($scope.job_type.value === 'scan' && $scope.project_name === "Default"){
|
if (!Empty(project)) {
|
||||||
$scope.playbook_options = ['Default'];
|
|
||||||
$scope.playbook = 'Default';
|
|
||||||
sync_playbook_select2();
|
|
||||||
Wait('stop');
|
|
||||||
}
|
|
||||||
else if (!Empty(project)) {
|
|
||||||
url = GetBasePath('projects') + project + '/playbooks/';
|
url = GetBasePath('projects') + project + '/playbooks/';
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
@@ -132,29 +126,12 @@ export default
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let last_non_scan_project_name = null;
|
|
||||||
let last_non_scan_playbook = "";
|
|
||||||
let last_non_scan_playbook_options = [];
|
|
||||||
$scope.jobTypeChange = function() {
|
$scope.jobTypeChange = function() {
|
||||||
if ($scope.job_type) {
|
if ($scope.job_type && $scope.project_name === "Default") {
|
||||||
if ($scope.job_type.value === 'scan') {
|
$scope.project_name = null;
|
||||||
if ($scope.project_name !== "Default") {
|
$scope.playbook_options = [];
|
||||||
last_non_scan_project_name = $scope.project_name;
|
$scope.playbook = "";
|
||||||
last_non_scan_playbook = $scope.playbook;
|
$scope.job_template_form.playbook.$setPristine();
|
||||||
last_non_scan_playbook_options = $scope.playbook_options;
|
|
||||||
}
|
|
||||||
// If the job_type is 'scan' then we don't want the user to be
|
|
||||||
// able to prompt for job type or inventory
|
|
||||||
$scope.ask_job_type_on_launch = false;
|
|
||||||
$scope.ask_inventory_on_launch = false;
|
|
||||||
$scope.resetProjectToDefault();
|
|
||||||
}
|
|
||||||
else if ($scope.project_name === "Default") {
|
|
||||||
$scope.project_name = last_non_scan_project_name;
|
|
||||||
$scope.playbook_options = last_non_scan_playbook_options;
|
|
||||||
$scope.playbook = last_non_scan_playbook;
|
|
||||||
$scope.job_template_form.playbook.$setPristine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sync_playbook_select2();
|
sync_playbook_select2();
|
||||||
};
|
};
|
||||||
@@ -529,12 +506,7 @@ export default
|
|||||||
$scope.formSave = function () {
|
$scope.formSave = function () {
|
||||||
var fld, data = {};
|
var fld, data = {};
|
||||||
$scope.invalid_survey = false;
|
$scope.invalid_survey = false;
|
||||||
|
|
||||||
// users can't save a survey with a scan job
|
|
||||||
if($scope.job_type.value === "scan" &&
|
|
||||||
$scope.survey_enabled === true){
|
|
||||||
$scope.survey_enabled = false;
|
|
||||||
}
|
|
||||||
// Can't have a survey enabled without a survey
|
// Can't have a survey enabled without a survey
|
||||||
if($scope.survey_enabled === true &&
|
if($scope.survey_enabled === true &&
|
||||||
$scope.survey_exists!==true){
|
$scope.survey_exists!==true){
|
||||||
@@ -575,11 +547,7 @@ export default
|
|||||||
|
|
||||||
data.extra_vars = ToJSON($scope.parseType,
|
data.extra_vars = ToJSON($scope.parseType,
|
||||||
$scope.variables, true);
|
$scope.variables, true);
|
||||||
if(data.job_type === 'scan' &&
|
|
||||||
$scope.default_scan === true){
|
|
||||||
data.project = "";
|
|
||||||
data.playbook = "";
|
|
||||||
}
|
|
||||||
// We only want to set the survey_enabled flag to
|
// We only want to set the survey_enabled flag to
|
||||||
// true for this job template if a survey exists
|
// true for this job template if a survey exists
|
||||||
// and it's been enabled. By default,
|
// and it's been enabled. By default,
|
||||||
|
|||||||
Reference in New Issue
Block a user