mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
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:
parent
c930b7759a
commit
22b44ceb32
@ -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()
|
||||
|
||||
@ -267,7 +267,7 @@
|
||||
</div>
|
||||
<div id="prompt-for-days" style="display:none">
|
||||
<form name="prompt_for_days_form" id="prompt_for_days_form">
|
||||
How many days of data would you like to <b>keep</b>? <br>
|
||||
How many days of recent data do you need to access? <br>
|
||||
<input type="number" id="days_to_keep" name="days_to_keep" ng-model="days_to_keep" ng-required="true" class="form-control" aw-min=0 aw-max=9999 style="margin-top:10px;" integer></input>
|
||||
<div class="error" ng-show="prompt_for_days_form.days_to_keep.$dirty && prompt_for_days_form.days_to_keep.$error.required">Please enter the number of days you would like to keep this data.</div>
|
||||
<div class="error survey_error" ng-show="prompt_for_days_form.days_to_keep.$error.number || prompt_for_days_form.days_to_keep.$error.integer" >Please enter a valid number.</div>
|
||||
@ -275,6 +275,51 @@
|
||||
<div class="error survey_error" ng-show="prompt_for_days_form.days_to_keep.$error.awMax">Please enter a number smaller than 9999.</div>
|
||||
</form>
|
||||
</div>
|
||||
<div id="prompt-for-days-facts" style="display:none">
|
||||
<form name="prompt_for_days_facts_form" id="prompt_for_days_facts_form">
|
||||
<div style="padding-bottom:15px;">For each host older than the value specified, keep one fact scan for each time window (granularity). For example,
|
||||
facts older than 30 days will be removed, while one fact gathering per week will remain. <br></div>
|
||||
<div class="form-group ">
|
||||
<label for="description">
|
||||
<span class="label-text">
|
||||
Facts older than specified shall be deleted
|
||||
</span>
|
||||
</label>
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<input type="number" id="keep_amount" name="keep_amount" ng-model="keep_amount" ng-required="true" class="form-control" aw-min=0 aw-max=9999 style="margin-top:10px;" integer></input>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<select id="keep_unit" name="keep_unit" ng-model="keep_unit" ng-options="type.label for type in keep_unit_choices track by type.value" ng-required="true" class="form-control" style="margin-top:10px;"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="error" ng-show="prompt_for_days_facts_form.keep_amount.$dirty && prompt_for_days_facts_form.keep_amount.$error.required">Please enter the number of days you would like to keep this data.</div>
|
||||
<div class="error survey_error" ng-show="prompt_for_days_facts_form.keep_amount.$error.number || prompt_for_days_facts_form.keep_amount.$error.integer" >Please enter a valid number.</div>
|
||||
<div class="error survey_error" ng-show="prompt_for_days_facts_form.keep_amount.$error.awMin">Please enter a non-negative number.</div>
|
||||
<div class="error survey_error" ng-show="prompt_for_days_facts_form.keep_amount.$error.awMax">Please enter a number smaller than 9999.</div>
|
||||
</div>
|
||||
<div class="form-group ">
|
||||
<label for="description">
|
||||
<span class="label-text">
|
||||
Granularity of facts to keep
|
||||
</span>
|
||||
</label>
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<input type="number" id="granularity_keep_amount" name="granularity_keep_amount" ng-model="granularity_keep_amount" ng-required="true" class="form-control" aw-min=0 aw-max=9999 style="margin-top:10px;" integer></input>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<select id="granularity_keep_unit" name="granularity_keep_unit" ng-model="granularity_keep_unit" ng-options="type.label for type in granularity_keep_unit_choices track by type.value" ng-required="true" class="form-control" style="margin-top:10px;"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="error" ng-show="prompt_for_days_facts_form.granularity_keep_amount.$dirty && prompt_for_days_facts_form.granularity_keep_amount.$error.required">Please enter the number of days you would like to keep this data.</div>
|
||||
<div class="error survey_error" ng-show="prompt_for_days_facts_form.granularity_keep_amount.$error.number || prompt_for_days_facts_form.granularity_keep_amount.$error.integer" >Please enter a valid number.</div>
|
||||
<div class="error survey_error" ng-show="prompt_for_days_facts_form.granularity_keep_amount.$error.awMin">Please enter a non-negative number.</div>
|
||||
<div class="error survey_error" ng-show="prompt_for_days_facts_form.granularity_keep_amount.$error.awMax">Please enter a number smaller than 9999.</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
],
|
||||
"watch": [
|
||||
"awx/ui/static",
|
||||
"awx/ui/tests"
|
||||
"awx/ui/tests",
|
||||
"awx/ui/templates/ui/index.html"
|
||||
],
|
||||
"ext": "js json less html"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user