1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

removes code/references related to cleanup_facts mgmt jobs, and their schedules

This commit is contained in:
Jared Tabor 2018-04-25 16:41:48 -07:00
parent a009d21edc
commit 5f38b4fde4
7 changed files with 18 additions and 263 deletions

View File

@ -38,121 +38,6 @@ export default
$scope.cardAction = "notifications";
}
$scope.submitCleanupJob = function(id, name){
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
CreateDialog({
id: 'prompt-for-days-facts',
title: name,
scope: $scope,
width: 500,
height: 470,
minWidth: 200,
callback: 'PromptForDaysFacts',
resizable: false,
onOpen: function(){
$scope.$watch('prompt_for_days_facts_form.$invalid', function(invalid) {
if (invalid === true) {
$('#prompt-for-days-facts-launch').prop("disabled", true);
} else {
$('#prompt-for-days-facts-launch').prop("disabled", false);
}
});
var fieldScope = $scope.$parent;
// set these form elements up on the $scope where the form
// is the parent of the current $scope
fieldScope.keep_unit_choices = [{
"label" : "Days",
"value" : "d"
},
{
"label": "Weeks",
"value" : "w"
},
{
"label" : "Years",
"value" : "y"
}];
fieldScope.granularity_keep_unit_choices = [{
"label" : "Days",
"value" : "d"
},
{
"label": "Weeks",
"value" : "w"
},
{
"label" : "Years",
"value" : "y"
}];
$scope.prompt_for_days_facts_form.$setPristine();
$scope.prompt_for_days_facts_form.$invalid = false;
fieldScope.keep_unit = fieldScope.keep_unit_choices[0];
fieldScope.granularity_keep_unit = fieldScope.granularity_keep_unit_choices[1];
fieldScope.keep_amount = 30;
fieldScope.granularity_keep_amount = 1;
},
buttons: [
{
"label": "Cancel",
"onClick": function() {
$(this).dialog('close');
},
"class": "btn btn-default",
"id": "prompt-for-days-facts-cancel"
},
{
"label": "Launch",
"onClick": function() {
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);
Rest.setUrl(defaultUrl);
Rest.post(data)
.then(({data}) => {
Wait('stop');
$("#prompt-for-days-facts").dialog("close");
$("#configure-dialog").dialog('close');
$state.go('jobz', { id: data.system_job, type: 'system' }, { reload: true });
})
.catch(({data, status}) => {
let template_id = $scope.job_template_id;
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
msg: i18n.sprintf(i18n._('Failed updating job %s with variables. POST returned: %d'), template_id, status) });
});
},
"class": "btn btn-primary",
"id": "prompt-for-days-facts-launch",
}
]
});
if ($scope.removePromptForDays) {
$scope.removePromptForDays();
}
$scope.removePromptForDays = $scope.$on('PromptForDaysFacts', function() {
// $('#configure-dialog').dialog('close');
$('#prompt-for-days-facts').show();
$('#prompt-for-days-facts').dialog('open');
CreateSelect2({
element: '#keep_unit',
multiple: false
});
CreateSelect2({
element: '#granularity_keep_unit',
multiple: false
});
Wait('stop');
});
};
$scope.goToNotifications = function(card){
$state.transitionTo('managementJobsList.notifications',{
card: card,
@ -235,15 +120,6 @@ export default
});
};
$scope.chooseRunJob = function(id, name) {
if(this.card.job_type === "cleanup_facts") {
// Run only for 'Cleanup Fact Details'
$scope.submitCleanupJob(id, name);
} else {
$scope.submitJob(id, name);
}
};
$scope.configureSchedule = function(id) {
$state.transitionTo('managementJobsList.schedule', {
id: id

View File

@ -18,7 +18,7 @@
<h3 class="MgmtCards-label"> {{ card.name }}</h3>
<div class="MgmtCards-actionItems">
<button class="MgmtCards-actionItem List-actionButton"
ng-click='chooseRunJob(card.id, card.name)'
ng-click='submitJob(card.id, card.name)'
ng-show='current_user.is_superuser'
data-placement="top" aw-tool-tip="{{'Launch Management Job'|translate}}" data-original-title="" title="">
<i class="MgmtCards-actionItemIcon icon-launch"></i>
@ -42,4 +42,4 @@
<!-- End Card Body -->
</div>
</div>
</div>
</div>

View File

@ -1,7 +1,6 @@
.MgmtCards {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
.MgmtCards-card {
@ -11,6 +10,7 @@
border: 1px solid @b7grey;
align-items: baseline;
margin-top: 20px;
margin-right: 20px;
width: 32%;
}

View File

@ -161,7 +161,7 @@
ng-show="sheduler_frequency_error">
</div>
</div>
<div class="form-group SchedulerForm-formGroup" ng-if="cleanupJob && !isFactCleanup">
<div class="form-group SchedulerForm-formGroup" ng-if="cleanupJob">
<label class="Form-inputLabel"><span class="red-text">*</span> Days of data to keep</label>
<input type="number" sch-spinner="scheduler_form" class="scheduler-time-spinner SchedulerTime-input SpinnerInput RepeatFrequencyOptions-number" name="schedulerPurgeDays" id="schedulerPurgeDays" min="1" aw-spinner="schedulerPurgeDays" ng-model="schedulerPurgeDays" required placeholder="Days of data to keep" ng-disabled="!(schedule_obj.summary_fields.user_capabilities.edit || canAdd)">
<div class="error" ng-show="scheduler_form.schedulerPurgeDays.$dirty && scheduler_form.schedulerPurgeDays.$error.required" translate>A value is required.</div>
@ -521,44 +521,6 @@
<div class="RepeatFrequencyOptions-subFormBorderFixer"
ng-show="schedulerFrequency.value && schedulerFrequency.value !== 'none'">
</div>
<!-- start management job fields -->
<div class="factDetailsNote" ng-if="isFactCleanup">
<span class="factDetailsHeader">Note:</span> For facts collected older than the time period specified, save one fact scan (snapshot) per time window (frequency). For example, facts older than 30 days are purged, while one weekly fact scan is kept.
Caution: Setting both numerical variables to "0" will delete all facts.</div>
<div class="form-group SchedulerForm-formGroup" ng-if="isFactCleanup">
<label class="Form-inputLabel RepeatFrequencyOptions-everyLabel"><span class="red-text">*</span> Select a time period after which to remove old facts</label>
<div class="RepeatFrequencyOptions-inputGroup RepeatFrequencyOptions-inputGroup--halvesWithSelect">
<input id="keep_amount" name="keep_amount" ng-model="keep_amount" aw-spinner="keep_amount" ng-required="true" sch-spinner="scheduler_form" class="scheduler-time-spinner SchedulerTime-input SpinnerInput RepeatFrequencyOptions-number" min="0" aw-min="0" max="9999" aw-max="9999" ng-disabled="!(schedule_obj.summary_fields.user_capabilities.edit || canAdd)" integer required></input>
<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 input-sm MakeSelect2" ng-disabled="!(schedule_obj.summary_fields.user_capabilities.edit || canAdd)"></select>
</div>
<!-- The below errors are ONLY for id="keep_amount", not for id="keep_unit" -->
<div>
<div class="error" ng-show="scheduler_form.keep_amount.$dirty && scheduler_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="scheduler_form.keep_amount.$error.number || scheduler_form.keep_amount.$error.integer" >Please enter a valid number.</div>
<div class="error survey_error" ng-show="scheduler_form.keep_amount.$error.awMin">Please enter a non-negative number.</div>
<div class="error survey_error" ng-show="scheduler_form.keep_amount.$error.awMax">Please enter a number smaller than 9999.</div>
</div>
</div>
<div class="form-group SchedulerForm-formGroup" ng-if="isFactCleanup">
<label class="Form-inputLabel RepeatFrequencyOptions-everyLabel"><span class="red-text">*</span> Select a frequency for snapshot retention</label>
<div class="RepeatFrequencyOptions-inputGroup RepeatFrequencyOptions-inputGroup--halvesWithSelect">
<input sch-spinner="scheduler_form" class="scheduler-time-spinner SchedulerTime-input SpinnerInput RepeatFrequencyOptions-number" id="granularity_keep_amount" name="granularity_keep_amount" ng-model="granularity_keep_amount" aw-spinner="granularity_keep_amount"
ng-required="true" min="0" max="9999" integer ng-disabled="!(schedule_obj.summary_fields.user_capabilities.edit || canAdd)" aw-min="0" aw-max="9999" required>
<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 input-sm MakeSelect2" ng-disabled="!(schedule_obj.summary_fields.user_capabilities.edit || canAdd)"></select>
</div>
<!-- The below errors are ONLY for id="granularity_keep_amount", not for id="granularity_keep_unit" -->
<div>
<div class="error" ng-show="scheduler_form.granularity_keep_amount.$dirty && scheduler_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="scheduler_form.granularity_keep_amount.$error.number || scheduler_form.granularity_keep_amount.$error.integer" >Please enter a valid number.</div>
<div class="error survey_error" ng-show="scheduler_form.granularity_keep_amount.$error.awMin">Please enter a non-negative number.</div>
<div class="error survey_error" ng-show="scheduler_form.granularity_keep_amount.$error.awMax">Please enter a number smaller than 9999.</div>
</div>
</div>
<!-- end management job fields -->
</form>
<div class="SchedulerFormDetail-container
SchedulerFormDetail-container--error"

View File

@ -18,13 +18,7 @@ export default
scheduleData.rrule = RRuleToAPI(rrule.toString(), scope);
scheduleData.description = (/error/.test(rrule.toText())) ? '' : rrule.toText();
if (scope.isFactCleanup) {
extra_vars = {
"older_than": scope.scheduler_form.keep_amount.$viewValue + scope.scheduler_form.keep_unit.$viewValue.value,
"granularity": scope.scheduler_form.granularity_keep_amount.$viewValue + scope.scheduler_form.granularity_keep_unit.$viewValue.value
};
scheduleData.extra_data = JSON.stringify(extra_vars);
} else if (scope.cleanupJob) {
if (scope.cleanupJob) {
extra_vars = {
"days" : scope.scheduler_form.schedulerPurgeDays.$viewValue
};

View File

@ -274,7 +274,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
}
});
}
if ($state.current.name === 'workflowJobTemplateSchedules.add' ||
$state.current.name === 'projectSchedules.add' ||
$state.current.name === 'inventories.edit.inventory_sources.edit.schedules.add'
@ -301,39 +301,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
}
} else if (base === 'system_job_templates') {
schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/';
if (job_type === "cleanup_facts"){
$scope.isFactCleanup = true;
$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"
}];
$scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30);
$scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1);
$scope.keep_unit = $scope.keep_unit_choices[0];
$scope.granularity_keep_unit = $scope.granularity_keep_unit_choices[1];
} else {
$scope.cleanupJob = true;
}
$scope.cleanupJob = true;
}
Wait('start');

