2020-08-13 14:38:36 +00:00
{% extends ../base.html %}
2020-08-27 22:35:08 +00:00
{% block meta %}
< meta http-equiv = "refresh" content = "60" >
{% end %}
2021-03-26 13:57:50 +00:00
{% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard') }}{% end %}
2020-08-13 14:38:36 +00:00
{% block content %}
< div class = "content-wrapper" >
<!-- Page Title Header Starts -->
< div class = "row page-title-header" >
< div class = "col-12" >
< div class = "page-header" >
2021-03-26 13:57:50 +00:00
< h4 class = "page-title" > {{ translate('dashboard', 'dashboard') }}< / h4 >
2020-08-13 14:38:36 +00:00
< / div >
< / div >
< / div >
<!-- Page Title Header Ends -->
< div class = "row" >
< div class = "col-md-12 grid-margin" >
< div class = "card" >
< div class = "card-body" >
< div class = "row" >
< div class = "col-lg-3 col-md-6" >
< div class = "d-flex" >
< div class = "wrapper" >
2021-03-26 13:57:50 +00:00
< h5 class = "mb-1 font-weight-medium text-primary" > {{ translate('dashboard', 'host') }}< / h5 >
2020-08-17 02:47:53 +00:00
< h3 class = "mb-0 font-weight-semibold" > < i class = "fas fa-chart-line" > < / i > < / h3 >
2020-08-13 14:38:36 +00:00
< / div >
< div class = "wrapper my-auto ml-auto ml-lg-4" >
2021-03-26 13:57:50 +00:00
< p id = "cpu_data" class = "mb-0 text-success" data-toggle = "tooltip" data-placement = "top" data-html = "true" title = "{% raw translate('dashboard', 'cpuCores') %}: {{ data.get('hosts_data').get('cpu_cores') }} <br /> {% raw translate('dashboard', 'cpuCurFreq') %}: {{ data.get('hosts_data').get('cpu_cur_freq') }} <br /> {% raw translate('dashboard', 'cpuMaxFreq') %}: {{ data.get('hosts_data').get('cpu_max_freq') }}" >
{{ translate('dashboard', 'cpuUsage') }}: < span id = "cpu_usage" > {{ data.get('hosts_data').get('cpu_usage') }}< / span >
2020-08-28 03:21:55 +00:00
< / p >
2021-03-26 13:57:50 +00:00
< p id = "mem_usage" class = "mb-0 text-danger" data-toggle = "tooltip" data-placement = "top" title = "{{ translate('dashboard', 'memUsage') }}: {{ data.get('hosts_data').get('mem_usage') }}" >
{{ translate('dashboard', 'memUsage') }}: < span id = "mem_percent" > {{ data.get('hosts_data').get('mem_percent') }}%< / span >
2020-08-28 03:21:55 +00:00
< / p >
2020-08-13 14:38:36 +00:00
< / div >
< / div >
< / div >
< div class = "col-lg-3 col-md-6 mt-md-0 mt-4" >
< div class = "d-flex" >
< div class = "wrapper" >
2021-03-26 13:57:50 +00:00
< h5 class = "mb-1 font-weight-medium text-primary" > {{ translate('dashboard', 'servers') }}< / h5 >
2020-08-19 01:04:43 +00:00
< h3 class = "mb-0 font-weight-semibold" > {{ data['server_stats']['total'] }}< / h3 >
2020-08-13 14:38:36 +00:00
< / div >
< div class = "wrapper my-auto ml-auto ml-lg-4" >
2021-03-26 13:57:50 +00:00
< p class = "mb-0 text-success" > {{ data['server_stats']['running'] }} {{ translate('dashboard', 'online').lower() }}< / p >
< p class = "mb-0 text-warning" > {{ data['server_stats']['stopped'] }} {{ translate('dashboard', 'offline').lower() }}< / p >
2020-08-13 14:38:36 +00:00
< / div >
< / div >
< / div >
< div class = "col-lg-3 col-md-6 mt-md-0 mt-4" >
< div class = "d-flex" >
< div class = "wrapper" >
2021-03-26 13:57:50 +00:00
< h5 class = "mb-1 font-weight-medium text-primary" > {{ translate('dashboard', 'players') }}< / h5 >
2020-08-13 14:38:36 +00:00
< h3 class = "mb-0 font-weight-semibold" > 18< / h3 >
< / div >
< div class = "wrapper my-auto ml-auto ml-lg-4" >
2021-03-26 13:57:50 +00:00
< p class = "mb-0 text-success" > 35 {{ translate('dashboard', 'max') }}< / p >
< p class = "mb-0 text-warning" > 10 {{ translate('dashboard', 'avg') }}< / p >
2020-08-13 14:38:36 +00:00
< / div >
< / div >
< / div >
< div class = "col-lg-3 col-md-6 mt-md-0 mt-4" >
< div class = "d-flex" >
< div class = "wrapper" >
2021-03-26 13:57:50 +00:00
< h5 class = "mb-1 font-weight-medium text-primary" > {{ translate('dashboard', 'backups') }}< / h5 >
2020-08-13 14:38:36 +00:00
< h3 class = "mb-0 font-weight-semibold" > 7< / h3 >
< / div >
< div class = "wrapper my-auto ml-auto ml-lg-4" >
2021-03-26 13:57:50 +00:00
< p class = "mb-0 text-success" > {{ translate('dashboard', 'lastBackup') }} 11-31-2020< / p >
< p class = "mb-0 text-success" > {{ translate('dashboard', 'nextBackup') }} 12-05-2020< / p >
2020-08-13 14:38:36 +00:00
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< div class = "row" >
< 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" >
2021-03-26 13:57:50 +00:00
< h4 class = "card-title" > < i class = "fas fa-server" > < / i > {{ translate('dashboard', 'allServers') }}< / h4 >
2020-08-27 23:55:55 +00:00
< div class = "d-md-none" >
2021-03-26 13:57:50 +00:00
< small > {{ translate('dashboard', 'cannotSeeOnMobile') }}< br / > {{ translate('dashboard', 'cannotSeeOnMobile2') }}< / small >
2020-08-27 23:55:55 +00:00
< / div >
2021-03-26 13:57:50 +00:00
< div > < a class = "nav-link" href = "/server/step1" > < i class = "fas fa-plus-circle" > < / i > {{ translate('dashboard', 'newServer') }}< / a > < / div >
2020-08-13 14:38:36 +00:00
< / div >
< div class = "card-body" >
< div class = "table-responsive" >
2021-08-21 23:41:25 +00:00
< table class = "table table-hover" >
2020-08-13 14:38:36 +00:00
< thead >
< tr class = "rounded" >
2021-03-26 13:57:50 +00:00
< th > {{ translate('dashboard', 'server') }}< / th >
< th > {{ translate('dashboard', 'actions') }}< / th >
< th > {{ translate('dashboard', 'cpuUsage') }}< / th >
< th > {{ translate('dashboard', 'memUsage') }}< / th >
< th > {{ translate('dashboard', 'world') }}< / th >
< th > {{ translate('dashboard', 'players') }}< / th >
< th > {{ translate('dashboard', 'status') }}< / th >
2020-08-13 14:38:36 +00:00
< / tr >
< / thead >
< tbody >
2020-08-24 17:08:17 +00:00
{% for server in data['servers'] %}
2020-08-13 14:38:36 +00:00
< tr >
< td >
2020-08-24 17:08:17 +00:00
< i class = "fas fa-server" > < / i >
2020-08-27 22:30:56 +00:00
< a href = "/panel/server_detail?id={{server['server_data']['server_id']}}" >
{{ server['server_data']['server_name'] }}
2020-08-24 17:08:17 +00:00
< / a >
< / td >
2021-07-26 22:43:57 +00:00
< td id = "controls{{server['server_data']['server_id']}}" class = "actions_serverlist" >
2021-08-21 23:41:25 +00:00
{% if server['user_command_permission'] %}
{% if server['stats']['running'] %}
2021-09-13 19:03:47 +00:00
< a class = "stop_button" data-id = "{{server['server_data']['server_id']}}" data-toggle = "tooltip" title = {{ translate ( ' dashboard ' , ' stop ' ) } } > < 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 ' ) } } > < 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 ' ) } } > < i class = "fas fa-skull" > < / i > < / a >
2021-08-21 23:41:25 +00:00
{% elif server['stats']['updating']%}
< a data-id = "{{server['server_data']['server_id']}}" class = "" > UPDATING...< / i > < / a >
{% else %}
2021-09-13 19:03:47 +00:00
< a data-id = "{{server['server_data']['server_id']}}" class = "play_button" > < i class = "fas fa-play" data-toggle = "tooltip" title = {{ translate ( ' dashboard ' , ' start ' ) } } > < / 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 ' ) } } > < / i > < / a >
< a class = "kill_button" data-id = "{{server['server_data']['server_id']}}" class = "kill_button" data-toggle = "tooltip" title = {{ translate ( ' dashboard ' , ' kill ' ) } } > < i class = "fas fa-skull" > < / i > < / a >
2021-08-21 23:41:25 +00:00
{% end %}
2020-08-24 17:08:17 +00:00
{% end %}
2020-08-13 14:38:36 +00:00
< / td >
2020-08-24 17:08:17 +00:00
2020-08-13 14:38:36 +00:00
< td >
2021-03-22 04:02:18 +00:00
< div class = "progress mb-1" data-toggle = "tooltip" data-placement = "top" title = "{{server['stats']['cpu']}}" >
2020-08-28 00:01:41 +00:00
< div class = "progress-bar
2021-03-22 04:02:18 +00:00
{% if server['stats']['cpu'] < = 33 %}
2020-08-28 00:01:41 +00:00
bg-success
2021-03-22 04:02:18 +00:00
{% elif 34 < = server['stats']['cpu'] < = 66 %}
2020-08-28 00:01:41 +00:00
bg-warning
{% else %}
bg-danger
{% end %}
2021-03-22 04:02:18 +00:00
" role="progressbar" style="width: {{server['stats']['cpu']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">< / div >
2020-08-13 14:38:36 +00:00
< / div >
2021-03-22 04:02:18 +00:00
{{server['stats']['cpu']}}%
2020-08-13 14:38:36 +00:00
< / td >
2020-08-24 17:08:17 +00:00
2020-08-13 14:38:36 +00:00
< td >
2021-03-22 04:02:18 +00:00
< div class = "progress mb-1" data-toggle = "tooltip" data-placement = "top" title = "{{server['stats']['mem']}}" >
2020-08-28 00:01:41 +00:00
< div class = "progress-bar
2021-03-22 04:02:18 +00:00
{% if server['stats']['mem_percent'] < = 33 %}
2020-08-28 00:01:41 +00:00
bg-success
2021-03-22 04:02:18 +00:00
{% elif 34 < = server['stats']['mem_percent'] < = 66 %}
2020-08-28 00:01:41 +00:00
bg-warning
{% else %}
bg-danger
{% end %}
2021-03-22 04:02:18 +00:00
" role="progressbar" style="width: {{server['stats']['mem_percent']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">< / div >
2020-08-13 14:38:36 +00:00
< / div >
2021-03-22 04:02:18 +00:00
{{server['stats']['mem_percent']}}% -
2020-08-31 17:46:25 +00:00
2021-03-22 04:02:18 +00:00
{% if server['stats']['mem'] == 0 %}
2020-08-31 17:46:25 +00:00
0 MB
{% else %}
2021-03-22 04:02:18 +00:00
{{server['stats']['mem']}}
2020-08-31 17:46:25 +00:00
{% end %}
2020-08-13 14:38:36 +00:00
< / td >
< td >
2021-03-22 04:02:18 +00:00
{{ server['stats']['world_name'] }} : {{ server['stats']['world_size'] }}
2020-08-13 14:38:36 +00:00
< / td >
< td >
2021-03-22 04:02:18 +00:00
{% if server['stats']['int_ping_results'] %}
2021-03-26 13:57:50 +00:00
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max') }}< br / >
2020-08-31 17:46:25 +00:00
2021-03-22 04:02:18 +00:00
{% if server['stats']['desc'] != 'False' %}
{{ server['stats']['desc'] }} < br / >
2020-08-31 17:46:25 +00:00
{% end %}
2021-03-22 04:02:18 +00:00
{% if server['stats']['version'] != 'False' %}
{{ server['stats']['version'] }}
2020-08-31 17:46:25 +00:00
{% end %}
2020-08-24 23:11:17 +00:00
{% end %}
2020-08-31 17:46:25 +00:00
2020-08-24 17:08:17 +00:00
< / td >
< td >
2021-03-22 04:02:18 +00:00
{% if server['stats']['running'] %}
2021-03-26 13:57:50 +00:00
< i class = "fas fa-thumbs-up" > < / i > < span class = "text-success" > {{ translate('dashboard', 'online') }}< / span >
2020-08-24 17:08:17 +00:00
{% else %}
2021-03-26 13:57:50 +00:00
< i class = "fas fa-thumbs-down" > < / i > < span class = "text-danger" > {{ translate('dashboard', 'offline') }}< / span >
2020-08-24 17:08:17 +00:00
{% end %}
2020-08-13 14:38:36 +00:00
< / td >
< / tr >
2020-08-24 17:08:17 +00:00
{% end %}
2020-08-13 14:38:36 +00:00
< / tbody >
< / table >
< / div >
< / div >
< / div >
< / div >
< / div >
2020-08-24 17:08:17 +00:00
2020-08-13 14:38:36 +00:00
< / div >
<!-- content - wrapper ends -->
2020-08-24 23:11:17 +00:00
{% end %}
{% block js %}
< script >
function send_command (server_id, command){
2021-02-26 08:59:25 +00:00
/* this getCookie function is in base.html */
2020-08-24 23:11:17 +00:00
var token = getCookie("_xsrf");
$.ajax({
type: "POST",
headers: {'X-XSRFToken': token},
url: '/server/command?command=' + command + '& id=' + server_id,
success: function(data){
console.log("got response:");
console.log(data);
2021-08-07 19:23:22 +00:00
setTimeout(function(){
if (command != 'start_server'){
location.reload();
}
}, 10000);
2020-08-24 23:11:17 +00:00
}
});
}
2021-09-13 19:03:47 +00:00
function send_kill (server_id){
/* this getCookie function is in base.html */
var token = getCookie("_xsrf");
$.ajax({
type: "POST",
headers: {'X-XSRFToken': token},
url: '/ajax/kill?id=' + server_id,
success: function(data){
console.log("got response:");
console.log(data);
setTimeout(function(){
location.reload();
}, 10000);
}
});
}
2020-08-24 23:11:17 +00:00
$( document ).ready(function() {
console.log('ready for JS!')
$( ".play_button" ).click(function() {
server_id = $(this).attr("data-id");
send_command(server_id, 'start_server');
bootbox.alert({
backdrop: true,
2021-03-26 13:57:50 +00:00
title: '{% raw translate("dashboard", "sendingCommand") %}',
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > {% raw translate("dashboard", "bePatientStart") %} < / div > '
2020-08-24 23:11:17 +00:00
});
});
$( ".stop_button" ).click(function() {
console.log("stopping server");
server_id = $(this).attr("data-id");
send_command(server_id, 'stop_server');
bootbox.alert({
backdrop: true,
2021-03-26 13:57:50 +00:00
title: '{% raw translate("dashboard", "sendingCommand") %}',
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > {% raw translate("dashboard", "bePatientStop") %} < / div > '
2020-08-24 23:11:17 +00:00
});
});
$( ".restart_button" ).click(function() {
server_id = $(this).attr("data-id");
send_command(server_id, 'restart_server');
bootbox.alert({
backdrop: true,
2021-03-26 13:57:50 +00:00
title: '{% raw translate("dashboard", "sendingCommand") %}',
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > {% raw translate("dashboard", "bePatientRestart") %} < / div > '
2020-08-24 23:11:17 +00:00
});
2021-09-13 19:03:47 +00:00
});
$( ".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?",
buttons: {
confirm: {
label: '{% raw translate("dashboard", "kill") %}',
className: 'btn-danger'
},
cancel: {
label: '{% raw translate("panelConfig", "cancel") %}',
className: 'btn-secondary'
}
},
callback: function (result) {
if(result){
send_kill(server_id);
var dialog = bootbox.dialog({
title: '{% raw translate("dashboard", "killing") %}',
message: '< p > < i class = "fa fa-spin fa-spinner" > < / i > Loading...< / p > '
});
dialog.init(function(){
setTimeout(function(){
location.reload();
}, 15000);
});
}
}
});
2020-08-24 23:11:17 +00:00
});
2021-02-27 12:05:04 +00:00
if (webSocket) {
cpu_data = document.getElementById('cpu_data');
cpu_usage = document.getElementById('cpu_usage');
mem_usage = document.getElementById('mem_usage');
mem_percent = document.getElementById('mem_percent');
webSocket.on('update_host_stats', function (hostStats) {
2021-03-26 13:57:50 +00:00
var cpuDataTitle = `{% raw translate('dashboard', 'cpuCores') %}: ${hostStats.cpu_cores} < br / > {% raw translate("dashboard", "cpuCurFreq") %}: ${hostStats.cpu_cur_freq} < br / > {% raw translate("dashboard", "cpuMaxFreq") %}: ${hostStats.cpu_max_freq}`;
2021-02-27 12:05:04 +00:00
cpu_data.setAttribute('data-original-title', cpuDataTitle);
cpu_usage.textContent = hostStats.cpu_usage;
2021-03-26 13:57:50 +00:00
mem_usage.setAttribute('data-original-title', `{% raw translate("dashboard", "memUsage") %}: ${hostStats.mem_usage}`);
2021-02-27 12:05:04 +00:00
mem_percent.textContent = hostStats.mem_percent + '%';
});
}
2021-08-21 19:17:07 +00:00
if (webSocket) {
webSocket.on('send_start_reload', function (start_error) {
location.reload()
});
}
2021-08-21 20:17:35 +00:00
2021-07-26 22:43:57 +00:00
if (webSocket) {
webSocket.on('update_button_status', function (updateButton) {
var id = 'controls';
2021-07-27 01:05:52 +00:00
var dataId = updateButton.server_id;
2021-07-27 01:39:22 +00:00
var string = updateButton.string
2021-07-26 22:43:57 +00:00
var id = id.concat(updateButton.server_id);
if (updateButton.isUpdating){
console.log(updateButton.isUpdating)
2021-07-27 01:39:22 +00:00
document.getElementById(id).innerHTML = string;
2021-07-26 22:43:57 +00:00
}
else{
2021-07-27 01:05:52 +00:00
window.location.reload()
2021-07-26 22:43:57 +00:00
}
});
}
2021-02-26 15:39:35 +00:00
2021-01-28 18:46:13 +00:00
$( ".clone_button" ).click(function() {
server_id = $(this).attr("data-id");
send_command(server_id, 'clone_server');
bootbox.alert({
backdrop: true,
2021-03-26 13:57:50 +00:00
title: '{% raw translate("dashboard", "sendingCommand") %}',
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > {% raw translate("dashboard", "bePatientClone") %} < / div > '
2021-01-28 18:46:13 +00:00
});
});
2020-08-24 23:11:17 +00:00
});
< / script >
2020-08-13 14:38:36 +00:00
{% end %}