Change backup_now post for better error handling

This commit is contained in:
Andrew 2023-07-05 19:34:42 -04:00
parent c0fb5cf179
commit 1b9e284f52

View File

@ -316,21 +316,32 @@
return r ? r[1] : undefined;
}
function backup_started() {
async function backup_started() {
var token = getCookie("_xsrf")
document.getElementById('backup_button').style.visibility = 'hidden';
var dialog = bootbox.dialog({
message: "{{ translate('serverBackups', 'backupTask', data['lang']) }}",
closeButton: false
});
$.ajax({
type: "POST",
headers: { 'X-XSRFToken': token },
url: `/api/v2/servers/${server_id}/action/backup_server`,
success: function (data) {
return;
},
});
var token = getCookie("_xsrf");
let res = await fetch(`/api/v2/servers/${server_id}/action/backup_server`, {
method: 'POST',
headers: {
'X-XSRFToken': token
}
});
let responseData = await res.json();
if (responseData.status === "ok") {
console.log(responseData);
process_tree_response(responseData);
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
return;
}
async function del_backup(filename, id) {
@ -352,28 +363,6 @@
}
}
function restore_backup(filename, id) {
var token = getCookie("_xsrf")
var dialog = bootbox.dialog({
message: "<i class='fa fa-spin fa-spinner'></i> {{ translate('serverBackups', 'restoring', data['lang']) }}",
closeButton: false
});
console.log('Sending Command to restore backup: ' + filename)
$.ajax({
type: "POST",
headers: { 'X-XSRFToken': token },
url: '/ajax/restore_backup?server_id=' + id,
body: {
"filename": filename,
},
success: function (data) {
setTimeout(function () {
location.href = ('/panel/dashboard');
}, 15000);
},
});
}
async function restore_backup(filename, id) {
var token = getCookie("_xsrf")
let contents = JSON.stringify({"filename": filename})