mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix server term command send
This commit is contained in:
parent
e399d57f47
commit
00ff98c991
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user