mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-18 17:15:13 +01:00
Fix command sends to server
This commit is contained in:
parent
d473a6ccf4
commit
81e4e7e450
@ -14,7 +14,8 @@
|
||||
<div class="col-12">
|
||||
<div class="page-header">
|
||||
<h4 class="page-title">
|
||||
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{ data['server_stats']['server_id']['server_name'] }}
|
||||
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{
|
||||
data['server_stats']['server_id']['server_name'] }}
|
||||
<br />
|
||||
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
|
||||
</h4>
|
||||
@ -76,10 +77,14 @@
|
||||
<li class="playerItem">
|
||||
<h3>{{ player }}</h3>
|
||||
<div class="buttons">
|
||||
<button onclick="send_command_to_server('ban {{ player }}')" type="button" class="btn btn-danger">Ban</button>
|
||||
<button onclick="send_command_to_server('kick {{ player }}')" type="button" class="btn btn-outline-danger">Kick</button>
|
||||
<button onclick="send_command_to_server('op {{ player }}')" type="button" class="btn btn-warning">OP</button>
|
||||
<button onclick="send_command_to_server('deop {{ player }}')" type="button" class="btn btn-outline-warning">De-OP</button>
|
||||
<button onclick="send_command_to_server('ban {{ player }}')" type="button"
|
||||
class="btn btn-danger">Ban</button>
|
||||
<button onclick="send_command_to_server('kick {{ player }}')" type="button"
|
||||
class="btn btn-outline-danger">Kick</button>
|
||||
<button onclick="send_command_to_server('op {{ player }}')" type="button"
|
||||
class="btn btn-warning">OP</button>
|
||||
<button onclick="send_command_to_server('deop {{ player }}')" type="button"
|
||||
class="btn btn-outline-warning">De-OP</button>
|
||||
</div>
|
||||
</li>
|
||||
{% end %}
|
||||
@ -136,21 +141,22 @@
|
||||
|
||||
});
|
||||
|
||||
function send_command_to_server(command) {
|
||||
async function send_command_to_server(command) {
|
||||
console.log(command)
|
||||
var token = getCookie("_xsrf")
|
||||
console.log('sending command: ' + command)
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/ajax/send_command?id=' + serverId,
|
||||
data: { command },
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/stdin`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-XSRFToken': token
|
||||
},
|
||||
body: command,
|
||||
});
|
||||
|
||||
let responseData = await res.text();
|
||||
console.log("got response:");
|
||||
console.log(responseData);
|
||||
}
|
||||
|
||||
|
||||
|
@ -311,12 +311,12 @@
|
||||
formdata.append('command', serverCommand)
|
||||
|
||||
console.log('sending command: ' + serverCommand)
|
||||
let res = await fetch("/ajax/send_command?id=" + serverId, {
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/stdin`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-XSRFToken': token
|
||||
},
|
||||
body: formdata,
|
||||
body: serverCommand,
|
||||
});
|
||||
|
||||
let responseData = await res.text();
|
||||
|
Loading…
x
Reference in New Issue
Block a user