View File

@ -131,10 +131,8 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
$scope.extraVars = (data.extra_data === '' || _.isEmpty(data.extra_data)) ? '---' : '---\n' + jsyaml.safeDump(data.extra_data);
if (schedule.extra_data.hasOwnProperty('granularity')){
$scope.isFactCleanup = true;
}
if (schedule.extra_data.hasOwnProperty('days')){
if (_.has(schedule, 'summary_fields.unified_job_template.unified_job_type') &&
schedule.summary_fields.unified_job_template.unified_job_type === 'system_job'){
$scope.cleanupJob = true;
}
@ -146,8 +144,13 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
$http.get('/api/v2/schedules/zoneinfo/').then(({data}) => {
scheduler.scope.timeZones = data;
scheduler.scope.schedulerTimeZone = _.find(data, function(x) {
let tz = $scope.schedule_obj.rrule.match(/TZID=\s*(.*?)\s*:/)[1];
return x.name === tz;
let tz = $scope.schedule_obj.rrule.match(/TZID=\s*(.*?)\s*:/);
if (_.has(tz, '1')) {
return x.name === tz[1];
} else {
return false;
}
});
});
scheduler.inject('form-container', false);
@ -200,56 +203,8 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
scheduler.setRRule(schedule.rrule);
scheduler.setName(schedule.name);
if ($scope.isFactCleanup || $scope.cleanupJob){
var a,b, prompt_for_days,
keep_unit,
granularity,
granularity_keep_unit;
if ($scope.cleanupJob){
$scope.schedulerPurgeDays = Number(schedule.extra_data.days);
} else if ($scope.isFactCleanup){
$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"
}];
// the API returns something like 20w or 1y
a = schedule.extra_data.older_than; // "20y"
b = schedule.extra_data.granularity; // "1w"
prompt_for_days = Number(_.initial(a,1).join('')); // 20
keep_unit = _.last(a); // "y"
granularity = Number(_.initial(b,1).join('')); // 1
granularity_keep_unit = _.last(b); // "w"
$scope.keep_amount = prompt_for_days;
$scope.granularity_keep_amount = granularity;
$scope.keep_unit = _.find($scope.keep_unit_choices, function(i){
return i.value === keep_unit;
});
$scope.granularity_keep_unit =_.find($scope.granularity_keep_unit_choices, function(i){
return i.value === granularity_keep_unit;
});
}
if ($scope.cleanupJob){
$scope.schedulerPurgeDays = Number(schedule.extra_data.days);
}
if ($state.current.name === 'jobTemplateSchedules.edit'){