2021-08-27 23:48:46 +00:00
|
|
|
{% extends ../public_base.html %}
|
2021-08-27 01:06:22 +00:00
|
|
|
|
|
|
|
{% block meta %}
|
|
|
|
{% end %}
|
|
|
|
|
2021-09-29 02:25:47 +00:00
|
|
|
{% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard', data['lang']) }}{% end %}
|
2021-08-27 01:06:22 +00:00
|
|
|
|
|
|
|
{% block content %}
|
2022-06-22 19:36:05 +00:00
|
|
|
<!-- View for Large screen -->
|
2022-12-01 00:53:10 +00:00
|
|
|
<style>
|
|
|
|
.auth.auth-bg-1 {
|
2023-01-18 19:35:35 +00:00
|
|
|
background: url("../../static/assets/images/auth/{% raw data['background'] %}"),
|
2023-03-07 03:54:26 +00:00
|
|
|
url("/static/assets/images/auth/login_1.jpg");
|
2022-12-01 00:53:10 +00:00
|
|
|
background-size: cover;
|
|
|
|
}
|
|
|
|
</style>
|
2022-06-22 19:36:05 +00:00
|
|
|
<div class="row justify-content-center">
|
2022-09-25 21:52:01 +00:00
|
|
|
<div class="content-wrapper col-md login-modal d-none d-sm-block" style="background-color: var(--dropdown-bg);">
|
2022-06-22 19:36:05 +00:00
|
|
|
<img src="/static/assets/images/logo_long.png" style='width: 25%; margin-left: 38%;'>
|
|
|
|
<hr />
|
|
|
|
<div class="table-responsive">
|
|
|
|
<table class="table table-hover">
|
|
|
|
<thead>
|
|
|
|
<tr class="rounded">
|
|
|
|
<th>{{ translate('dashboard', 'server', data['lang']) }}</th>
|
|
|
|
<th>{{ translate('dashboard', 'players', data['lang']) }}</th>
|
|
|
|
<th>{{ translate('dashboard', 'motd', data['lang']) }}</th>
|
|
|
|
<th>{{ translate('dashboard', 'version', data['lang']) }}</th>
|
|
|
|
<th>{{ translate('dashboard', 'status', data['lang']) }}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for server in data['servers'] %}
|
2022-07-14 22:26:42 +00:00
|
|
|
{% if server['server_data']['show_status'] %}
|
2022-06-22 19:36:05 +00:00
|
|
|
<tr>
|
|
|
|
<td id="server_name_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
<i class="fas fa-server"></i>
|
|
|
|
{{ server['server_data']['server_name'] }}
|
|
|
|
</td>
|
|
|
|
{% if server['stats']['int_ping_results'] != 'False' %}
|
|
|
|
<td id="server_players_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max',
|
|
|
|
data['lang']) }}<br />
|
|
|
|
</td>
|
|
|
|
<td id="server_motd_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
{% if server['stats']['desc'] != 'False' %}
|
2023-09-02 19:51:28 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-auto">
|
|
|
|
<img src="/static/assets/images/pack.png" alt="icon" style="-webkit-filter:grayscale(100%); filter:grayscale(100%)" />
|
|
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
|
|
<span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ server['stats']['desc'] }}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-22 19:36:05 +00:00
|
|
|
{% end %}
|
|
|
|
</td>
|
|
|
|
<td id="server_version_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
{% if server['stats']['version'] != 'False' %}
|
|
|
|
{{ server['stats']['version'] }}
|
|
|
|
{% end %}
|
|
|
|
</td>
|
|
|
|
{% else %}
|
|
|
|
<td id="server_players_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
<span class="text-warning"><i class="fas fa-exclamation-triangle"></i></span>
|
|
|
|
</td>
|
|
|
|
<td id="server_motd_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
<span class="text-warning">Crafty can't get infos from this Server </span>
|
|
|
|
</td>
|
|
|
|
<td id="server_version_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
<span class="text-warning"><i class="fas fa-question"></i></i></span>
|
|
|
|
</td>
|
2021-08-27 23:48:46 +00:00
|
|
|
{% end %}
|
2022-06-22 19:36:05 +00:00
|
|
|
<td id="server_online_status_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
{% if server['stats']['running'] %}
|
|
|
|
<span class="text-success"><i class="fas fa-signal"></i> {{ translate('dashboard', 'online', data['lang'])
|
|
|
|
}}</span>
|
|
|
|
{% else %}
|
|
|
|
<span class="text-danger"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', data['lang'])
|
|
|
|
}}</span>
|
|
|
|
{% end %}
|
|
|
|
</td>
|
|
|
|
</tr>
|
2022-01-19 20:34:59 +00:00
|
|
|
{% end %}
|
2022-07-14 22:26:42 +00:00
|
|
|
{% end %}
|
2022-06-22 19:36:05 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- View for Small screen -->
|
|
|
|
<div class="row justify-content-center align-items-sm-center">
|
2023-08-09 21:47:53 +00:00
|
|
|
<div class="content-wrapper login-modal d-sm-none d-block" style="background-color: var(--dropdown-bg);">
|
2022-06-22 19:36:05 +00:00
|
|
|
<img src="/static/assets/images/logo_long.png" style='width: 100%;'>
|
|
|
|
<hr />
|
|
|
|
<div class="accordion" id="accordionServers">
|
|
|
|
{% for server in data['servers'] %}
|
2023-08-01 16:20:01 +00:00
|
|
|
{% if server['server_data']['show_status'] %}
|
2022-06-22 19:36:05 +00:00
|
|
|
<div class="card mb-0">
|
|
|
|
<div class="card-header" id="heading-{{server['server_data']['server_id']}}">
|
|
|
|
<h2 class="mb-0 container overflow-hidden">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-8 mx-0 px-0">
|
2023-08-09 21:47:53 +00:00
|
|
|
<a id="m_server_name_{{ server['stats']['server_id']['server_id'] }}" class="btn btn-link d-flex justify-content-center" type="button" data-toggle="collapse" data-target="#collapse-{{server['server_data']['server_id']}}" aria-expanded="false" aria-controls="collapse-{{server['server_data']['server_id']}}">
|
2022-06-22 19:36:05 +00:00
|
|
|
<i class="fas fa-server"></i>
|
|
|
|
{{ server['server_data']['server_name'] }}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="col-4 mx-0 px-0">
|
2023-08-09 21:47:53 +00:00
|
|
|
<a id="m_server_online_status_{{ server['stats']['server_id']['server_id'] }}" class="btn btn-link d-flex justify-content-center" type="button">
|
2022-06-22 19:36:05 +00:00
|
|
|
{% if server['stats']['running'] %}
|
|
|
|
<div id="m_server_players_{{ server['stats']['server_id']['server_id'] }}">
|
2022-09-25 21:52:01 +00:00
|
|
|
<span class="text-success"><i class="fas fa-signal"></i> {{ server['stats']['online'] }} / {{
|
|
|
|
server['stats']['max'] }}</span>
|
2022-06-22 19:36:05 +00:00
|
|
|
</div>
|
|
|
|
{% else %}
|
2022-09-25 21:52:01 +00:00
|
|
|
<span class="text-danger"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline',
|
|
|
|
data['lang']) }}</span>
|
2022-06-22 19:36:05 +00:00
|
|
|
{% end %}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
|
2023-08-09 21:47:53 +00:00
|
|
|
<div id="collapse-{{server['server_data']['server_id']}}" class="collapse" aria-labelledby="heading-{{server['server_data']['server_id']}}" data-parent="#accordionServers">
|
2022-06-22 19:36:05 +00:00
|
|
|
<div class="card-body">
|
|
|
|
{% if server['stats']['int_ping_results'] != 'False' %}
|
|
|
|
<div id="m_server_motd_{{ server['stats']['server_id']['server_id'] }}" class="media">
|
|
|
|
{% if server['stats']['desc'] != 'False' %}
|
2023-08-09 21:47:53 +00:00
|
|
|
<img src="/static/assets/images/pack.png" class="w-25 mr-3" alt="icon" style="-webkit-filter:grayscale(100%); filter:grayscale(100%);" />
|
2022-06-22 19:36:05 +00:00
|
|
|
{% end %}
|
|
|
|
<div class="media-body">
|
|
|
|
{% if server['stats']['desc'] != 'False' %}
|
|
|
|
<div id="m_server_motd_{{ server['stats']['server_id']['server_id'] }}">
|
2022-07-16 17:58:58 +00:00
|
|
|
<span id="m_input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{
|
2022-06-22 19:36:05 +00:00
|
|
|
server['stats']['desc'] }}</span> <br />
|
|
|
|
</div>
|
|
|
|
{% end %}
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-23 16:07:25 +00:00
|
|
|
<br />
|
|
|
|
<div id="m_server_version_{{ server['stats']['server_id']['server_id'] }}">
|
|
|
|
{% if server['stats']['version'] != 'False' %}
|
|
|
|
{{ server['stats']['version'] }}
|
|
|
|
{% end %}
|
|
|
|
</div>
|
2021-08-27 23:48:46 +00:00
|
|
|
{% else %}
|
2022-06-22 19:36:05 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-12">
|
|
|
|
<div id="m_server_motd_{{ server['stats']['server_id']['server_id'] }}">
|
2022-09-25 21:52:01 +00:00
|
|
|
<span class="text-warning"><i class="fas fa-exclamation-triangle"></i> Crafty can't get infos from
|
|
|
|
this Server </span>
|
2022-06-22 19:36:05 +00:00
|
|
|
</div>
|
2022-07-16 17:58:58 +00:00
|
|
|
<div id="m_server_version_{{ server['stats']['server_id']['server_id'] }}"></div>
|
2022-06-22 19:36:05 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-27 23:48:46 +00:00
|
|
|
{% end %}
|
2022-06-22 19:36:05 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% end %}
|
2023-08-01 16:20:01 +00:00
|
|
|
{% end %}
|
2022-06-22 19:36:05 +00:00
|
|
|
</div>
|
2021-08-27 23:48:46 +00:00
|
|
|
</div>
|
2021-08-27 01:06:22 +00:00
|
|
|
</div>
|
|
|
|
{% end %}
|
|
|
|
|
|
|
|
{% block js %}
|
|
|
|
|
2022-01-19 20:34:59 +00:00
|
|
|
<script src="/static/assets/js/motd.js"></script>
|
|
|
|
<script>
|
|
|
|
function display_motd() {
|
|
|
|
var all_motds = Array.from(document.getElementsByClassName('input_motd'));
|
|
|
|
for (element of all_motds) {
|
|
|
|
initParser(element.id, element.id);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_one_server_status(server) {
|
2022-06-22 19:36:05 +00:00
|
|
|
/* Normal Screen view */
|
2022-01-19 20:34:59 +00:00
|
|
|
server_players = document.getElementById('server_players_' + server.id);
|
|
|
|
server_motd = document.getElementById('server_motd_' + server.id);
|
|
|
|
server_version = document.getElementById('server_version_' + server.id);
|
|
|
|
server_online_status = document.getElementById('server_online_status_' + server.id);
|
2022-06-22 19:36:05 +00:00
|
|
|
/* Small Screen view */
|
|
|
|
m_server_players = document.getElementById('m_server_players_' + server.id);
|
|
|
|
m_server_motd = document.getElementById('m_server_motd_' + server.id);
|
|
|
|
m_server_version = document.getElementById('m_server_version_' + server.id);
|
|
|
|
m_server_online_status = document.getElementById('m_server_online_status_' + server.id);
|
2022-01-19 20:34:59 +00:00
|
|
|
|
|
|
|
/* TODO Update each element */
|
2023-09-02 19:51:28 +00:00
|
|
|
if (server.running) {
|
2022-01-19 20:34:59 +00:00
|
|
|
/* Update Players */
|
2023-09-20 00:31:56 +00:00
|
|
|
if (server.max != 0) {
|
2022-01-19 20:34:59 +00:00
|
|
|
server_players.innerHTML = server.online + ` / ` + server.max + ` {{ translate('dashboard', 'max', data['lang']) }}<br />`
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update Motd */
|
|
|
|
var motd = "";
|
|
|
|
if (server.desc) {
|
|
|
|
if (server.icon) {
|
2023-09-02 19:51:28 +00:00
|
|
|
img_motd = `<img src="data:image/png;base64,` + server.icon + `" alt="icon" /> `;
|
2022-06-22 19:36:05 +00:00
|
|
|
m_motd = `<img src="data:image/png;base64,` + server.icon + `" alt="icon" /> `;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
else {
|
2023-09-02 19:51:28 +00:00
|
|
|
img_motd = `<img src="/static/assets/images/pack.png" alt="icon" /> `;
|
2022-06-23 16:02:54 +00:00
|
|
|
m_motd = `<img class="w-25 mr-3" src="/static/assets/images/pack.png" alt="icon" /> `;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
|
2023-09-02 19:51:28 +00:00
|
|
|
desc_motd = `<span id="input_motd_` + server.id + `" class="input_motd">` + server.desc + `</span> <br />`;
|
2022-07-16 17:58:58 +00:00
|
|
|
m_motd = m_motd + `<div class="media-body"><span id="m_input_motd_` + server.id + `" class="input_motd">` + server.desc + `</span></div>`;
|
2023-09-02 19:51:28 +00:00
|
|
|
|
|
|
|
motd = `<div class="row"><div class="col-auto">` + img_motd + `</div><div class="col-auto">` + desc_motd + `</div></div>`;
|
2022-01-19 20:34:59 +00:00
|
|
|
server_motd.innerHTML = motd;
|
2022-06-22 19:36:05 +00:00
|
|
|
m_server_motd.innerHTML = m_motd;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Version */
|
2022-06-22 19:36:05 +00:00
|
|
|
if (server.version) {
|
|
|
|
server_version.innerHTML = server.version;
|
|
|
|
m_server_version.innerHTML = server.version;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
server_players.innerHTML = `<span class="text-warning"><i class="fas fa-exclamation-triangle"></i></span>`;
|
|
|
|
server_motd.innerHTML = `<span class="text-warning">Crafty can't get infos from this Server </span>`;
|
2022-06-22 19:36:05 +00:00
|
|
|
server_version.innerHTML = `<span class="text-warning"><i class="fas fa-question"></i></i></span>`;
|
|
|
|
m_server_motd.innerHTML = `<span class="text-warning"><i class="fas fa-exclamation-triangle"></i> Crafty can't get infos from this Server </span>`;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update Online Status */
|
|
|
|
var online_status = "";
|
|
|
|
if (server.running) {
|
|
|
|
online_status = `<span class="text-success"><i class="fas fa-signal"></i> {{ translate('dashboard', 'online', data['lang'])}}</span>`;
|
2022-06-22 19:36:05 +00:00
|
|
|
m_online_status = `<span class="text-success"><i class="fas fa-signal"></i>` + server.online + ` / ` + server.max + `</span>`;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
online_status = `<span class="text-danger"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', data['lang'])}}</span>`;
|
2022-06-22 19:36:05 +00:00
|
|
|
m_online_status = `<span class="text-danger"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', data['lang'])}}</span>`;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
server_online_status.innerHTML = online_status;
|
2022-06-22 19:36:05 +00:00
|
|
|
m_server_online_status.innerHTML = m_online_status;
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function update_servers_status(data) {
|
2023-09-02 19:51:28 +00:00
|
|
|
console.log("update servers");
|
|
|
|
data.forEach(server => {
|
|
|
|
console.log(server);
|
|
|
|
update_one_server_status(server);
|
|
|
|
});
|
2022-03-03 22:13:40 +00:00
|
|
|
display_motd();
|
2022-01-19 20:34:59 +00:00
|
|
|
}
|
|
|
|
|
2023-09-02 19:51:28 +00:00
|
|
|
function refreshStatus() {
|
|
|
|
let xmlHttp = new XMLHttpRequest();
|
|
|
|
xmlHttp.onreadystatechange = function () {
|
|
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
|
|
var myData = JSON.parse(this.responseText);
|
|
|
|
update_servers_status(myData.data);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
xmlHttp.open('GET', '/api/v2/servers/status', true);
|
|
|
|
xmlHttp.send();
|
|
|
|
|
|
|
|
setTimeout(refreshStatus, 30000);
|
|
|
|
}
|
|
|
|
|
2022-01-19 20:34:59 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
console.log("ready!");
|
2023-09-02 19:51:28 +00:00
|
|
|
refreshStatus();
|
2022-01-19 20:34:59 +00:00
|
|
|
}());
|
|
|
|
</script>
|
2021-08-27 23:48:46 +00:00
|
|
|
|
2022-06-22 19:36:05 +00:00
|
|
|
{% end %}
|