Merge branch 'refactor/remote-comms-patch-2' of gitlab.com:crafty-controller/crafty-4 into refactor/remote-comms-patch-2

This commit is contained in:
amcmanu3 2023-07-12 12:23:52 -04:00
commit 2f509b46ee
3 changed files with 26 additions and 57 deletions

View File

@ -1146,12 +1146,6 @@ class Helpers:
user_id, "send_temp_path", {"path": temp_dir}
)
def backup_select(self, path, user_id):
if user_id:
self.websocket_helper.broadcast_user(
user_id, "send_temp_path", {"path": path}
)
@staticmethod
def unzip_backup_archive(backup_path, zip_name):
zip_path = os.path.join(backup_path, zip_name)

View File

@ -187,11 +187,6 @@ class AjaxHandler(BaseHandler):
)
return
elif page == "backup_select":
path = self.get_argument("path", None)
self.helper.backup_select(path, exec_user["user_id"])
return
elif page == "jar_cache":
if not superuser:
self.redirect("/panel/error?error=Not a super user")

View File

@ -313,21 +313,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) {
@ -349,28 +360,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})
@ -571,17 +560,6 @@
closeButton: false
});
$.ajax({
type: "POST",
headers: { 'X-XSRFToken': token },
url: '/ajax/backup_select?id=' + server_id + '&path=' + path,
});
} else {
bootbox.alert("You must input a path before selecting this button");
}
});
if (webSocket) {
webSocket.on('send_temp_path', function (data) {
setTimeout(function () {
var x = document.querySelector('.bootbox');
if (x) {
@ -591,13 +569,15 @@
if (x) {
x.remove()
}
document.getElementById('main-tree-input').setAttribute('value', data.path)
getTreeView(data.path);
document.getElementById('main-tree-input').setAttribute('value', path)
getTreeView(path);
show_file_tree();
}, 5000);
});
}
} else {
bootbox.alert("You must input a path before selecting this button");
}
});
if (webSocket) {
webSocket.on('backup_status', function (backup) {
if (backup.percent >= 100) {