mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 09:45:28 +01:00
Add delete to front end
This commit is contained in:
parent
ad7ba9d6a7
commit
c0fb5cf179
@ -648,37 +648,27 @@
|
||||
});
|
||||
}
|
||||
|
||||
function deleteFile(path, callback) {
|
||||
console.log('Deleting: ' + path)
|
||||
var token = getCookie("_xsrf")
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: "/files/del_file?id=" + serverId,
|
||||
data: {
|
||||
file_path: path
|
||||
},
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
callback();
|
||||
async function deleteItem(path, el, callback) {
|
||||
var token = getCookie("_xsrf");
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/files`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-XSRFToken': token
|
||||
},
|
||||
body: JSON.stringify({"filename": path}),
|
||||
});
|
||||
let responseData = await res.json();
|
||||
if (responseData.status === "ok") {
|
||||
el = document.getElementById(path + "li");
|
||||
$(el).remove();
|
||||
document.getElementById('files-tree-nav').style.display = 'none';
|
||||
} else {
|
||||
|
||||
bootbox.alert({
|
||||
title: responseData.status,
|
||||
message: responseData.error
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDir(path, callback) {
|
||||
var token = getCookie("_xsrf")
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: "/files/del_dir?id=" + serverId,
|
||||
data: {
|
||||
dir_path: path
|
||||
},
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
callback();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function unZip(path, callback) {
|
||||
@ -1155,11 +1145,7 @@
|
||||
},
|
||||
callback: function (result) {
|
||||
if (!result) return;
|
||||
deleteFile(path, function () {
|
||||
el = document.getElementById(path + "li");
|
||||
$(el).remove();
|
||||
document.getElementById('files-tree-nav').style.display = 'none';
|
||||
});
|
||||
deleteItem(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1184,11 +1170,7 @@
|
||||
},
|
||||
callback: function (result) {
|
||||
if (!result) return;
|
||||
deleteDir(path, function () {
|
||||
el = document.getElementById(path + "li");
|
||||
$(el).remove();
|
||||
document.getElementById('files-tree-nav').style.display = 'none';
|
||||
});
|
||||
deleteItem(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user