SweetAlert on "Cleanup VNC Sessions"

This commit is contained in:
Will Nilges 2022-09-10 10:16:57 -04:00
parent 509ea616fc
commit cd6bdba409

View file

@ -636,18 +636,44 @@ $("#process-expiring-vms-task-button").click(function(){
$("#cleanup-vnc-task-button").click(function(){ $("#cleanup-vnc-task-button").click(function(){
const vncCleanupToken = $(this).data('vnc_cleanup_token'); const vncCleanupToken = $(this).data('vnc_cleanup_token');
// let data = {'token': vncCleanupToken};
swal({
console.log(vncCleanupToken); title: "Are you sure you want to clear VNC tokens?",
text: "This will clear the websockify targets file, and remove all entries from Redis. Ongoing VNC sessions may be disrupted.",
var formData = new FormData(); icon: "warning",
formData.append('token', vncCleanupToken); buttons: {
fetch(`/console/cleanup`, { cancel: true,
method: 'post', action: {
credentials: 'same-origin', text: "Cleanup VNC Sessions",
body: formData closeModal: false,
}).then(res => { className: "swal-button--danger",
console.log("Request complete! response:", res); }
},
dangerMode: true,
})
.then((willComplete) => {
if (willComplete) {
var formData = new FormData();
formData.append('token', vncCleanupToken);
fetch(`/console/cleanup`, {
method: 'post',
credentials: 'same-origin',
body: formData
}).then((response) => {
return swal("VNC Sessions have been cleared", {
icon: "success",
});
}).then(() => {
window.location = location;
}).catch(err => {
if (err) {
swal("Uh oh...", "Unable to clear VNC sessions", "error");
} else {
swal.stopLoading();
swal.close();
}
});
}
}); });
}); });