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')
|
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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user