mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Merge pull request #2109 from anoek/858
Fixed/enhanced scan job type selection process
This commit is contained in:
commit
0948375763
@ -433,6 +433,10 @@ input[type='radio']:checked:before {
|
|||||||
outline:none;
|
outline:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Form-inputLabelContainer {
|
||||||
|
width: 100%;
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
.Form-inputLabel{
|
.Form-inputLabel{
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: @default-interface-txt;
|
color: @default-interface-txt;
|
||||||
@ -443,6 +447,16 @@ input[type='radio']:checked:before {
|
|||||||
.noselect;
|
.noselect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Form-labelAction {
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: normal;
|
||||||
|
font-size: 0.8em;
|
||||||
|
padding-left:5px;
|
||||||
|
float: right;
|
||||||
|
margin-top: 3px;
|
||||||
|
.noselect;
|
||||||
|
}
|
||||||
|
|
||||||
.Form-buttons{
|
.Form-buttons{
|
||||||
height: 30px;
|
height: 30px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -81,6 +81,11 @@ export default
|
|||||||
},
|
},
|
||||||
project: {
|
project: {
|
||||||
label: 'Project',
|
label: 'Project',
|
||||||
|
labelAction: {
|
||||||
|
label: 'RESET',
|
||||||
|
ngClick: 'resetProjectToDefault()',
|
||||||
|
'class': "{{!(job_type.value === 'scan' && project_name !== 'Default') ? 'hidden' : ''}}",
|
||||||
|
},
|
||||||
type: 'lookup',
|
type: 'lookup',
|
||||||
sourceModel: 'project',
|
sourceModel: 'project',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
@ -99,6 +104,7 @@ export default
|
|||||||
label: 'Playbook',
|
label: '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'",
|
||||||
id: 'playbook-select',
|
id: 'playbook-select',
|
||||||
awRequiredWhen: {
|
awRequiredWhen: {
|
||||||
reqExpression: "playbookrequired",
|
reqExpression: "playbookrequired",
|
||||||
@ -110,12 +116,6 @@ export default
|
|||||||
dataPlacement: 'right',
|
dataPlacement: 'right',
|
||||||
dataContainer: "body",
|
dataContainer: "body",
|
||||||
},
|
},
|
||||||
default_scan: {
|
|
||||||
type: 'custom',
|
|
||||||
column: 1,
|
|
||||||
ngShow: 'job_type.value === "scan" && project_name !== "Default"',
|
|
||||||
control: '<a href="" ng-click="toggleScanInfo()">Reset to default project and playbook</a>'
|
|
||||||
},
|
|
||||||
credential: {
|
credential: {
|
||||||
label: 'Machine Credential',
|
label: 'Machine Credential',
|
||||||
type: 'lookup',
|
type: 'lookup',
|
||||||
|
@ -177,7 +177,7 @@ angular.module('JobTemplatesHelper', ['Utilities'])
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if(scope.project === "" && scope.playbook === ""){
|
if (scope.project === "" && scope.playbook === "") {
|
||||||
scope.toggleScanInfo();
|
scope.toggleScanInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,12 +197,20 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function sync_playbook_select2() {
|
||||||
|
CreateSelect2({
|
||||||
|
element:'#playbook-select',
|
||||||
|
multiple: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 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($scope.job_type.value === 'scan' && $scope.project_name === "Default"){
|
||||||
$scope.playbook_options = ['Default'];
|
$scope.playbook_options = ['Default'];
|
||||||
$scope.playbook = 'Default';
|
$scope.playbook = 'Default';
|
||||||
|
sync_playbook_select2();
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
}
|
}
|
||||||
else if (oldValue !== newValue) {
|
else if (oldValue !== newValue) {
|
||||||
@ -217,6 +225,7 @@
|
|||||||
opts.push(data[i]);
|
opts.push(data[i]);
|
||||||
}
|
}
|
||||||
$scope.playbook_options = opts;
|
$scope.playbook_options = opts;
|
||||||
|
sync_playbook_select2();
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
@ -227,32 +236,37 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.jobTypeChange = function(){
|
let last_non_scan_project_name = null;
|
||||||
if($scope.job_type){
|
let last_non_scan_playbook = "";
|
||||||
if($scope.job_type.value === 'scan'){
|
let last_non_scan_playbook_options = [];
|
||||||
// If the job_type is 'scan' then we don't want the user to be
|
$scope.jobTypeChange = function() {
|
||||||
// able to prompt for job type or inventory
|
if ($scope.job_type) {
|
||||||
$scope.ask_job_type_on_launch = false;
|
if ($scope.job_type.value === 'scan') {
|
||||||
$scope.ask_inventory_on_launch = false;
|
if ($scope.project_name !== "Default") {
|
||||||
$scope.toggleScanInfo();
|
last_non_scan_project_name = $scope.project_name;
|
||||||
}
|
last_non_scan_playbook = $scope.playbook;
|
||||||
else if($scope.project_name === "Default"){
|
last_non_scan_playbook_options = $scope.playbook_options;
|
||||||
$scope.project_name = null;
|
}
|
||||||
$scope.playbook_options = [];
|
// If the job_type is 'scan' then we don't want the user to be
|
||||||
// $scope.playbook = 'null';
|
// able to prompt for job type or inventory
|
||||||
$scope.job_templates_form.playbook.$setPristine();
|
$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_templates_form.playbook.$setPristine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sync_playbook_select2();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggleScanInfo = function() {
|
$scope.resetProjectToDefault = function() {
|
||||||
$scope.project_name = 'Default';
|
$scope.project_name = 'Default';
|
||||||
if($scope.project === null){
|
$scope.project = null;
|
||||||
selectPlaybook();
|
selectPlaybook('force_load');
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scope.project = null;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Detect and alert user to potential SCM status issues
|
// Detect and alert user to potential SCM status issues
|
||||||
|
@ -76,6 +76,13 @@ export default
|
|||||||
$scope.playbook = null;
|
$scope.playbook = null;
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
|
function sync_playbook_select2() {
|
||||||
|
CreateSelect2({
|
||||||
|
element:'#playbook-select',
|
||||||
|
multiple: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getPlaybooks = function (project) {
|
getPlaybooks = function (project) {
|
||||||
var url;
|
var url;
|
||||||
if ($scope.playbook) {
|
if ($scope.playbook) {
|
||||||
@ -85,6 +92,7 @@ export default
|
|||||||
if($scope.job_type.value === 'scan' && $scope.project_name === "Default"){
|
if($scope.job_type.value === 'scan' && $scope.project_name === "Default"){
|
||||||
$scope.playbook_options = ['Default'];
|
$scope.playbook_options = ['Default'];
|
||||||
$scope.playbook = 'Default';
|
$scope.playbook = 'Default';
|
||||||
|
sync_playbook_select2();
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
}
|
}
|
||||||
else if (!Empty(project)) {
|
else if (!Empty(project)) {
|
||||||
@ -93,14 +101,14 @@ export default
|
|||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
var i;
|
|
||||||
$scope.playbook_options = [];
|
$scope.playbook_options = [];
|
||||||
for (i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
$scope.playbook_options.push(data[i]);
|
$scope.playbook_options.push(data[i]);
|
||||||
if (data[i] === $scope.playbook) {
|
if (data[i] === $scope.playbook) {
|
||||||
$scope.job_templates_form.playbook.$setValidity('required', true);
|
$scope.job_templates_form.playbook.$setValidity('required', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sync_playbook_select2();
|
||||||
if ($scope.playbook) {
|
if ($scope.playbook) {
|
||||||
$scope.$emit('jobTemplateLoadFinished');
|
$scope.$emit('jobTemplateLoadFinished');
|
||||||
} else {
|
} else {
|
||||||
@ -122,23 +130,31 @@ export default
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.jobTypeChange = function(){
|
let last_non_scan_project_name = null;
|
||||||
if($scope.job_type){
|
let last_non_scan_playbook = "";
|
||||||
if($scope.job_type.value === 'scan'){
|
let last_non_scan_playbook_options = [];
|
||||||
// If the job_type is 'scan' then we don't want the user to be
|
$scope.jobTypeChange = function() {
|
||||||
// able to prompt for job type or inventory
|
if ($scope.job_type) {
|
||||||
$scope.ask_job_type_on_launch = false;
|
if ($scope.job_type.value === 'scan') {
|
||||||
$scope.ask_inventory_on_launch = false;
|
if ($scope.project_name !== "Default") {
|
||||||
$scope.toggleScanInfo();
|
last_non_scan_project_name = $scope.project_name;
|
||||||
}
|
last_non_scan_playbook = $scope.playbook;
|
||||||
else if($scope.project_name === "Default"){
|
last_non_scan_playbook_options = $scope.playbook_options;
|
||||||
$scope.project_name = null;
|
}
|
||||||
$scope.playbook_options = [];
|
// If the job_type is 'scan' then we don't want the user to be
|
||||||
// $scope.playbook = 'null';
|
// able to prompt for job type or inventory
|
||||||
$scope.job_templates_form.playbook.$setPristine();
|
$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_templates_form.playbook.$setPristine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sync_playbook_select2();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggleNotification = function(event, notifier_id, column) {
|
$scope.toggleNotification = function(event, notifier_id, column) {
|
||||||
@ -159,14 +175,10 @@ export default
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggleScanInfo = function() {
|
$scope.resetProjectToDefault = function() {
|
||||||
$scope.project_name = 'Default';
|
$scope.project_name = 'Default';
|
||||||
if($scope.project === null){
|
$scope.project = null;
|
||||||
getPlaybooks();
|
getPlaybooks();
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scope.project = null;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Detect and alert user to potential SCM status issues
|
// Detect and alert user to potential SCM status issues
|
||||||
|
@ -714,13 +714,10 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
function label() {
|
function label() {
|
||||||
var html = '';
|
var html = '';
|
||||||
if (field.label || field.labelBind) {
|
if (field.label || field.labelBind) {
|
||||||
html += "<label ";
|
html += "<label class=\"";
|
||||||
if (horizontal || field.labelClass) {
|
html += (field.labelClass) ? field.labelClass : "";
|
||||||
html += "class=\"";
|
html += (horizontal) ? " " + getLabelWidth() : "Form-inputLabelContainer ";
|
||||||
html += (field.labelClass) ? field.labelClass : "";
|
html += "\" ";
|
||||||
html += (horizontal) ? " " + getLabelWidth() : "";
|
|
||||||
html += "\" ";
|
|
||||||
}
|
|
||||||
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
||||||
html += "for=\"" + fld + '">\n';
|
html += "for=\"" + fld + '">\n';
|
||||||
html += (field.icon) ? Icon(field.icon) : "";
|
html += (field.icon) ? Icon(field.icon) : "";
|
||||||
@ -742,6 +739,14 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += "\" value=\"json\" ng-change=\"parseTypeChange()\"> <span class=\"parse-label\">JSON</span>\n";
|
html += "\" value=\"json\" ng-change=\"parseTypeChange()\"> <span class=\"parse-label\">JSON</span>\n";
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field.labelAction) {
|
||||||
|
let action = field.labelAction;
|
||||||
|
let href = action.href || "";
|
||||||
|
let ngClick = action.ngClick || "";
|
||||||
|
let cls = action["class"] || "";
|
||||||
|
html += `<a class="Form-labelAction ${cls}" href="${href}" ng-click="${ngClick}">${action.label}</a>`;
|
||||||
|
}
|
||||||
html += "\n\t</label>\n";
|
html += "\n\t</label>\n";
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
|
@ -8,7 +8,6 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
|
|||||||
function ($log, $rootScope, $scope, $state, $stateParams, ProcessErrors, Rest, Wait) {
|
function ($log, $rootScope, $scope, $state, $stateParams, ProcessErrors, Rest, Wait) {
|
||||||
|
|
||||||
var api_complete = false,
|
var api_complete = false,
|
||||||
stdout_url,
|
|
||||||
current_range,
|
current_range,
|
||||||
loaded_sections = [],
|
loaded_sections = [],
|
||||||
event_queue = 0,
|
event_queue = 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user