mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev_websocket_server_status' into 'dev'
Adding Websocket for server details See merge request crafty-controller/crafty-commander!144
This commit is contained in:
commit
9cc149c7e8
@ -287,9 +287,9 @@ class Controller:
|
||||
return False
|
||||
|
||||
if helper.is_os_windows():
|
||||
server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem),
|
||||
server_command = 'java -Xms{}M -Xmx{}M -jar "{}" nogui'.format(helper.float_to_string(min_mem),
|
||||
helper.float_to_string(max_mem),
|
||||
'"'+full_jar_path+'"')
|
||||
full_jar_path)
|
||||
else:
|
||||
server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem),
|
||||
helper.float_to_string(max_mem),
|
||||
|
@ -1,4 +1,5 @@
|
||||
from datetime import timedelta
|
||||
from http import server
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
@ -285,8 +286,7 @@ class TasksManager:
|
||||
logger.info("Scheduling Serverjars.com cache refresh service every 12 hours")
|
||||
self.scheduler.add_job(server_jar_obj.refresh_cache, 'interval', hours=12, id="serverjars")
|
||||
|
||||
@staticmethod
|
||||
def realtime():
|
||||
def realtime(self):
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
|
||||
@ -311,7 +311,69 @@ class TasksManager:
|
||||
'mem_percent': host_stats.get('mem_percent'),
|
||||
'mem_usage': host_stats.get('mem_usage')
|
||||
})
|
||||
time.sleep(4)
|
||||
|
||||
servers = self.controller.servers_list
|
||||
servers_ping = []
|
||||
for srv in servers:
|
||||
server_data = srv.get('server_data_obj', False)
|
||||
if server_data:
|
||||
server_id = server_data.get('server_id', False)
|
||||
srv['raw_ping_result'] = self.controller.stats.get_raw_server_stats(server_id)
|
||||
if ("{}".format(srv['raw_ping_result'].get('icon')) == "b''"):
|
||||
srv['raw_ping_result']['icon'] = False
|
||||
|
||||
servers_ping.append({
|
||||
'id': srv['raw_ping_result'].get('id'),
|
||||
'started': srv['raw_ping_result'].get('started'),
|
||||
'running': srv['raw_ping_result'].get('running'),
|
||||
'cpu': srv['raw_ping_result'].get('cpu'),
|
||||
'mem': srv['raw_ping_result'].get('mem'),
|
||||
'mem_percent': srv['raw_ping_result'].get('mem_percent'),
|
||||
'world_name': srv['raw_ping_result'].get('world_name'),
|
||||
'world_size': srv['raw_ping_result'].get('world_size'),
|
||||
'server_port': srv['raw_ping_result'].get('server_port'),
|
||||
'int_ping_results': srv['raw_ping_result'].get('int_ping_results'),
|
||||
'online': srv['raw_ping_result'].get('online'),
|
||||
'max': srv['raw_ping_result'].get('max'),
|
||||
'players': srv['raw_ping_result'].get('players'),
|
||||
'desc': srv['raw_ping_result'].get('desc'),
|
||||
'version': srv['raw_ping_result'].get('version'),
|
||||
'icon': srv['raw_ping_result'].get('icon')
|
||||
})
|
||||
if (len(websocket_helper.clients) > 0):
|
||||
websocket_helper.broadcast_page_params(
|
||||
'/panel/server_detail',
|
||||
{
|
||||
'id': str(server_id)
|
||||
},
|
||||
'update_server_details',
|
||||
{
|
||||
'id': srv['raw_ping_result'].get('id'),
|
||||
'started': srv['raw_ping_result'].get('started'),
|
||||
'running': srv['raw_ping_result'].get('running'),
|
||||
'cpu': srv['raw_ping_result'].get('cpu'),
|
||||
'mem': srv['raw_ping_result'].get('mem'),
|
||||
'mem_percent': srv['raw_ping_result'].get('mem_percent'),
|
||||
'world_name': srv['raw_ping_result'].get('world_name'),
|
||||
'world_size': srv['raw_ping_result'].get('world_size'),
|
||||
'server_port': srv['raw_ping_result'].get('server_port'),
|
||||
'int_ping_results': srv['raw_ping_result'].get('int_ping_results'),
|
||||
'online': srv['raw_ping_result'].get('online'),
|
||||
'max': srv['raw_ping_result'].get('max'),
|
||||
'players': srv['raw_ping_result'].get('players'),
|
||||
'desc': srv['raw_ping_result'].get('desc'),
|
||||
'version': srv['raw_ping_result'].get('version'),
|
||||
'icon': srv['raw_ping_result'].get('icon')
|
||||
}
|
||||
)
|
||||
|
||||
if (len(servers_ping) > 0) & (len(websocket_helper.clients) > 0):
|
||||
try:
|
||||
websocket_helper.broadcast_page('/panel/dashboard', 'update_server_status', servers_ping)
|
||||
websocket_helper.broadcast_page('/status', 'update_server_status', servers_ping)
|
||||
except:
|
||||
console.warning("Can't broadcast server status to websocket")
|
||||
time.sleep(5)
|
||||
|
||||
def log_watcher(self):
|
||||
self.controller.servers.check_for_old_logs()
|
||||
|
@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@ -13,7 +14,8 @@
|
||||
<link rel="stylesheet" href="/static/assets/vendors/ti-icons/css/themify-icons.css">
|
||||
<link rel="stylesheet" href="/static/assets/vendors/typicons/typicons.css">
|
||||
<link rel="stylesheet" href="/static/assets/vendors/fontawesome5/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css"/>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css" />
|
||||
<link rel="stylesheet" href="/static/assets/vendors/css/vendor.bundle.base.css">
|
||||
<link rel="stylesheet" href="/static/assets/css/crafty.css">
|
||||
|
||||
@ -32,9 +34,9 @@
|
||||
<link rel="alternate icon" href="/static/assets/images/favicon.png" />
|
||||
<link rel="stylesheet" href="/static/assets/css/crafty.css">
|
||||
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body class="dark-theme">
|
||||
<body class="dark-theme">
|
||||
<div class="container-scroller">
|
||||
<!-- partial:partials/_navbar.html -->
|
||||
<nav class="navbar default-layout col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
|
||||
@ -51,7 +53,8 @@
|
||||
|
||||
{% include notify.html %}
|
||||
|
||||
<button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="offcanvas">
|
||||
<button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button"
|
||||
data-toggle="offcanvas">
|
||||
<span class="mdi mdi-menu"></span>
|
||||
</button>
|
||||
</div>
|
||||
@ -87,6 +90,7 @@
|
||||
top: 70px;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.notification {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
@ -103,20 +107,24 @@
|
||||
z-index: 999;
|
||||
top: 0px;
|
||||
}
|
||||
|
||||
.notification.active {
|
||||
right: 0rem;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.notification.remove {
|
||||
right: 0rem;
|
||||
opacity: 0.1;
|
||||
top: -2rem;
|
||||
}
|
||||
|
||||
.notification p {
|
||||
margin: 0px;
|
||||
width: calc(160.8px - 16px);
|
||||
z-index: inherit;
|
||||
}
|
||||
|
||||
.notification span {
|
||||
position: absolute;
|
||||
right: 0.5rem;
|
||||
@ -138,6 +146,7 @@
|
||||
<script src="/static/assets/js/shared/misc.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.4.0/bootbox.min.js"></script>
|
||||
<script type="text/javascript" src="/static/assets/js/motd.js"></script>
|
||||
|
||||
<script>
|
||||
$.extend($.fn.dataTable.defaults, {
|
||||
@ -156,9 +165,9 @@
|
||||
})
|
||||
|
||||
// Notify
|
||||
$(document).ready(function(){
|
||||
$("#notificationDropdown").click(function(){
|
||||
$.get("/ajax/announcements", function(data){
|
||||
$(document).ready(function () {
|
||||
$("#notificationDropdown").click(function () {
|
||||
$.get("/ajax/announcements", function (data) {
|
||||
console.log(data);
|
||||
bootbox.alert({
|
||||
title: "Notifications",
|
||||
@ -178,7 +187,7 @@
|
||||
pageQueryParams = 'page_query_params=' + encodeURIComponent(location.search)
|
||||
page = 'page=' + encodeURIComponent(location.pathname)
|
||||
var wsInternal = new WebSocket('wss://' + location.host + '/ws?' + page + '&' + pageQueryParams);
|
||||
wsInternal.onopen = function() {
|
||||
wsInternal.onopen = function () {
|
||||
console.log('opened WebSocket connection:', wsInternal)
|
||||
};
|
||||
wsInternal.onmessage = function (rawMessage) {
|
||||
@ -222,30 +231,34 @@
|
||||
var webSocket;
|
||||
// {% end%}
|
||||
|
||||
if (webSocket) {
|
||||
if (webSocket) {
|
||||
webSocket.on('send_start_error', function (start_error) {
|
||||
var x = document.querySelector('.bootbox');
|
||||
if(x){
|
||||
x.remove()}
|
||||
if (x) {
|
||||
x.remove()
|
||||
}
|
||||
var x = document.querySelector('.modal-backdrop');
|
||||
if(x){
|
||||
x.remove()}
|
||||
if (x) {
|
||||
x.remove()
|
||||
}
|
||||
bootbox.alert({
|
||||
message: start_error.error,
|
||||
callback: function () {
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
if (webSocket) {
|
||||
webSocket.on('send_logs_bootbox', function (server_id) {
|
||||
var x = document.querySelector('.bootbox');
|
||||
if(x){
|
||||
x.remove()}
|
||||
if (x) {
|
||||
x.remove()
|
||||
}
|
||||
var x = document.querySelector('.modal-backdrop');
|
||||
if(x){
|
||||
x.remove()}
|
||||
if (x) {
|
||||
x.remove()
|
||||
}
|
||||
bootbox.alert({
|
||||
title: "{{ translate('notify', 'downloadLogs', data['lang']) }}",
|
||||
message: "{{ translate('notify', 'finishedPreparing', data['lang']) }}",
|
||||
@ -255,22 +268,24 @@ if (webSocket) {
|
||||
className: 'btn-info'
|
||||
}
|
||||
},
|
||||
callback: function(){
|
||||
callback: function () {
|
||||
console.log("in callback")
|
||||
location.href="/panel/download_support_package";
|
||||
location.href = "/panel/download_support_package";
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (webSocket) {
|
||||
webSocket.on('send_eula_bootbox', function (server_id) {
|
||||
var x = document.querySelector('.bootbox');
|
||||
if(x){
|
||||
x.remove()}
|
||||
if (x) {
|
||||
x.remove()
|
||||
}
|
||||
var x = document.querySelector('.modal-backdrop');
|
||||
if(x){
|
||||
x.remove()}
|
||||
if (x) {
|
||||
x.remove()
|
||||
}
|
||||
bootbox.confirm({
|
||||
title: '{% raw translate("error", "eulaTitle", data['lang']) %}',
|
||||
message: '{% raw translate("error", "eulaMsg", data['lang']) %} <br><br><a href="https://account.mojang.com/documents/minecraft_eula" target="_blank">EULA</a><br><br>{% raw translate("error", "eulaAgree", data['lang']) %}',
|
||||
@ -285,31 +300,29 @@ if (webSocket) {
|
||||
}
|
||||
},
|
||||
callback: function (result) {
|
||||
if(result == true){
|
||||
if (result == true) {
|
||||
eulaAgree(server_id.id)
|
||||
}
|
||||
else {
|
||||
location.reload()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function eulaAgree (server_id, command){
|
||||
<!-- this getCookie function is in base.html-->
|
||||
function eulaAgree(server_id, command) {
|
||||
//< !--this getCookie function is in base.html-- >
|
||||
var token = getCookie("_xsrf");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
url: '/ajax/eula?id='+ server_id,
|
||||
success: function(data){
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/ajax/eula?id=' + server_id,
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
location.reload();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -332,7 +345,7 @@ if (webSocket) {
|
||||
closeEl.style.lineHeight = '20px';
|
||||
closeEl.style.cursor = 'pointer';
|
||||
|
||||
closeEl.addEventListener('click', function () {this.parentElement.style.display='none';});
|
||||
closeEl.addEventListener('click', function () { this.parentElement.style.display = 'none'; });
|
||||
|
||||
var parentEl = document.createElement('div');
|
||||
|
||||
@ -360,7 +373,7 @@ if (webSocket) {
|
||||
paragraphEl.textContent = message;
|
||||
|
||||
closeEl.innerHTML = '×';
|
||||
closeEl.addEventListener('click', function () {closeNotification(this)});
|
||||
closeEl.addEventListener('click', function () { closeNotification(this) });
|
||||
|
||||
var parentEl = document.createElement('div');
|
||||
parentEl.appendChild(paragraphEl);
|
||||
@ -388,25 +401,26 @@ if (webSocket) {
|
||||
}
|
||||
webSocket.on('notification', notify);
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#support_logs').click(function(){
|
||||
$(document).ready(function () {
|
||||
$('#support_logs').click(function () {
|
||||
var dialog = bootbox.dialog({
|
||||
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i>{{ translate('notify', 'preparingLogs', data['lang']) }}</p>',
|
||||
closeButton: false
|
||||
});
|
||||
setTimeout(function(){
|
||||
location.href="/panel/support_logs";
|
||||
setTimeout(function () {
|
||||
location.href = "/panel/support_logs";
|
||||
}, 6000);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{% block js %}
|
||||
<!-- Custom js for this page -->
|
||||
<!-- End custom js for this page -->
|
||||
<!-- Custom js for base.html page partial pages -->
|
||||
<!-- End custom js for base.html page -->
|
||||
{% end %}
|
||||
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Blank Page{% end %}
|
||||
|
@ -1,8 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Activity Logs{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Contribute{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Credits{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<meta http-equiv="refresh" content="60">
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard', data['lang']) }}{% end %}
|
||||
@ -29,16 +28,21 @@
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="d-flex">
|
||||
<div class="wrapper">
|
||||
<h5 class="mb-1 font-weight-medium text-primary"> {{ translate('dashboard', 'host', data['lang']) }}</h5>
|
||||
<h5 class="mb-1 font-weight-medium text-primary"> {{ translate('dashboard', 'host', data['lang']) }}
|
||||
</h5>
|
||||
<h3 class="mb-0 font-weight-semibold"> <i class="fas fa-chart-line"></i></h3>
|
||||
|
||||
</div>
|
||||
<div class="wrapper my-auto ml-auto ml-lg-4">
|
||||
<p id="cpu_data" class="mb-0 text-success" data-toggle="tooltip" data-placement="top" data-html="true" title="{% raw translate('dashboard', 'cpuCores', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cores') }} <br /> {% raw translate('dashboard', 'cpuCurFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cur_freq') }} <br /> {% raw translate('dashboard', 'cpuMaxFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_max_freq') }}" >
|
||||
{{ translate('dashboard', 'cpuUsage', data['lang']) }}: <span id="cpu_usage">{{ data.get('hosts_data').get('cpu_usage') }}</span>
|
||||
<p id="cpu_data" class="mb-0 text-success" data-toggle="tooltip" data-placement="top" data-html="true"
|
||||
title="{% raw translate('dashboard', 'cpuCores', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cores') }} <br /> {% raw translate('dashboard', 'cpuCurFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cur_freq') }} <br /> {% raw translate('dashboard', 'cpuMaxFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_max_freq') }}">
|
||||
{{ translate('dashboard', 'cpuUsage', data['lang']) }}: <span id="cpu_usage">{{
|
||||
data.get('hosts_data').get('cpu_usage') }}</span>
|
||||
</p>
|
||||
<p id="mem_usage" class="mb-0 text-danger" data-toggle="tooltip" data-placement="top" title="{{ translate('dashboard', 'memUsage', data['lang']) }}: {{ data.get('hosts_data').get('mem_usage') }}" >
|
||||
{{ translate('dashboard', 'memUsage', data['lang']) }}: <span id="mem_percent">{{ data.get('hosts_data').get('mem_percent') }}%</span>
|
||||
<p id="mem_usage" class="mb-0 text-danger" data-toggle="tooltip" data-placement="top"
|
||||
title="{{ translate('dashboard', 'memUsage', data['lang']) }}: {{ data.get('hosts_data').get('mem_usage') }}">
|
||||
{{ translate('dashboard', 'memUsage', data['lang']) }}: <span id="mem_percent">{{
|
||||
data.get('hosts_data').get('mem_percent') }}%</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -46,20 +50,24 @@
|
||||
<div class="col-lg-4 col-md-6 mt-md-0 mt-4">
|
||||
<div class="d-flex">
|
||||
<div class="wrapper">
|
||||
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'servers', data['lang']) }}</h5>
|
||||
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'servers', data['lang']) }}
|
||||
</h5>
|
||||
<h3 class="mb-0 font-weight-semibold">{{ data['server_stats']['total'] }}</h3>
|
||||
|
||||
</div>
|
||||
<div class="wrapper my-auto ml-auto ml-lg-4">
|
||||
<p class="mb-0 text-success">{{ data['server_stats']['running'] }} {{ translate('dashboard', 'online', data['lang']).lower() }}</p>
|
||||
<p class="mb-0 text-warning"> {{ data['server_stats']['stopped'] }} {{ translate('dashboard', 'offline', data['lang']).lower() }}</p>
|
||||
<p class="mb-0 text-success">{{ data['server_stats']['running'] }} {{ translate('dashboard', 'online',
|
||||
data['lang']).lower() }}</p>
|
||||
<p class="mb-0 text-warning"> {{ data['server_stats']['stopped'] }} {{ translate('dashboard',
|
||||
'offline', data['lang']).lower() }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6 mt-md-0 mt-4">
|
||||
<div class="d-flex">
|
||||
<div class="wrapper">
|
||||
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'players', data['lang']) }}</h5>
|
||||
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'players', data['lang']) }}
|
||||
</h5>
|
||||
<h3 class="mb-0 font-weight-semibold">{{ data['num_players'] }}</h3>
|
||||
|
||||
</div>
|
||||
@ -79,11 +87,15 @@
|
||||
<div class="col-md-12 col-lg-12 grid-margin stretch-card">
|
||||
<div class="card">
|
||||
<div class="card-header header-sm d-flex justify-content-between align-items-center">
|
||||
<h4 class="card-title"><i class="fas fa-server"></i> {{ translate('dashboard', 'allServers', data['lang']) }}</h4>
|
||||
<h4 class="card-title"><i class="fas fa-server"></i> {{ translate('dashboard', 'allServers',
|
||||
data['lang']) }}</h4>
|
||||
{% if len(data['servers']) > 0 %}
|
||||
<span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}", data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}", data-placement="top"></span>
|
||||
<span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}" ,
|
||||
data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" ,
|
||||
data-placement="top"></span>
|
||||
{% end %}
|
||||
<div><a class="nav-link" href="/server/step1"><i class="fas fa-plus-circle"></i> {{ translate('dashboard', 'newServer', data['lang']) }}</a></div>
|
||||
<div><a class="nav-link" href="/server/step1"><i class="fas fa-plus-circle"></i> {{
|
||||
translate('dashboard', 'newServer', data['lang']) }}</a></div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
@ -92,7 +104,8 @@
|
||||
<div style="text-align: center; color: grey;">
|
||||
<h1>{{ translate('dashboard', 'welcome', data['lang']) }}</h1>
|
||||
<br>
|
||||
<h7>{{ translate('dashboard', 'no-servers', data['lang']) }} {{ translate('dashboard', 'newServer', data['lang']) }}.</h7>
|
||||
<h7>{{ translate('dashboard', 'no-servers', data['lang']) }} {{ translate('dashboard', 'newServer',
|
||||
data['lang']) }}.</h7>
|
||||
</div>
|
||||
|
||||
{% end %}
|
||||
@ -122,23 +135,36 @@
|
||||
<td id="controls{{server['server_data']['server_id']}}" class="actions_serverlist">
|
||||
{% if server['user_command_permission'] %}
|
||||
{% if server['stats']['running'] %}
|
||||
<a class="stop_button" data-id="{{server['server_data']['server_id']}}" data-toggle="tooltip" title={{ translate('dashboard', 'stop', data['lang']) }}> <i class="fas fa-stop"></i></a>
|
||||
<a class="restart_button" data-id="{{server['server_data']['server_id']}}" data-toggle="tooltip" title={{ translate('dashboard', 'restart', data['lang']) }}> <i class="fas fa-sync"></i></a>
|
||||
<a class="kill_button" data-id="{{server['server_data']['server_id']}}" class="kill_button" data-toggle="tooltip" title={{ translate('dashboard', 'kill', data['lang']) }}> <i class="fas fa-skull"></i></a>
|
||||
<a class="stop_button" data-id="{{server['server_data']['server_id']}}" data-toggle="tooltip"
|
||||
title={{ translate('dashboard', 'stop' , data['lang']) }}> <i class="fas fa-stop"></i></a>
|
||||
<a class="restart_button" data-id="{{server['server_data']['server_id']}}" data-toggle="tooltip"
|
||||
title={{ translate('dashboard', 'restart' , data['lang']) }}> <i class="fas fa-sync"></i></a>
|
||||
|
||||
<a class="kill_button" data-id="{{server['server_data']['server_id']}}" class="kill_button"
|
||||
data-toggle="tooltip" title={{ translate('dashboard', 'kill' , data['lang']) }}> <i
|
||||
class="fas fa-skull"></i></a>
|
||||
{% elif server['stats']['updating']%}
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="">{{ translate('serverTerm', 'updating', data['lang']) }}</i></a>
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="">{{ translate('serverTerm', 'updating',
|
||||
data['lang']) }}</i></a>
|
||||
{% elif server['stats']['waiting_start']%}
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="" title={{ translate('dashboard', 'delay-explained', data['lang'])}}>{{ translate('dashboard', 'starting', data['lang']) }}</i></a>
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="" title={{
|
||||
translate('dashboard', 'delay-explained' , data['lang'])}}>{{ translate('dashboard', 'starting',
|
||||
data['lang']) }}</i></a>
|
||||
{% else %}
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="play_button"><i class="fas fa-play" data-toggle="tooltip" title={{ translate('dashboard', 'start', data['lang']) }}></i></a>
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="clone_button"> <i class="fas fa-clone" data-toggle="tooltip" title={{ translate('dashboard', 'clone', data['lang']) }}></i></a>
|
||||
<a class="kill_button" data-id="{{server['server_data']['server_id']}}" class="kill_button" data-toggle="tooltip" title={{ translate('dashboard', 'kill', data['lang']) }}> <i class="fas fa-skull"></i></a>
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="play_button"><i class="fas fa-play"
|
||||
data-toggle="tooltip" title={{ translate('dashboard', 'start' , data['lang']) }}></i></a>
|
||||
<a data-id="{{server['server_data']['server_id']}}" class="clone_button"> <i class="fas fa-clone"
|
||||
data-toggle="tooltip" title={{ translate('dashboard', 'clone' , data['lang']) }}></i></a>
|
||||
<a class="kill_button" data-id="{{server['server_data']['server_id']}}" class="kill_button"
|
||||
data-toggle="tooltip" title={{ translate('dashboard', 'kill' , data['lang']) }}> <i
|
||||
class="fas fa-skull"></i></a>
|
||||
{% end %}
|
||||
{% end %}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="{{server['stats']['cpu']}}">
|
||||
<td id="server_cpu_{{server['server_data']['server_id']}}">
|
||||
<div class="progress mb-1" data-toggle="tooltip" data-placement="top"
|
||||
title="{{server['stats']['cpu']}}">
|
||||
<div class="progress-bar
|
||||
{% if server['stats']['cpu'] <= 33 %}
|
||||
bg-success
|
||||
@ -147,13 +173,15 @@
|
||||
{% else %}
|
||||
bg-danger
|
||||
{% end %}
|
||||
" role="progressbar" style="width: {{server['stats']['cpu']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
" role="progressbar" style="width: {{server['stats']['cpu']}}%" aria-valuenow="0"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{server['stats']['cpu']}}%
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="{{server['stats']['mem']}}">
|
||||
<td id="server_mem_{{server['server_data']['server_id']}}">
|
||||
<div class="progress mb-1" data-toggle="tooltip" data-placement="top"
|
||||
title="{{server['stats']['mem']}}">
|
||||
<div class="progress-bar
|
||||
{% if server['stats']['mem_percent'] <= 33 %}
|
||||
bg-success
|
||||
@ -162,7 +190,8 @@
|
||||
{% else %}
|
||||
bg-danger
|
||||
{% end %}
|
||||
" role="progressbar" style="width: {{server['stats']['mem_percent']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
" role="progressbar" style="width: {{server['stats']['mem_percent']}}%" aria-valuenow="0"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{server['stats']['mem_percent']}}% -
|
||||
|
||||
@ -172,12 +201,13 @@
|
||||
{{server['stats']['mem']}}
|
||||
{% end %}
|
||||
</td>
|
||||
<td>
|
||||
<td id="server_world_{{server['server_data']['server_id']}}">
|
||||
{{ server['stats']['world_name'] }} : {{ server['stats']['world_size'] }}
|
||||
</td>
|
||||
<td>
|
||||
<td id="server_desc_{{server['server_data']['server_id']}}">
|
||||
{% if server['stats']['int_ping_results'] %}
|
||||
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max', data['lang']) }}<br />
|
||||
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max',
|
||||
data['lang']) }} <br />
|
||||
|
||||
{% if server['stats']['desc'] != 'False' %}
|
||||
{{ server['stats']['desc'] }} <br />
|
||||
@ -189,11 +219,13 @@
|
||||
{% end %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<td id="server_running_status_{{server['server_data']['server_id']}}">
|
||||
{% if server['stats']['running'] %}
|
||||
<i class="fas fa-thumbs-up"></i> <span class="text-success">{{ translate('dashboard', 'online', data['lang']) }}</span>
|
||||
<i class="fas fa-thumbs-up"></i> <span class="text-success">{{ translate('dashboard', 'online',
|
||||
data['lang']) }}</span>
|
||||
{% else %}
|
||||
<i class="fas fa-thumbs-down"></i> <span class="text-danger">{{ translate('dashboard', 'offline', data['lang']) }}</span>
|
||||
<i class="fas fa-thumbs-down"></i> <span class="text-danger">{{ translate('dashboard', 'offline',
|
||||
data['lang']) }}</span>
|
||||
{% end %}
|
||||
</td>
|
||||
</tr>
|
||||
@ -212,84 +244,191 @@
|
||||
</div>
|
||||
<!-- content-wrapper ends -->
|
||||
<style>
|
||||
.popover-body{
|
||||
color: white !important;;
|
||||
}
|
||||
.popover-body {
|
||||
color: white !important;
|
||||
;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
{% end %}
|
||||
|
||||
{% block js %}
|
||||
|
||||
<script src="/static/assets/js/motd.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
function display_motd() {
|
||||
var all_motds = Array.from(document.getElementsByClassName('input_motd'));
|
||||
for (element of all_motds) {
|
||||
initParser(element.id, element.id);
|
||||
};
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$('[data-toggle="popover"]').popover();
|
||||
if($(window).width() < 1000){
|
||||
if ($(window).width() < 1000) {
|
||||
$('.too_small').popover("show");
|
||||
}
|
||||
|
||||
});
|
||||
$(window).ready(function(){
|
||||
$('body').click(function(){
|
||||
});
|
||||
$(window).ready(function () {
|
||||
$('body').click(function () {
|
||||
$('.too_small').popover("hide");
|
||||
});
|
||||
});
|
||||
$(window).resize(function() {
|
||||
});
|
||||
$(window).resize(function () {
|
||||
// This will execute whenever the window is resized
|
||||
if($(window).width() < 1000){
|
||||
if ($(window).width() < 1000) {
|
||||
$('.too_small').popover("show");
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$('.too_small').popover("hide");
|
||||
} // New width
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function send_command (server_id, command){
|
||||
function send_command(server_id, command) {
|
||||
/* this getCookie function is in base.html */
|
||||
var token = getCookie("_xsrf");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/server/command?command=' + command + '&id=' + server_id,
|
||||
success: function(data){
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
setTimeout(function(){
|
||||
if (command != 'start_server'){
|
||||
/*setTimeout(function () {
|
||||
if (command != 'start_server') {
|
||||
location.reload();
|
||||
}
|
||||
}, 10000);
|
||||
|
||||
}, 10000);*/
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function send_kill (server_id){
|
||||
function send_kill(server_id) {
|
||||
/* this getCookie function is in base.html */
|
||||
var token = getCookie("_xsrf");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/ajax/kill?id=' + server_id,
|
||||
success: function(data){
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
setTimeout(function(){
|
||||
/*setTimeout(function () {
|
||||
location.reload();
|
||||
}, 10000);
|
||||
|
||||
}, 10000);*/
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
function update_one_server_status(server) {
|
||||
server_cpu = document.getElementById('server_cpu_' + server.id);
|
||||
server_mem = document.getElementById('server_mem_' + server.id);
|
||||
server_world = document.getElementById('server_world_' + server.id);
|
||||
server_desc = document.getElementById('server_desc_' + server.id);
|
||||
server_online_status = document.getElementById('server_running_status_' + server.id);
|
||||
|
||||
console.log("Received Data : " + server.id + ": " + server);
|
||||
/* TODO Update each element */
|
||||
|
||||
/* Update CPU */
|
||||
cpu_status = "";
|
||||
if (server.cpu <= 33)
|
||||
{
|
||||
cpu_status = "bg-success";
|
||||
}
|
||||
else if (server.cpu > 33 && server.cpu <= 66)
|
||||
{
|
||||
cpu_status = "bg-warning";
|
||||
}
|
||||
else
|
||||
{
|
||||
cpu_status = "bg-danger";
|
||||
}
|
||||
server_cpu.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="`+ server.cpu +`"><div class="progress-bar `+ cpu_status + `" role="progressbar" style="width: `+ server.cpu + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>`+ server.cpu +`%`;
|
||||
|
||||
|
||||
/* Update Memory */
|
||||
mem_status = "";
|
||||
total_mem = "";
|
||||
if (server.mem_percent <= 33)
|
||||
{
|
||||
mem_status = "bg-success";
|
||||
} else if (server.mem_percent > 33 && server.mem_percent <= 66)
|
||||
{
|
||||
mem_status = "bg-warning";
|
||||
}
|
||||
else
|
||||
{
|
||||
mem_status = "bg-danger";
|
||||
}
|
||||
|
||||
if (server.mem == 0)
|
||||
{
|
||||
total_mem = "0 MB";
|
||||
}
|
||||
else
|
||||
{
|
||||
total_mem = server.mem;
|
||||
}
|
||||
|
||||
server_mem.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="`+ server_mem +`"><div class="progress-bar `+ mem_status + `" role="progressbar" style="width: `+ server.mem_percent + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>`+ server.mem_percent +`% - ` + total_mem;
|
||||
|
||||
/* Update World Infos */
|
||||
server_world.innerHTML = server.world_name + ` : ` + server.world_size
|
||||
|
||||
/* Update Server Infos */
|
||||
if (server.int_ping_results) {
|
||||
/* Update Players */
|
||||
if (server.players) {
|
||||
server_desc.innerHTML = server.online + ` / ` + server.max + ` {{ translate('dashboard', 'max', data['lang']) }}<br />`
|
||||
|
||||
server_infos = "";
|
||||
server_infos = server.online + " / " + server.max + "{{ translate('dashboard', 'max', data['lang']) }}<br />"
|
||||
}
|
||||
|
||||
/* Update Motd */
|
||||
var motd = "";
|
||||
if (server.desc) {
|
||||
motd = `<span id="input_motd_` + server.id + `" class="input_motd">` + server.desc + `</span>`;
|
||||
server_infos = server_infos + motd + "<br />";
|
||||
}
|
||||
|
||||
/* Version */
|
||||
if (server.version) {
|
||||
server_infos = server_infos + server.version
|
||||
}
|
||||
server_desc.innerHTML = server_infos;
|
||||
}
|
||||
|
||||
/* 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>`;
|
||||
}
|
||||
else {
|
||||
online_status = `<span class="text-danger"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', data['lang'])}}</span>`;
|
||||
}
|
||||
server_online_status.innerHTML = online_status;
|
||||
}
|
||||
|
||||
function update_servers_status(data) {
|
||||
console.log(data);
|
||||
for (server of data) {
|
||||
update_one_server_status(server);
|
||||
}
|
||||
display_motd();
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
console.log('ready for JS!')
|
||||
|
||||
$( ".play_button" ).click(function() {
|
||||
$(".play_button").click(function () {
|
||||
server_id = $(this).attr("data-id");
|
||||
send_command(server_id, 'start_server');
|
||||
bootbox.alert({
|
||||
@ -299,7 +438,7 @@ $( document ).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$( ".stop_button" ).click(function() {
|
||||
$(".stop_button").click(function () {
|
||||
console.log("stopping server");
|
||||
server_id = $(this).attr("data-id");
|
||||
send_command(server_id, 'stop_server');
|
||||
@ -310,7 +449,7 @@ $( document ).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$( ".restart_button" ).click(function() {
|
||||
$(".restart_button").click(function () {
|
||||
server_id = $(this).attr("data-id");
|
||||
send_command(server_id, 'restart_server');
|
||||
bootbox.alert({
|
||||
@ -319,7 +458,7 @@ $( document ).ready(function() {
|
||||
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> {% raw translate("dashboard", "bePatientRestart", data['lang']) %} </div>'
|
||||
});
|
||||
});
|
||||
$( ".kill_button" ).click(function() {
|
||||
$(".kill_button").click(function () {
|
||||
server_id = $(this).attr("data-id");
|
||||
bootbox.confirm({
|
||||
message: "This will kill the server process and all it's subprocesses. Killing a process can potentially corrupt files. Only do this in extreme circumstances. Are you sure you would like to continue?",
|
||||
@ -334,21 +473,21 @@ $( document ).ready(function() {
|
||||
}
|
||||
},
|
||||
callback: function (result) {
|
||||
if(result){
|
||||
if (result) {
|
||||
send_kill(server_id);
|
||||
var dialog = bootbox.dialog({
|
||||
title: '{% raw translate("dashboard", "killing", data['lang']) %}',
|
||||
message: '<p><i class="fa fa-spin fa-spinner"></i> Loading...</p>'
|
||||
});
|
||||
});
|
||||
|
||||
dialog.init(function(){
|
||||
setTimeout(function(){
|
||||
dialog.init(function () {
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 15000);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
if (webSocket) {
|
||||
cpu_data = document.getElementById('cpu_data');
|
||||
@ -377,17 +516,21 @@ dialog.init(function(){
|
||||
var dataId = updateButton.server_id;
|
||||
var string = updateButton.string
|
||||
var id = id.concat(updateButton.server_id);
|
||||
if (updateButton.isUpdating){
|
||||
if (updateButton.isUpdating) {
|
||||
console.log(updateButton.isUpdating)
|
||||
document.getElementById(id).innerHTML = string;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
window.location.reload()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$( ".clone_button" ).click(function() {
|
||||
if (webSocket) {
|
||||
webSocket.on('update_server_status', update_servers_status);
|
||||
}
|
||||
|
||||
$(".clone_button").click(function () {
|
||||
server_id = $(this).attr("data-id");
|
||||
send_command(server_id, 'clone_server');
|
||||
bootbox.alert({
|
||||
@ -397,7 +540,7 @@ dialog.init(function(){
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% end %}
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('panelConfig', 'pageTitle', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('rolesConfig', 'pageTitle', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Edit User{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Edit User API Keys{% end %}
|
||||
|
@ -5,52 +5,48 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-4 mr-2">
|
||||
{% if data['server_stats']['running'] %}
|
||||
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span class="text-success">{{ translate('serverStats', 'online', data['lang']) }}</span><br />
|
||||
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-success">{{ translate('serverStats', 'online', data['lang']) }}</span><br />
|
||||
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started">{{ data['server_stats']['started'] }} ({{ translate('serverStats', 'serverTime', data['lang']) }})</span><br />
|
||||
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime">{{ translate('serverStats', 'errorCalculatingUptime', data['lang']) }}</span>
|
||||
{% else %}
|
||||
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
|
||||
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
|
||||
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span>
|
||||
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
|
||||
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started" class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
|
||||
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime" class="text-danger">{{ translate('serverStats', 'offline', data['lang']) }}</span>
|
||||
{% end %}
|
||||
<br>
|
||||
<b>{{ translate('serverStats', 'serverTimeZone', data['lang']) }}:</b> <span class="text-info">{{ data['serverTZ'] }}</span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mr-2">
|
||||
<b>{{ translate('serverStats', 'cpuUsage', data['lang']) }}:</b> {{ data['server_stats']['cpu'] }}% <br />
|
||||
<b>{{ translate('serverStats', 'memUsage', data['lang']) }}:</b> {{ data['server_stats']['mem'] }} <br />
|
||||
<b>{{ translate('serverStats', 'cpuUsage', data['lang']) }}:</b> <span id="cpu">{{ data['server_stats']['cpu'] }}%</span> <br />
|
||||
<b>{{ translate('serverStats', 'memUsage', data['lang']) }}:</b> <span id="mem" >{{ data['server_stats']['mem'] }}</span> <br />
|
||||
{% if data['server_stats']['int_ping_results'] %}
|
||||
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> {{ data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}<br />
|
||||
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players" >{{ data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}</span><br />
|
||||
{% else %}
|
||||
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> 0/0<br />
|
||||
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players" >0/0</span><br />
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mr-2">
|
||||
{% if data['server_stats']['version'] != 'False' %}
|
||||
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> {{ data['server_stats']['version'] }} <br />
|
||||
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ data['server_stats']['version'] }}</span><br />
|
||||
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span id="input_motd" class="input_motd">{{ data['server_stats']['desc'] }}</span> <br />
|
||||
{% else %}
|
||||
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> {{ translate('serverStats', 'unableToConnect', data['lang']) }} <br />
|
||||
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> {{ translate('serverStats', 'unableToConnect', data['lang']) }} <br />
|
||||
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br />
|
||||
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span id="input_motd" class="input_motd">{{ translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br />
|
||||
{% end %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/assets/vendors/moment/moment.min.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script src="/static/assets/js/motd.js"></script>
|
||||
<script>
|
||||
|
||||
function durationToHumanizedString (duration) {
|
||||
function durationToHumanizedString(duration) {
|
||||
duration._data.months += duration._data.years * 12;
|
||||
// 30.45833333333 = average month length, calculate with (31+28.5+31+30+31+30+31+31+30+31+30+31) / 12
|
||||
duration._data.days += duration._data.months * 30.45833333333;
|
||||
@ -80,20 +76,21 @@
|
||||
return output;
|
||||
}
|
||||
|
||||
document.body.onload = (() => {
|
||||
|
||||
console.log('calculateTime');
|
||||
let uptime = document.querySelector('#uptime');
|
||||
let started = document.querySelector('#started');
|
||||
let startedUTC;
|
||||
let startedLocal;
|
||||
let uptimeLoop;
|
||||
|
||||
document.body.onload = (() => {
|
||||
console.log('calculateTime');
|
||||
|
||||
if (started != null) {
|
||||
startedUTC = '{{ data['server_stats']['started'] }}';
|
||||
if (startedUTC != 'False') {
|
||||
console.log('started utc:', startedUTC);
|
||||
startedUTC = moment.utc(startedUTC, 'YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
let browserUTCOffset = moment().utcOffset(); // This is in minutes
|
||||
var browserUTCOffset = moment().utcOffset(); // This is in minutes
|
||||
|
||||
startedLocal = startedUTC.utcOffset(browserUTCOffset);
|
||||
startedLocalFormatted = startedLocal.format('YYYY-MM-DD HH:mm:ss');
|
||||
@ -104,23 +101,108 @@
|
||||
}
|
||||
|
||||
var calculateUptime = () => {
|
||||
var msdiff = moment()
|
||||
.diff(startedLocal);
|
||||
var msdiff = moment().diff(startedLocal);
|
||||
var diff = moment.duration(msdiff);
|
||||
|
||||
uptime.textContent = durationToHumanizedString(diff);
|
||||
}
|
||||
|
||||
if (uptime != null && started != null) {
|
||||
|
||||
console.log('startedLocal', startedLocal)
|
||||
if (startedLocal) {
|
||||
calculateUptime()
|
||||
var uptimeLoop = setInterval(calculateUptime, 1000)
|
||||
calculateUptime();
|
||||
uptimeLoop = setInterval(calculateUptime, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
initParser('input_motd', 'input_motd');
|
||||
|
||||
});
|
||||
|
||||
function update_server_details(server) {
|
||||
server_status = document.getElementById('status');
|
||||
server_started = document.getElementById('started');
|
||||
server_uptime = document.getElementById('uptime');
|
||||
server_cpu = document.getElementById('cpu');
|
||||
server_mem = document.getElementById('mem');
|
||||
server_players = document.getElementById('players');
|
||||
server_version = document.getElementById('version');
|
||||
server_input_motd = document.getElementById('input_motd');
|
||||
|
||||
/* TODO Update each element */
|
||||
if (server.running)
|
||||
{
|
||||
if (server.int_ping_results)
|
||||
{
|
||||
server_status.setAttribute("class", "text-success");
|
||||
server_status.innerHTML = `{{ translate('serverStats', 'online', data['lang']) }}`;
|
||||
}
|
||||
else
|
||||
{
|
||||
server_status.setAttribute("class", "text-warning");
|
||||
server_status.innerHTML = `{{ translate('serverStats', 'starting', data['lang']) }}`;
|
||||
}
|
||||
|
||||
startedUTC = server.started;
|
||||
startedUTC = moment.utc(startedUTC, 'YYYY-MM-DD HH:mm:ss');
|
||||
var browserUTCOffset = moment().utcOffset(); // This is in minutes
|
||||
startedLocal = startedUTC.utcOffset(browserUTCOffset);
|
||||
startedLocalFormatted = startedLocal.format('YYYY-MM-DD HH:mm:ss');
|
||||
server_started.setAttribute("class", "");
|
||||
server_started.innerHTML = startedLocalFormatted +` ({{ translate('serverStats', 'serverTime', data['lang']) }})`;
|
||||
server_uptime.setAttribute("class", "");
|
||||
if (!uptimeLoop) {
|
||||
var calculateUptime = () => {
|
||||
var msdiff = moment().diff(startedLocal);
|
||||
var diff = moment.duration(msdiff);
|
||||
uptime.textContent = durationToHumanizedString(diff);
|
||||
}
|
||||
uptimeLoop = setInterval(calculateUptime, 1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
server_status.setAttribute("class", "text-danger");
|
||||
server_status.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`;
|
||||
server_started.setAttribute("class", "text-danger");
|
||||
server_started.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`;
|
||||
clearInterval(uptimeLoop);
|
||||
uptimeLoop = null;
|
||||
server_uptime.setAttribute("class", "text-danger");
|
||||
server_uptime.innerHTML = `{{ translate('serverStats', 'offline', data['lang']) }}`;
|
||||
}
|
||||
|
||||
server_cpu.innerHTML = server.cpu + ` %`;
|
||||
server_mem.innerHTML = server.mem;
|
||||
|
||||
if (server.int_ping_results)
|
||||
{
|
||||
server_players.innerHTML = server.online + `/` + server.max;
|
||||
}
|
||||
else
|
||||
{
|
||||
server_players.innerHTML = `0/0`;
|
||||
}
|
||||
|
||||
if (server.version)
|
||||
{
|
||||
server_version.innerHTML = server.version;
|
||||
server_input_motd.innerHTML = server.desc;
|
||||
}
|
||||
else
|
||||
{
|
||||
server_version.innerHTML = `{{ translate('serverStats', 'unableToConnect', data['lang']) }}`;
|
||||
server_input_motd.innerHTML = `{{ translate('serverStats', 'unableToConnect', data['lang']) }}`;
|
||||
}
|
||||
|
||||
initParser('input_motd', 'input_motd');
|
||||
|
||||
}
|
||||
|
||||
$(window).ready(function () {
|
||||
console.log("ready!");
|
||||
|
||||
//if (webSocket) {
|
||||
webSocket.on('update_server_details', update_server_details);
|
||||
//}
|
||||
});
|
||||
</script>
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
@ -15,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>
|
||||
@ -42,86 +42,135 @@
|
||||
<input type="hidden" name="subpage" value="config">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="server_name">{{ translate('serverConfig', 'serverName', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverNameDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="server_name" id="server_name" value="{{ data['server_stats']['server_id']['server_name'] }}" placeholder="{{ translate('serverConfig', 'serverName', data['lang']) }}" required>
|
||||
<label for="server_name">{{ translate('serverConfig', 'serverName', data['lang']) }} <small
|
||||
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverNameDesc', data['lang']) }}</small>
|
||||
</label>
|
||||
<input type="text" class="form-control" name="server_name" id="server_name"
|
||||
value="{{ data['server_stats']['server_id']['server_name'] }}"
|
||||
placeholder="{{ translate('serverConfig', 'serverName', data['lang']) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{% if data['super_user'] %}
|
||||
<label for="server_path">{{ translate('serverConfig', 'serverPath', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverPathDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="server_path" id="server_path" value="{{ data['server_stats']['server_id']['path'] }}" placeholder="{{ translate('serverConfig', 'serverPath', data['lang']) }}" required>
|
||||
<label for="server_path">{{ translate('serverConfig', 'serverPath', data['lang']) }} <small
|
||||
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverPathDesc', data['lang']) }}</small>
|
||||
</label>
|
||||
<input type="text" class="form-control" name="server_path" id="server_path"
|
||||
value="{{ data['server_stats']['server_id']['path'] }}"
|
||||
placeholder="{{ translate('serverConfig', 'serverPath', data['lang']) }}" required>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="log_path">{{ translate('serverConfig', 'serverLogLocation', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverLogLocationDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="log_path" id="log_path" value="{{ data['server_stats']['server_id']['log_path'] }}" placeholder="{{ translate('serverConfig', 'serverLogLocation', data['lang']) }}" required>
|
||||
<label for="log_path">{{ translate('serverConfig', 'serverLogLocation', data['lang']) }} <small
|
||||
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverLogLocationDesc', data['lang'])
|
||||
}}</small> </label>
|
||||
<input type="text" class="form-control" name="log_path" id="log_path"
|
||||
value="{{ data['server_stats']['server_id']['log_path'] }}"
|
||||
placeholder="{{ translate('serverConfig', 'serverLogLocation', data['lang']) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="executable">{{ translate('serverConfig', 'serverExecutable', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverExecutableDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="executable" id="executable" value="{{ data['server_stats']['server_id']['executable'] }}" placeholder="{{ translate('serverConfig', 'serverExecutable', data['lang']) }}" required>
|
||||
<label for="executable">{{ translate('serverConfig', 'serverExecutable', data['lang']) }} <small
|
||||
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverExecutableDesc', data['lang'])
|
||||
}}</small> </label>
|
||||
<input type="text" class="form-control" name="executable" id="executable"
|
||||
value="{{ data['server_stats']['server_id']['executable'] }}"
|
||||
placeholder="{{ translate('serverConfig', 'serverExecutable', data['lang']) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="execution_command">{{ translate('serverConfig', 'serverExecutionCommand', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverExecutionCommandDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="execution_command" id="execution_command" value="{{ data['server_stats']['server_id']['execution_command'] }}" placeholder="{{ translate('serverConfig', 'serverExecutionCommand', data['lang']) }}" required>
|
||||
<label for="execution_command">{{ translate('serverConfig', 'serverExecutionCommand', data['lang']) }}
|
||||
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverExecutionCommandDesc',
|
||||
data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="execution_command" id="execution_command"
|
||||
value="{{ data['server_stats']['server_id']['execution_command'] }}"
|
||||
placeholder="{{ translate('serverConfig', 'serverExecutionCommand', data['lang']) }}" required>
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="stop_command">{{ translate('serverConfig', 'serverStopCommand', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverStopCommandDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="stop_command" id="stop_command" value="{{ data['server_stats']['server_id']['stop_command'] }}" placeholder="{{ translate('serverConfig', 'serverStopCommand', data['lang']) }}" required>
|
||||
<label for="stop_command">{{ translate('serverConfig', 'serverStopCommand', data['lang']) }} <small
|
||||
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverStopCommandDesc', data['lang'])
|
||||
}}</small> </label>
|
||||
<input type="text" class="form-control" name="stop_command" id="stop_command"
|
||||
value="{{ data['server_stats']['server_id']['stop_command'] }}"
|
||||
placeholder="{{ translate('serverConfig', 'serverStopCommand', data['lang']) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="auto_start_delay">{{ translate('serverConfig', 'serverAutostartDelay', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverAutostartDelayDesc', data['lang']) }}</small> </label>
|
||||
<input type="number" class="form-control" name="auto_start_delay" id="auto_start_delay" value="{{ data['server_stats']['server_id']['auto_start_delay'] }}" step="1" max="999" min="10" required>
|
||||
<label for="auto_start_delay">{{ translate('serverConfig', 'serverAutostartDelay', data['lang']) }}
|
||||
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverAutostartDelayDesc',
|
||||
data['lang']) }}</small> </label>
|
||||
<input type="number" class="form-control" name="auto_start_delay" id="auto_start_delay"
|
||||
value="{{ data['server_stats']['server_id']['auto_start_delay'] }}" step="1" max="999" min="10"
|
||||
required>
|
||||
</div>
|
||||
|
||||
{% if data['super_user'] %}
|
||||
<div class="form-group">
|
||||
<label for="executable_update_url">{{ translate('serverConfig', 'exeUpdateURL', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'exeUpdateURLDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="executable_update_url" id="executable_update_url" value="{{ data['server_stats']['server_id']['executable_update_url'] }}" placeholder="{{ translate('serverConfig', 'exeUpdateURL', data['lang']) }}">
|
||||
<label for="executable_update_url">{{ translate('serverConfig', 'exeUpdateURL', data['lang']) }}
|
||||
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'exeUpdateURLDesc', data['lang'])
|
||||
}}</small> </label>
|
||||
<input type="text" class="form-control" name="executable_update_url" id="executable_update_url"
|
||||
value="{{ data['server_stats']['server_id']['executable_update_url'] }}"
|
||||
placeholder="{{ translate('serverConfig', 'exeUpdateURL', data['lang']) }}">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="server_ip">{{ translate('serverConfig', 'serverIP', data['lang']) }} <small class="text-muted ml-1">- {{ translate('serverConfig', 'serverIPDesc', data['lang']) }}</small> </label>
|
||||
<input type="text" class="form-control" name="server_ip" id="server_ip" value="{{ data['server_stats']['server_id']['server_ip'] }}" required>
|
||||
<label for="server_ip">{{ translate('serverConfig', 'serverIP', data['lang']) }} <small
|
||||
class="text-muted ml-1">- {{ translate('serverConfig', 'serverIPDesc', data['lang']) }}</small>
|
||||
</label>
|
||||
<input type="text" class="form-control" name="server_ip" id="server_ip"
|
||||
value="{{ data['server_stats']['server_id']['server_ip'] }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="server_port">{{ translate('serverConfig', 'serverPort', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverPortDesc', data['lang']) }} </small> </label>
|
||||
<input type="number" class="form-control" name="server_port" id="server_port" value="{{ data['server_stats']['server_id']['server_port'] }}" step="1" max="65566" min="1" required>
|
||||
<label for="server_port">{{ translate('serverConfig', 'serverPort', data['lang']) }} <small
|
||||
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverPortDesc', data['lang']) }}
|
||||
</small> </label>
|
||||
<input type="number" class="form-control" name="server_port" id="server_port"
|
||||
value="{{ data['server_stats']['server_id']['server_port'] }}" step="1" max="65566" min="1"
|
||||
required>
|
||||
</div>
|
||||
{% end %}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="logs_delete_after">{{ translate('serverConfig', 'removeOldLogsAfter', data['lang']) }} <small class="text-muted ml-1"> - {{ translate('serverConfig', 'removeOldLogsAfterDesc', data['lang']) }}</small> </label>
|
||||
<input type="number" class="form-control" name="logs_delete_after" id="logs_delete_after" value="{{ data['server_stats']['server_id']['logs_delete_after'] }}" step="1" max="365" min="0" required>
|
||||
<label for="logs_delete_after">{{ translate('serverConfig', 'removeOldLogsAfter', data['lang']) }}
|
||||
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'removeOldLogsAfterDesc',
|
||||
data['lang']) }}</small> </label>
|
||||
<input type="number" class="form-control" name="logs_delete_after" id="logs_delete_after"
|
||||
value="{{ data['server_stats']['server_id']['logs_delete_after'] }}" step="1" max="365" min="0"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div class="form-check-flat">
|
||||
<label for="auto_start" class="form-check-label ml-4 mb-4">
|
||||
{% if data['server_stats']['server_id']['auto_start'] %}
|
||||
<input type="checkbox" class="form-check-input" id="auto_start" name="auto_start" checked="" value="1">{{ translate('serverConfig', 'serverAutoStart', data['lang']) }}
|
||||
<input type="checkbox" class="form-check-input" id="auto_start" name="auto_start" checked=""
|
||||
value="1">{{ translate('serverConfig', 'serverAutoStart', data['lang']) }}
|
||||
{% else %}
|
||||
<input type="checkbox" class="form-check-input" id="auto_start" name="auto_start" value="1">{{ translate('serverConfig', 'serverAutoStart', data['lang']) }}
|
||||
<input type="checkbox" class="form-check-input" id="auto_start" name="auto_start" value="1">{{
|
||||
translate('serverConfig', 'serverAutoStart', data['lang']) }}
|
||||
{% end %}
|
||||
</label>
|
||||
|
||||
<label for="crash_detection" class="form-check-label ml-4 mb-4">
|
||||
{% if data['server_stats']['server_id']['crash_detection'] %}
|
||||
<input type="checkbox" class="form-check-input" id="crash_detection" name="crash_detection" checked="" value="1">{{ translate('serverConfig', 'serverCrashDetection', data['lang']) }}
|
||||
<input type="checkbox" class="form-check-input" id="crash_detection" name="crash_detection"
|
||||
checked="" value="1">{{ translate('serverConfig', 'serverCrashDetection', data['lang']) }}
|
||||
{% else %}
|
||||
<input type="checkbox" class="form-check-input" id="crash_detection" name="crash_detection" value="1" >{{ translate('serverConfig', 'serverCrashDetection', data['lang']) }}
|
||||
<input type="checkbox" class="form-check-input" id="crash_detection" name="crash_detection"
|
||||
value="1">{{ translate('serverConfig', 'serverCrashDetection', data['lang']) }}
|
||||
{% end %}
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{ translate('serverConfig', 'save', data['lang']) }}</button>
|
||||
<button type="reset" class="btn btn-light"><i class="fas fa-times"></i> {{ translate('serverConfig', 'cancel', data['lang']) }}</button>
|
||||
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{
|
||||
translate('serverConfig', 'save', data['lang']) }}</button>
|
||||
<button type="reset" class="btn btn-light"><i class="fas fa-times"></i> {{ translate('serverConfig',
|
||||
'cancel', data['lang']) }}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -139,12 +188,18 @@
|
||||
</div>
|
||||
<div class="text-center">
|
||||
{% if data['server_stats']['running'] %}
|
||||
<button onclick="send_command(server_id, 'update_executable');" id="update_executable" style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig', 'update', data['lang']) }}</button>
|
||||
<a class="btn btn-sm btn-danger disabled">{{ translate('serverConfig', 'deleteServer', data['lang']) }}</a><br />
|
||||
<button onclick="send_command(server_id, 'update_executable');" id="update_executable"
|
||||
style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
||||
'update', data['lang']) }}</button>
|
||||
<a class="btn btn-sm btn-danger disabled">{{ translate('serverConfig', 'deleteServer', data['lang'])
|
||||
}}</a><br />
|
||||
<small>{{ translate('serverConfig', 'stopBeforeDeleting', data['lang']) }}</small>
|
||||
{% else %}
|
||||
<button onclick="send_command(server_id, 'update_executable');" id="update_executable" style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig', 'update', data['lang']) }}</button>
|
||||
<button onclick="deleteConfirm()" class="btn btn-sm btn-danger">{{ translate('serverConfig', 'deleteServer', data['lang']) }}</button>
|
||||
<button onclick="send_command(server_id, 'update_executable');" id="update_executable"
|
||||
style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig',
|
||||
'update', data['lang']) }}</button>
|
||||
<button onclick="deleteConfirm()" class="btn btn-sm btn-danger">{{ translate('serverConfig',
|
||||
'deleteServer', data['lang']) }}</button>
|
||||
{% end %}
|
||||
|
||||
</div>
|
||||
@ -173,8 +228,8 @@
|
||||
return r ? r[1] : undefined;
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
console.log( "ready!" );
|
||||
$(document).ready(function () {
|
||||
console.log("ready!");
|
||||
|
||||
});
|
||||
|
||||
@ -182,11 +237,11 @@
|
||||
var token = getCookie("_xsrf")
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
headers: {'X-XSRFToken': token},
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/ajax/delete_server?id={{ data['server_stats']['server_id']['server_id'] }}',
|
||||
data: {
|
||||
},
|
||||
success: function(data){
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
},
|
||||
@ -196,35 +251,34 @@
|
||||
var token = getCookie("_xsrf")
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
headers: {'X-XSRFToken': token},
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/ajax/delete_server_files?id={{ data['server_stats']['server_id']['server_id'] }}',
|
||||
data: {
|
||||
},
|
||||
success: function(data){
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
|
||||
function send_command (server_id, command){
|
||||
<!-- this getCookie function is in base.html-->
|
||||
function send_command(server_id, command) {
|
||||
//<!-- this getCookie function is in base.html-->
|
||||
var token = getCookie("_xsrf");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/server/command?command=' + command + '&id=' + server_id,
|
||||
success: function(data){
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
setTimeout(function(){ location.reload(); }, 10000);
|
||||
|
||||
setTimeout(function () { location.reload(); }, 10000);
|
||||
}
|
||||
});
|
||||
if(command != "delete_server" && command != "delete_server_files"){
|
||||
if (command != "delete_server" && command != "delete_server_files") {
|
||||
bootbox.alert({
|
||||
backdrop: true,
|
||||
title: '{% raw translate("serverConfig", "sendingRequest", data['lang']) %}',
|
||||
@ -233,7 +287,7 @@ let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
}
|
||||
}
|
||||
|
||||
function deleteServer (){
|
||||
function deleteServer() {
|
||||
path = "{{data['server_stats']['server_id']['path']}}";
|
||||
name = "{{data['server_stats']['server_id']['server_name']}}";
|
||||
bootbox.dialog({
|
||||
@ -245,9 +299,9 @@ let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
files: {
|
||||
label: "{{ translate('serverConfig', 'yesDeleteFiles', data['lang']) }}",
|
||||
className: 'btn-danger',
|
||||
callback: function(){
|
||||
callback: function () {
|
||||
deleteServerFilesE();
|
||||
setTimeout(function(){ window.location = '/panel/dashboard'; }, 5000);
|
||||
setTimeout(function () { window.location = '/panel/dashboard'; }, 5000);
|
||||
bootbox.dialog({
|
||||
backdrop: true,
|
||||
title: '{% raw translate("serverConfig", "sendingDelete", data['lang']) %}',
|
||||
@ -261,9 +315,9 @@ let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
noFiles: {
|
||||
label: "{{ translate('serverConfig', 'noDeleteFiles', data['lang']) }}",
|
||||
className: 'btn-outline-danger',
|
||||
callback: function(){
|
||||
callback: function () {
|
||||
deleteServerE()
|
||||
setTimeout(function(){ window.location = '/panel/dashboard'; }, 5000);
|
||||
setTimeout(function () { window.location = '/panel/dashboard'; }, 5000);
|
||||
bootbox.dialog({
|
||||
backdrop: true,
|
||||
title: '{% raw translate("serverConfig", "sendingDelete", data['lang']) %}',
|
||||
@ -276,17 +330,17 @@ let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
cancel: {
|
||||
label: "{{ translate('serverConfig', 'cancel', data['lang']) }}",
|
||||
className: 'btn-secondary',
|
||||
callback: function(){
|
||||
callback: function () {
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: function(result) {
|
||||
callback: function (result) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
function deleteConfirm (){
|
||||
function deleteConfirm() {
|
||||
path = "{{data['server_stats']['server_id']['path']}}";
|
||||
name = "{{data['server_stats']['server_id']['server_name']}}";
|
||||
bootbox.confirm({
|
||||
@ -304,11 +358,12 @@ let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
className: 'btn-link',
|
||||
}
|
||||
},
|
||||
callback: function(result) {
|
||||
if (!result){
|
||||
callback: function (result) {
|
||||
if (!result) {
|
||||
return;
|
||||
return;}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
else {
|
||||
deleteServer();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
||||
@ -43,7 +42,8 @@
|
||||
<div style="gap: 0.5rem;" class="input-group flex-wrap">
|
||||
<input style="min-width: 10rem;" type="text" class="form-control" id="server_command" name="server_command" placeholder="{{ translate('serverTerm', 'commandInput', data['lang']) }}" autofocus="">
|
||||
<span class="input-group-btn ml-5">
|
||||
<button id="submit" class="btn btn-sm btn-info" type="button">{{ translate('serverTerm', 'sendCommand', data['lang']) }}</button>
|
||||
<button id="submit" class="btn btn-sm btn-info" type="button">{{ translate('serverTerm', 'sendCommand',
|
||||
data['lang']) }}</button>
|
||||
</span>
|
||||
</div>
|
||||
{% if data['permissions']['Commands'] in data['user_permissions'] %}
|
||||
@ -68,7 +68,6 @@
|
||||
{% end %}
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -81,10 +80,11 @@
|
||||
|
||||
/* Hide scrollbar for IE, Edge and Firefox */
|
||||
#virt_console {
|
||||
-ms-overflow-style: none; /* IE and Edge */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
-ms-overflow-style: none;
|
||||
/* IE and Edge */
|
||||
scrollbar-width: none;
|
||||
/* Firefox */
|
||||
}
|
||||
|
||||
</style>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
@ -93,45 +93,39 @@
|
||||
{% block js %}
|
||||
<script>
|
||||
|
||||
function send_command (server_id, command){
|
||||
if (command == 'start_server'){
|
||||
function send_command(server_id, command) {
|
||||
if (command == 'start_server') {
|
||||
startBtn.setAttribute('disabled', 'disabled');
|
||||
restartBtn.removeAttribute('disabled');
|
||||
stopBtn.removeAttribute('disabled');
|
||||
}
|
||||
if (command == 'stop_server'){
|
||||
if (command == 'stop_server') {
|
||||
startBtn.removeAttribute('disabled');
|
||||
restartBtn.setAttribute('disabled', 'disabled');
|
||||
stopBtn.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
<!-- this getCookie function is in base.html-->
|
||||
//<!-- this getCookie function is in base.html-->
|
||||
var token = getCookie("_xsrf");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/server/command?command=' + command + '&id=' + server_id,
|
||||
success: function(data){
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
setTimeout(function(){
|
||||
if (command != 'start_server'){
|
||||
location.reload();
|
||||
}
|
||||
}, 10000);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
if (webSocket) {
|
||||
webSocket.on('update_button_status', function (updateButton) {
|
||||
if (updateButton.isUpdating){
|
||||
if(updateButton.server_id == '{{ data['server_stats']['server_id']['server_id'] }}') {
|
||||
if (updateButton.isUpdating) {
|
||||
if (updateButton.server_id == '{{ data['server_stats']['server_id']['server_id'] }}') {
|
||||
console.log(updateButton.isUpdating)
|
||||
document.getElementById('control_buttons').innerHTML = '<button onclick="" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "updating", data['lang']) }}</button><button onclick="" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart", data['lang']) %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop", data['lang']) }}</button>';
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
if (updateButton.server_id == '{{ data['server_stats']['server_id']['server_id'] }}') {
|
||||
window.location.reload()
|
||||
document.getElementById('update_control_buttons').innerHTML = '<button onclick="send_command(server_id, "start_server");" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "start", data['lang']) }}</button><button onclick="send_command(server_id, "restart_server");" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart", data['lang']) %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop", data['lang']) }}</button>';
|
||||
@ -161,7 +155,7 @@
|
||||
|
||||
let server_id = '{{ data['server_stats']['server_id']['server_id'] }}';
|
||||
|
||||
function get_server_log(){
|
||||
function get_server_log() {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/ajax/server_log?id={{ data['server_stats']['server_id']['server_id'] }}',
|
||||
@ -191,15 +185,15 @@
|
||||
return r ? r[1] : undefined;
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
console.log( "ready!" );
|
||||
$(document).ready(function () {
|
||||
console.log("ready!");
|
||||
get_server_log()
|
||||
|
||||
webSocket.on('vterm_new_line', new_line_handler)
|
||||
});
|
||||
|
||||
$('#server_command').on('keydown', function (e) {
|
||||
if (e.which == 13){
|
||||
if (e.which == 13) {
|
||||
$(this).attr("disabled", "disabled"); //Disable textbox to prevent multiple submit
|
||||
send_command_to_server()
|
||||
$(this).removeAttr("disabled"); //Enable the textbox again if needed.
|
||||
@ -215,20 +209,20 @@
|
||||
|
||||
});
|
||||
|
||||
$("#submit").click(function(e) {
|
||||
$("#submit").click(function (e) {
|
||||
e.preventDefault();
|
||||
send_command_to_server();
|
||||
|
||||
});
|
||||
|
||||
function scrollConsole(){
|
||||
function scrollConsole() {
|
||||
var logview = $('#virt_console');
|
||||
if(logview.length)
|
||||
if (logview.length)
|
||||
logview.scrollTop(logview[0].scrollHeight - logview.height());
|
||||
}
|
||||
|
||||
|
||||
function send_command_to_server(){
|
||||
function send_command_to_server() {
|
||||
var server_command = $("#server_command").val()
|
||||
console.log(server_command)
|
||||
|
||||
@ -236,15 +230,15 @@
|
||||
|
||||
var token = getCookie("_xsrf")
|
||||
|
||||
data_to_send = { command :server_command, }
|
||||
data_to_send = { command: server_command, }
|
||||
|
||||
console.log('sending command: ' + server_command)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: {'X-XSRFToken': token},
|
||||
headers: { 'X-XSRFToken': token },
|
||||
url: '/ajax/send_command?id={{ data['server_stats']['server_id']['server_id'] }}',
|
||||
data: data_to_send,
|
||||
success: function(data){
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
$("#server_command").val('')
|
||||
@ -256,17 +250,17 @@
|
||||
const cmdHistory = {
|
||||
history: [],
|
||||
current: 0,
|
||||
push: function(cmd) {
|
||||
push: function (cmd) {
|
||||
this.history.push(cmd);
|
||||
this.current = this.history.length - 1;
|
||||
},
|
||||
getPrev: function() {
|
||||
getPrev: function () {
|
||||
const prevCommand = this.history[this.current];
|
||||
this.current--;
|
||||
if (this.current < 0) this.current = 0;
|
||||
return prevCommand;
|
||||
},
|
||||
getNext: function() {
|
||||
getNext: function () {
|
||||
this.current++;
|
||||
if (this.current > (this.history.length - 1)) {
|
||||
this.current = (this.history.length - 1);
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends ../public_base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<meta http-equiv="refresh" content="30">
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard', data['lang']) }}{% end %}
|
||||
@ -24,40 +23,49 @@
|
||||
<tbody>
|
||||
{% for server in data['servers'] %}
|
||||
<tr>
|
||||
<td>
|
||||
<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>
|
||||
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max', data['lang']) }}<br />
|
||||
<td id="server_players_{{ server['stats']['server_id']['server_id'] }}">
|
||||
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max',
|
||||
data['lang']) }}<br />
|
||||
</td>
|
||||
<td>
|
||||
<td id="server_motd_{{ server['stats']['server_id']['server_id'] }}">
|
||||
{% if server['stats']['desc'] != 'False' %}
|
||||
{% if server['raw_ping_result']['icon'] %}
|
||||
<img src="data:image/png;base64,{% raw server['raw_ping_result']['icon'] %}" alt="icon"/>
|
||||
<img src="data:image/png;base64,{% raw server['raw_ping_result']['icon'] %}" alt="icon" />
|
||||
{% else %}
|
||||
<img src="/static/assets/images/pack.png" alt="icon" />
|
||||
{% end %}
|
||||
<span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ server['stats']['desc'] }}</span> <br />
|
||||
<span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{
|
||||
server['stats']['desc'] }}</span> <br />
|
||||
{% end %}
|
||||
</td>
|
||||
<td>
|
||||
<td id="server_version_{{ server['stats']['server_id']['server_id'] }}">
|
||||
{% if server['stats']['version'] != 'False' %}
|
||||
{{ server['stats']['version'] }}
|
||||
{% end %}
|
||||
</td>
|
||||
{% else %}
|
||||
<td colspan="3">
|
||||
<!-- TODO: translate the following text -->
|
||||
<span class="text-warning"><i class="fas fa-exclamation-triangle"></i> Crafty can't get infos from this Server </span>
|
||||
<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>
|
||||
{% end %}
|
||||
<td>
|
||||
<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>
|
||||
<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>
|
||||
<span class="text-danger"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', data['lang'])
|
||||
}}</span>
|
||||
{% end %}
|
||||
</td>
|
||||
</tr>
|
||||
@ -73,14 +81,83 @@
|
||||
|
||||
{% block js %}
|
||||
|
||||
<script src="/static/assets/js/motd.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
<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) {
|
||||
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);
|
||||
|
||||
/* TODO Update each element */
|
||||
if (server.int_ping_results) {
|
||||
|
||||
/* Update Players */
|
||||
if (server.players)
|
||||
{
|
||||
server_players.innerHTML = server.online + ` / ` + server.max + ` {{ translate('dashboard', 'max', data['lang']) }}<br />`
|
||||
}
|
||||
|
||||
/* Update Motd */
|
||||
var motd = "";
|
||||
if (server.desc) {
|
||||
if (server.icon) {
|
||||
motd = `<img src="data:image/png;base64,` + server.icon + `" alt="icon" /> `;
|
||||
}
|
||||
else {
|
||||
motd = `<img src="/static/assets/images/pack.png" alt="icon" /> `;
|
||||
}
|
||||
|
||||
motd = motd + `<span id="input_motd_` + server.id + `" class="input_motd">` + server.desc + `</span> <br />`;
|
||||
server_motd.innerHTML = motd;
|
||||
}
|
||||
|
||||
/* Version */
|
||||
if (server.version)
|
||||
{
|
||||
server_version.innerHTML = server.version
|
||||
}
|
||||
}
|
||||
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>`;
|
||||
server_version.innerHTML = `<span class="text-warning"><i class="fas fa-question"></i></i></span>`
|
||||
}
|
||||
|
||||
/* 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>`;
|
||||
}
|
||||
else {
|
||||
online_status = `<span class="text-danger"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', data['lang'])}}</span>`;
|
||||
}
|
||||
server_online_status.innerHTML = online_status;
|
||||
}
|
||||
|
||||
function update_servers_status(data) {
|
||||
for (server of data) {
|
||||
update_one_server_status(server);
|
||||
}
|
||||
display_motd();
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
console.log("ready!");
|
||||
display_motd()
|
||||
|
||||
if (webSocket)
|
||||
{
|
||||
webSocket.on('update_server_status', update_servers_status);
|
||||
}
|
||||
}());
|
||||
</script>
|
||||
</script>
|
||||
|
||||
{% end %}
|
@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@ -21,8 +22,9 @@
|
||||
<!-- End Layout styles -->
|
||||
<link rel="shortcut icon" type="image/svg+xml" href="/static/assets/images/logo_small.svg">
|
||||
<link rel="alternate icon" href="/static/assets/images/favicon.png" />
|
||||
</head>
|
||||
<body class="dark-theme">
|
||||
</head>
|
||||
|
||||
<body class="dark-theme">
|
||||
<div class="container-scroller">
|
||||
<div class="container-fluid page-body-wrapper full-page-wrapper">
|
||||
<div class="content-wrapper d-flex align-items-center auth auth-bg-1 theme-one">
|
||||
@ -50,11 +52,67 @@
|
||||
<script src="/static/assets/js/shared/settings.js"></script>
|
||||
<script src="/static/assets/js/shared/todolist.js"></script>
|
||||
<!-- endinject -->
|
||||
<script>
|
||||
|
||||
// {% if request.protocol == 'https' %}
|
||||
let usingWebSockets = true;
|
||||
|
||||
let listenEvents = [];
|
||||
|
||||
try {
|
||||
pageQueryParams = 'page_query_params=' + encodeURIComponent(location.search)
|
||||
page = 'page=' + encodeURIComponent(location.pathname)
|
||||
var wsInternal = new WebSocket('wss://' + location.host + '/ws?' + page + '&' + pageQueryParams);
|
||||
wsInternal.onopen = function () {
|
||||
console.log('opened WebSocket connection:', wsInternal)
|
||||
};
|
||||
wsInternal.onmessage = function (rawMessage) {
|
||||
var message = JSON.parse(rawMessage.data);
|
||||
|
||||
console.log('got message: ', message)
|
||||
|
||||
listenEvents
|
||||
.filter(listenedEvent => listenedEvent.event == message.event)
|
||||
.forEach(listenedEvent => listenedEvent.callback(message.data))
|
||||
};
|
||||
wsInternal.onerror = function (errorEvent) {
|
||||
console.error('WebSocket Error', errorEvent);
|
||||
};
|
||||
wsInternal.onclose = function (closeEvent) {
|
||||
console.log('Closed WebSocket', closeEvent);
|
||||
};
|
||||
|
||||
|
||||
webSocket = {
|
||||
on: function (event, callback) {
|
||||
console.log('registered ' + event + ' event');
|
||||
listenEvents.push({ event: event, callback: callback })
|
||||
},
|
||||
emit: function (event, data) {
|
||||
var message = {
|
||||
event: event,
|
||||
data: data
|
||||
}
|
||||
|
||||
wsInternal.send(JSON.stringify(message));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error while making websocket helpers', error);
|
||||
usingWebSockets = false;
|
||||
}
|
||||
// {% else %}
|
||||
let usingWebSockets = false;
|
||||
warn('WebSockets are not supported in Crafty if not using the https protocol')
|
||||
var webSocket;
|
||||
// {% end%}
|
||||
|
||||
</script>
|
||||
{% block js %}
|
||||
<!-- Custom js for this page -->
|
||||
<!-- End custom js for this page -->
|
||||
{% end %}
|
||||
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -122,6 +122,7 @@
|
||||
"serverStats": {
|
||||
"online": "Online",
|
||||
"offline": "Offline",
|
||||
"starting": "Verzögerter Start",
|
||||
"serverStatus": "Server Status",
|
||||
"serverStarted": "Server gestartet",
|
||||
"serverUptime": "Server-Betriebszeit",
|
||||
|
@ -129,6 +129,7 @@
|
||||
"serverStats": {
|
||||
"online": "Online",
|
||||
"offline": "Offline",
|
||||
"starting": "Delayed-Start",
|
||||
"serverStatus": "Server Status",
|
||||
"serverStarted": "Server Started",
|
||||
"serverUptime": "Server Uptime",
|
||||
|
@ -123,6 +123,7 @@
|
||||
"serverStats": {
|
||||
"online": "En línea",
|
||||
"offline": "Desconectado",
|
||||
"starting": "Inicio-retrasado",
|
||||
"serverStatus": "Estado del Servidor",
|
||||
"serverStarted": "Servidor Iniciado",
|
||||
"serverUptime": "Actividad del Servidor",
|
||||
|
@ -133,6 +133,7 @@
|
||||
"serverStats": {
|
||||
"online": "Päällä",
|
||||
"offline": "Pois päältä",
|
||||
"starting": "Myöhästynyt lähtö",
|
||||
"serverStatus": "Palvelimen tila",
|
||||
"serverStarted": "Palvelin käynnistyi",
|
||||
"serverUptime": "Palvelimen käyttöaika",
|
||||
|
@ -123,6 +123,7 @@
|
||||
"serverStats": {
|
||||
"online": "En Ligne",
|
||||
"offline": "Hors Ligne",
|
||||
"starting": "Démarrage en cours",
|
||||
"serverStatus": "Statut du Serveur",
|
||||
"serverStarted": "Serveur Démarré",
|
||||
"serverUptime": "Serveur Disponible depuis",
|
||||
|
@ -122,6 +122,7 @@
|
||||
"serverStats": {
|
||||
"online": "Na mreži",
|
||||
"offline": "Izvan mreže",
|
||||
"starting": "Odgođeno pokretanje",
|
||||
"serverStatus": "Status poslužitelja",
|
||||
"serverStarted": "Poslužitelj pokrenut",
|
||||
"serverUptime": "Vrijeme rada poslužitelja",
|
||||
|
@ -122,6 +122,7 @@
|
||||
"serverStats": {
|
||||
"online": "Online",
|
||||
"offline": "Offline",
|
||||
"starting": "Avvio ritardato",
|
||||
"serverStatus": "Stato del server",
|
||||
"serverStarted": "Server Avviato",
|
||||
"serverUptime": "Tempo di esecuzione",
|
||||
|
@ -123,6 +123,7 @@
|
||||
"serverStats": {
|
||||
"online": "Turnd on",
|
||||
"offline": "Turnd off",
|
||||
"starting": "I waitz b4 I start",
|
||||
"serverStatus": "Servr Status",
|
||||
"serverStarted": "Servr Started",
|
||||
"serverUptime": "How longz servr been awaek",
|
||||
|
@ -122,6 +122,7 @@
|
||||
"serverStats": {
|
||||
"online": "Online",
|
||||
"offline": "Offline",
|
||||
"starting": "Vertraagde start",
|
||||
"serverStatus": "Server Status",
|
||||
"serverStarted": "Server gestart",
|
||||
"serverUptime": "Server Uptime",
|
||||
|
@ -123,6 +123,7 @@
|
||||
"serverStats": {
|
||||
"online": "运行中",
|
||||
"offline": "已停止",
|
||||
"starting": "延迟启动",
|
||||
"serverStatus": "服务器状态",
|
||||
"serverStarted": "服务器已启动",
|
||||
"serverUptime": "服务器正常运行时间",
|
||||
|
Loading…
Reference in New Issue
Block a user