Fix server term command send

This commit is contained in:
amcmanu3 2024-01-28 16:20:58 -05:00
parent e399d57f47
commit 00ff98c991

View File

@ -164,7 +164,7 @@
const serverId = new URLSearchParams(document.location.search).get('id')
function send_command(serverId, command) {
async function send_command(serverId, command) {
if (command == 'start_server') {
startBtn.setAttribute('disabled', 'disabled');
restartBtn.removeAttribute('disabled');
@ -178,16 +178,23 @@
//<!-- this getCookie function is in base.html-->
const token = getCookie("_xsrf");
$.ajax({
type: "POST",
headers: { 'X-XSRFToken': token },
url: `/api/v2/servers/${serverId}/action/${command}`,
success: function (data) {
console.log("got response:");
console.log(data);
}
let res = await fetch(`/api/v2/servers/${serverId}/action/${command}`, {
method: 'POST',
headers: {
'token': token,
},
});
let responseData = await res.json();
if (responseData.status === "ok") {
console.log("Command received successfully")
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
}
if (webSocket) {
webSocket.on('update_button_status', function (updateButton) {
if (updateButton.isUpdating) {