Configure Tower schedule deletion

Moved the delete icon from the cleanup job list to a button on the schedule form for when the mode is 'edit'
This commit is contained in:
Jared Tabor
2014-11-14 11:45:51 -05:00
parent f0d7e3be23
commit 825d996316
3 changed files with 64 additions and 69 deletions

View File

@@ -221,66 +221,7 @@ angular.module('ConfigureTowerHelper', [ 'Utilities', 'RestServices', 'Schedules
};
scope.deleteSystemSchedule = function(id){
var url, hdr,action;
Rest.setUrl(scheduleUrl+id+'/schedules/');
Rest.get()
.success(function(data) {
//delete the schedule if one exists
if(data.count>0){
if(!Empty(data.results[0].url)){
url = data.results[0].url;
hdr = 'Delete Schedule';
action = function () {
Wait('start');
Rest.setUrl(url);
Rest.destroy()
.success(function () {
$('#prompt-modal').modal('hide');
Wait('stop');
scope.$emit(callback, id);
})
.error(function (data, status) {
try {
$('#prompt-modal').modal('hide');
}
catch(e) {
// ignore
}
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
' failed. DELETE returned: ' + status });
});
};
Prompt({
hdr: hdr,
body: "<div class=\"alert alert-info\">Are you sure you want to delete the <em>" + data.results[0].name + "</em> schedule?</div>",
action: action,
backdrop: false
});
}
} else {
//a schedule doesn't exist
$("#prompt_action_btn").text('OK');
$('#prompt_cancel_btn').hide();
var action2 = function(){
$('#prompt-modal').modal('hide');
$("#prompt_action_btn").text('Yes');
$('#prompt_cancel_btn').show();
};
Prompt({
hdr: "Delete",
body: "<div class=\"alert alert-info\">No schedule exists for that job. </div>",
action: action2,
backdrop: false
});
}
})
.error(function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed updating job ' + scope.job_template_id + ' with variables. PUT returned: ' + status });
});
};
parent_scope.refreshJobs = function(){
scope.search(SchedulesList.iterator);
@@ -328,7 +269,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
container = $('#configure-schedules-form-container');
$("#configure-jobs").show();
$("#configure-schedules-form-container").hide();
scope.mode = mode;
// Clean up any lingering stuff
container.hide();
target.empty();
@@ -379,7 +320,6 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
scheduler.setRRule(schedule.rrule);
scheduler.setName(schedule.name);
scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30;
scope.id = id;
});
}
};
@@ -447,6 +387,60 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
}
};
scope.deleteSystemSchedule = function(){
var hdr = 'Delete Schedule',
action = function () {
Wait('start');
Rest.setUrl(schedule.url);
Rest.destroy()
.success(function () {
$('#prompt-modal').modal('hide');
Wait('stop');
// scope.$emit(callback, id);
scope.cancelScheduleForm();
})
.error(function (data, status) {
try {
$('#prompt-modal').modal('hide');
}
catch(e) {
// ignore
}
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
' failed. DELETE returned: ' + status });
});
};
Prompt({
hdr: hdr,
body: "<div class=\"alert alert-info\">Are you sure you want to delete the <em>" + scope.schedulerName + "</em> schedule?</div>",
action: action,
backdrop: false
});
// }
// } else {
// //a schedule doesn't exist
// $("#prompt_action_btn").text('OK');
// $('#prompt_cancel_btn').hide();
// var action2 = function(){
// $('#prompt-modal').modal('hide');
// $("#prompt_action_btn").text('Yes');
// $('#prompt_cancel_btn').show();
// };
// Prompt({
// hdr: "Delete",
// body: "<div class=\"alert alert-info\">No schedule exists for that job. </div>",
// action: action2,
// backdrop: false
// });
// }
// })
// .error(function(data, status) {
// ProcessErrors(scope, data, status, null, { hdr: 'Error!',
// msg: 'Failed updating job ' + scope.job_template_id + ' with variables. PUT returned: ' + status });
// });
};
scope.cancelScheduleForm = function() {
container.hide('slide', { direction: 'right' }, 500, restoreList);
scope.$destroy();

View File

@@ -41,16 +41,16 @@ angular.module('ConfigureTowerJobsListDefinition', [])
schedule: {
label: 'Schedule',
mode: 'all',
ngClick: 'configureSchedule(configure_job.id)', // '#/job_templates/{{ configure_job.id }}/schedules',
ngClick: 'configureSchedule(configure_job.id, configure_job.name)', // '#/job_templates/{{ configure_job.id }}/schedules',
awToolTip: 'Schedule future job template runs',
dataPlacement: 'top',
},
delete: {
label: 'Delete Schedule',
mode: 'all',
ngClick: 'deleteSystemSchedule(configure_job.id)', // '#/job_templates/{{ configure_job.id }}/schedules',
awToolTip: 'Delete the schedule ',
dataPlacement: 'top'
}
// delete: {
// label: 'Delete Schedule',
// mode: 'all',
// ngClick: 'deleteSystemSchedule(configure_job.id)', // '#/job_templates/{{ configure_job.id }}/schedules',
// awToolTip: 'Delete the schedule ',
// dataPlacement: 'top'
// }
}
});

View File

@@ -408,6 +408,7 @@
<div id="configure-schedules-buttons" >
<a id="configure-schedules-flip-link" ng-show="formShowing" ng-click="showScheduleDetail()" href=""><i class="fa fa-search-plus"></i> View Details</a>
<a id="configure-schedules-flip-link" ng-show="!formShowing" ng-click="showScheduleDetail()" href=""><i class="fa fa-arrow-circle-left"></i> Back to options</a>
<button type="button" class="btn btn-default btn-sm" id="configure-schedule-delete-button" ng-show="mode==='edit'" ng-click="deleteSystemSchedule($event)"><i class="fa fa-trash-o"></i> Delete</button>
<button type="button" class="btn btn-default btn-sm" id="configure-reset-button" ng-click="cancelScheduleForm()"><i class="fa fa-times"></i> Cancel</button>
<button type="button" class="btn btn-primary btn-sm" id="configure-save-button" ng-click="saveScheduleForm()"><i class="fa fa-check"></i> Save</button>
</div>