mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 23:37:39 -02:30
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:
@@ -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(){
|
parent_scope.refreshJobs = function(){
|
||||||
scope.search(SchedulesList.iterator);
|
scope.search(SchedulesList.iterator);
|
||||||
@@ -328,7 +269,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
|
|||||||
container = $('#configure-schedules-form-container');
|
container = $('#configure-schedules-form-container');
|
||||||
$("#configure-jobs").show();
|
$("#configure-jobs").show();
|
||||||
$("#configure-schedules-form-container").hide();
|
$("#configure-schedules-form-container").hide();
|
||||||
|
scope.mode = mode;
|
||||||
// Clean up any lingering stuff
|
// Clean up any lingering stuff
|
||||||
container.hide();
|
container.hide();
|
||||||
target.empty();
|
target.empty();
|
||||||
@@ -379,7 +320,6 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
|
|||||||
scheduler.setRRule(schedule.rrule);
|
scheduler.setRRule(schedule.rrule);
|
||||||
scheduler.setName(schedule.name);
|
scheduler.setName(schedule.name);
|
||||||
scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30;
|
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() {
|
scope.cancelScheduleForm = function() {
|
||||||
container.hide('slide', { direction: 'right' }, 500, restoreList);
|
container.hide('slide', { direction: 'right' }, 500, restoreList);
|
||||||
scope.$destroy();
|
scope.$destroy();
|
||||||
|
|||||||
@@ -41,16 +41,16 @@ angular.module('ConfigureTowerJobsListDefinition', [])
|
|||||||
schedule: {
|
schedule: {
|
||||||
label: 'Schedule',
|
label: 'Schedule',
|
||||||
mode: 'all',
|
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',
|
awToolTip: 'Schedule future job template runs',
|
||||||
dataPlacement: 'top',
|
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'
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -408,6 +408,7 @@
|
|||||||
<div id="configure-schedules-buttons" >
|
<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-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>
|
<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-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>
|
<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>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user