crafty-4/app/frontend/templates/panel/server_admin_controls.html

109 lines
2.5 KiB
HTML
Raw Normal View History

2021-03-05 08:58:38 +00:00
{% extends ../base.html %}
{% block meta %}
{% end %}
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
2021-03-05 08:58:38 +00:00
{% block content %}
<div class="content-wrapper">
<!-- Page Title Header Starts-->
2021-03-05 08:58:38 +00:00
<div class="row page-title-header">
<div class="col-12">
<div class="page-header">
<h4 class="page-title">
2023-03-02 18:24:07 +00:00
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{
data['server_stats']['server_id']['server_name'] }}
<br />
2023-11-01 17:44:56 +00:00
<small>UUID: {{ data['server_stats']['server_id']['server_id'] }}</small>
2021-03-05 08:58:38 +00:00
</h4>
</div>
</div>
</div>
<!-- Page Title Header Ends-->
{% include "parts/details_stats.html %}
2021-03-05 08:58:38 +00:00
<div class="row">
<div class="col-sm-12 grid-margin">
<div class="card">
<div class="card-body pt-0">
<span class="d-none d-sm-block">
{% include "parts/server_controls_list.html %}
</span>
<span class="d-block d-sm-none">
{% include "parts/m_server_controls_list.html %}
</span>
<div class="row">
2023-04-15 18:47:35 +00:00
{% include "parts/server_players.html %}
</div>
<hr />
2021-03-05 08:58:38 +00:00
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
{% end %}
{% block js %}
<script>
const serverId = new URLSearchParams(document.location.search).get('id')
2021-03-05 08:58:38 +00:00
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
function getCookie(name) {
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
return r ? r[1] : undefined;
}
2021-03-05 08:58:38 +00:00
function htmlDecode(input) {
var e = document.createElement('textarea');
e.innerHTML = input;
// handle case of empty input
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
}
2021-03-05 08:58:38 +00:00
$(document).ready(function () {
console.log("ready!");
2021-03-05 08:58:38 +00:00
2023-04-15 18:47:35 +00:00
var bannedPlayers = `{{ data['banned_players_html'] }}`;
2021-03-05 08:58:38 +00:00
var bannedPlayersDecoded = htmlDecode(bannedPlayers);
2021-03-05 08:58:38 +00:00
$("#bannedPlayers").html(bannedPlayersDecoded)
2021-03-05 08:58:38 +00:00
});
2021-03-05 08:58:38 +00:00
2023-03-02 18:24:07 +00:00
async function send_command_to_server(command) {
console.log(command)
2023-09-04 23:22:11 +00:00
const token = getCookie("_xsrf")
console.log('sending command: ' + command)
2023-03-02 18:24:07 +00:00
let res = await fetch(`/api/v2/servers/${serverId}/stdin`, {
method: 'POST',
headers: {
'X-XSRFToken': token
},
2023-03-02 18:24:07 +00:00
body: command,
});
2023-03-02 18:24:07 +00:00
let responseData = await res.text();
console.log("got response:");
console.log(responseData);
}
2021-03-05 08:58:38 +00:00
</script>
{% end %}