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