management jobs fixes

This commit is contained in:
Jared Tabor
2015-07-23 16:46:52 -04:00
parent fe285a8924
commit 8d19eec6af
2 changed files with 16 additions and 14 deletions

View File

@@ -86,6 +86,9 @@ export default
schedule, scheduler, schedule, scheduler,
url = GetBasePath('schedules') + id + '/'; url = GetBasePath('schedules') + id + '/';
delete scope.isFactCleanup;
delete scope.cleanupJob;
function setGranularity(){ function setGranularity(){
var a,b, prompt_for_days, var a,b, prompt_for_days,
keep_unit, keep_unit,
@@ -124,13 +127,13 @@ export default
// the API returns something like 20w or 1y // the API returns something like 20w or 1y
a = schedule.extra_data.older_than; // "20y" a = schedule.extra_data.older_than; // "20y"
b = schedule.extra_data.granularity; // "1w" b = schedule.extra_data.granularity; // "1w"
prompt_for_days = Number(_.initial(a,1).join('')); prompt_for_days = Number(_.initial(a,1).join('')); // 20
keep_unit = _.last(a); // "y" keep_unit = _.last(a); // "y"
granularity = Number(_.initial(b,1).join('')); granularity = Number(_.initial(b,1).join('')); // 1
granularity_keep_unit = _.last(b); // "w" granularity_keep_unit = _.last(b); // "w"
scope.prompt_for_days_facts_form.keep_amount.$setViewValue(prompt_for_days); scope.keep_amount = prompt_for_days;
scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(granularity); scope.granularity_keep_amount = granularity;
scope.keep_unit = _.find(scope.keep_unit_choices, function(i){ scope.keep_unit = _.find(scope.keep_unit_choices, function(i){
return i.value === keep_unit; return i.value === keep_unit;
}); });
@@ -140,14 +143,6 @@ export default
} }
} }
if(!Empty($routeParams.management_job)) {
if(scope.management_job.id === 4){
scope.isFactCleanup = true;
} else {
scope.cleanupJob = true;
}
}
if (scope.removeDialogReady) { if (scope.removeDialogReady) {
scope.removeDialogReady(); scope.removeDialogReady();
} }
@@ -158,7 +153,7 @@ export default
scope.$apply(function() { scope.$apply(function() {
scheduler.setRRule(schedule.rrule); scheduler.setRRule(schedule.rrule);
scheduler.setName(schedule.name); scheduler.setName(schedule.name);
if(!Empty(scope.management_job)){ if(scope.isFactCleanup || scope.cleanupJob){
setGranularity(); setGranularity();
} }
@@ -225,6 +220,13 @@ export default
Rest.get() Rest.get()
.success(function(data) { .success(function(data) {
schedule = data; schedule = data;
if(schedule.hasOwnProperty('extra_data')) {
if(schedule.extra_data.hasOwnProperty('granularity')){
scope.isFactCleanup = true;
} else {
scope.cleanupJob = true;
}
}
scope.$emit('ScheduleFound'); scope.$emit('ScheduleFound');
}) })
.error(function(data,status){ .error(function(data,status){

View File

@@ -48,7 +48,7 @@ export default [
scope: $scope, scope: $scope,
list: SchedulesList, list: SchedulesList,
id: 'management_jobs_schedule', id: 'management_jobs_schedule',
url: url + '?next_run__isnull=false', url: url,
pageSize: 20 pageSize: 20
}); });
}); });