mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-15 15:58:38 -05:00
Adding cleanup_fact prompt
The cleanup_fact job requires a different set of parameters: older_than and granularity. A different prompt modal was required in order to reflect these extra parameters.
This commit is contained in:
@@ -137,35 +137,74 @@ export default
|
||||
}
|
||||
};
|
||||
|
||||
scope.submitJob = function (id, name) {
|
||||
Wait('start');
|
||||
scope.submitCleanupJob = function(id, name){
|
||||
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
|
||||
CreateDialog({
|
||||
id: 'prompt-for-days' ,
|
||||
id: 'prompt-for-days-facts',
|
||||
title: name,
|
||||
scope: scope,
|
||||
width: 500,
|
||||
height: 300,
|
||||
height: 470,
|
||||
minWidth: 200,
|
||||
callback: 'PromptForDays',
|
||||
callback: 'PromptForDaysFacts',
|
||||
onOpen: function(){
|
||||
e = angular.element(document.getElementById('prompt_for_days_form'));
|
||||
scope.prompt_for_days_form.days_to_keep.$setViewValue(30);
|
||||
scope.keep_unit_choices = [{
|
||||
"label" : "Days",
|
||||
"value" : "d"
|
||||
},
|
||||
{
|
||||
"label": "Weeks",
|
||||
"value" : "w"
|
||||
},
|
||||
{
|
||||
"label" : "Years",
|
||||
"value" : "y"
|
||||
}];
|
||||
scope.granularity_keep_unit_choices = [{
|
||||
"label" : "Days",
|
||||
"value" : "d"
|
||||
},
|
||||
{
|
||||
"label": "Weeks",
|
||||
"value" : "w"
|
||||
},
|
||||
{
|
||||
"label" : "Years",
|
||||
"value" : "y"
|
||||
}];
|
||||
e = angular.element(document.getElementById('prompt_for_days_facts_form'));
|
||||
scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30);
|
||||
scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1);
|
||||
$compile(e)(scope);
|
||||
scope.keep_unit = scope.keep_unit_choices[0];
|
||||
scope.granularity_keep_unit = scope.granularity_keep_unit_choices[1];
|
||||
|
||||
// this is a work-around for getting awMax to work (without
|
||||
// clearing out the form)
|
||||
scope.$watch('days_to_keep', function(newVal) { // oldVal, scope) { // unused params get caught by jshint
|
||||
scope.$watch('keep_amount', function(newVal) {
|
||||
if (!newVal && newVal !== 0) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else if (isNaN(newVal)) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else if (newVal < 0) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else if (newVal > 9999) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else {
|
||||
$('#prompt-for-days-launch').prop("disabled", false);
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", false);
|
||||
}
|
||||
});
|
||||
scope.$watch('granularity_keep_amount', function(newVal2) {
|
||||
if (!newVal2 && newVal2 !== 0) {
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else if (isNaN(newVal2)) {
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else if (newVal2 < 0) {
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else if (newVal2 > 9999) {
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||
} else {
|
||||
$('#prompt-for-days-facts-launch').prop("disabled", false);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -177,11 +216,14 @@ export default
|
||||
},
|
||||
"icon": "fa-times",
|
||||
"class": "btn btn-default",
|
||||
"id": "prompt-for-days-cancel"
|
||||
"id": "prompt-for-days-facts-cancel"
|
||||
},{
|
||||
"label": "Launch",
|
||||
"onClick": function() {
|
||||
var extra_vars = {"days": scope.days_to_keep },
|
||||
var extra_vars = {
|
||||
"older_than": scope.keep_amount+scope.keep_unit.value,
|
||||
"granularity": scope.granularity_keep_amount+scope.granularity_keep_unit.value
|
||||
},
|
||||
data = {};
|
||||
data.extra_vars = JSON.stringify(extra_vars);
|
||||
|
||||
@@ -189,7 +231,7 @@ export default
|
||||
Rest.post(data)
|
||||
.success(function() {
|
||||
Wait('stop');
|
||||
$("#prompt-for-days").dialog("close");
|
||||
$("#prompt-for-days-facts").dialog("close");
|
||||
$("#configure-tower-dialog").dialog('close');
|
||||
$location.path('/jobs/');
|
||||
})
|
||||
@@ -200,21 +242,104 @@ export default
|
||||
},
|
||||
"icon": "fa-rocket",
|
||||
"class": "btn btn-primary",
|
||||
"id": "prompt-for-days-launch"
|
||||
"id": "prompt-for-days-facts-launch"
|
||||
}]
|
||||
});
|
||||
|
||||
if (scope.removePromptForDays) {
|
||||
scope.removePromptForDays();
|
||||
}
|
||||
scope.removePromptForDays = scope.$on('PromptForDays', function() {
|
||||
scope.removePromptForDays = scope.$on('PromptForDaysFacts', function() {
|
||||
// $('#configure-tower-dialog').dialog('close');
|
||||
$('#prompt-for-days').show();
|
||||
$('#prompt-for-days').dialog('open');
|
||||
$('#prompt-for-days-facts').show();
|
||||
$('#prompt-for-days-facts').dialog('open');
|
||||
Wait('stop');
|
||||
});
|
||||
};
|
||||
|
||||
scope.submitJob = function (id, name) {
|
||||
Wait('start');
|
||||
if(this.configure_job.job_type === "cleanup_facts"){
|
||||
scope.submitCleanupJob(id, name);
|
||||
}
|
||||
else {
|
||||
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
|
||||
CreateDialog({
|
||||
id: 'prompt-for-days' ,
|
||||
title: name,
|
||||
scope: scope,
|
||||
width: 500,
|
||||
height: 300,
|
||||
minWidth: 200,
|
||||
callback: 'PromptForDays',
|
||||
onOpen: function(){
|
||||
e = angular.element(document.getElementById('prompt_for_days_form'));
|
||||
scope.prompt_for_days_form.days_to_keep.$setViewValue(30);
|
||||
$compile(e)(scope);
|
||||
|
||||
// this is a work-around for getting awMax to work (without
|
||||
// clearing out the form)
|
||||
scope.$watch('days_to_keep', function(newVal) { // oldVal, scope) { // unused params get caught by jshint
|
||||
if (!newVal && newVal !== 0) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
} else if (isNaN(newVal)) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
} else if (newVal < 0) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
} else if (newVal > 9999) {
|
||||
$('#prompt-for-days-launch').prop("disabled", true);
|
||||
} else {
|
||||
$('#prompt-for-days-launch').prop("disabled", false);
|
||||
}
|
||||
});
|
||||
},
|
||||
buttons: [{
|
||||
"label": "Cancel",
|
||||
"onClick": function() {
|
||||
$(this).dialog('close');
|
||||
|
||||
},
|
||||
"icon": "fa-times",
|
||||
"class": "btn btn-default",
|
||||
"id": "prompt-for-days-cancel"
|
||||
},{
|
||||
"label": "Launch",
|
||||
"onClick": function() {
|
||||
var extra_vars = {"days": scope.days_to_keep },
|
||||
data = {};
|
||||
data.extra_vars = JSON.stringify(extra_vars);
|
||||
|
||||
Rest.setUrl(defaultUrl);
|
||||
Rest.post(data)
|
||||
.success(function() {
|
||||
Wait('stop');
|
||||
$("#prompt-for-days").dialog("close");
|
||||
$("#configure-tower-dialog").dialog('close');
|
||||
$location.path('/jobs/');
|
||||
})
|
||||
.error(function(data, status) {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Failed updating job ' + scope.job_template_id + ' with variables. POST returned: ' + status });
|
||||
});
|
||||
},
|
||||
"icon": "fa-rocket",
|
||||
"class": "btn btn-primary",
|
||||
"id": "prompt-for-days-launch"
|
||||
}]
|
||||
});
|
||||
|
||||
if (scope.removePromptForDays) {
|
||||
scope.removePromptForDays();
|
||||
}
|
||||
scope.removePromptForDays = scope.$on('PromptForDays', function() {
|
||||
// $('#configure-tower-dialog').dialog('close');
|
||||
$('#prompt-for-days').show();
|
||||
$('#prompt-for-days').dialog('open');
|
||||
Wait('stop');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
scope.configureSchedule = function(id, name) {
|
||||
Rest.setUrl(scheduleUrl+id+'/schedules/');
|
||||
Rest.get()
|
||||
|
||||
Reference in New Issue
Block a user