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 %}
2020-08-13 14:38:36 +00:00
{% block title %}Crafty Controller - Dashboard{% end %}
{% block content %}
< div class = "content-wrapper" >
<!-- Page Title Header Starts -->
< div class = "row page-title-header" >
< div class = "col-12" >
< div class = "page-header" >
< h4 class = "page-title" > Dashboard< / h4 >
< / 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" >
2020-08-17 02:47:53 +00:00
< h5 class = "mb-1 font-weight-medium text-primary" > Host< / h5 >
< 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" >
2020-08-28 03:21:55 +00:00
< p class = "mb-0 text-success" data-toggle = "tooltip" data-placement = "top" data-html = "true" title = "CPU Cores: {{ data.get('hosts_data').get('cpu_cores') }} <br /> CPU Cur Freq: {{ data.get('hosts_data').get('cpu_cur_freq') }} <br /> CPU Max Freq: {{ data.get('hosts_data').get('cpu_max_freq') }}" >
{{ data.get('hosts_data').get('cpu_usage') }} {{ _('CPU Usage') }}
< / p >
< p class = "mb-0 text-danger" data-toggle = "tooltip" data-placement = "top" title = "Memory Usage: {{ data.get('hosts_data').get('mem_usage') }}" >
{{ data.get('hosts_data').get('mem_percent') }}% {{ _('Memory Usage') }}
< / 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" >
< h5 class = "mb-1 font-weight-medium text-primary" > 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" >
2020-08-24 17:08:17 +00:00
< p class = "mb-0 text-success" > {{ data['server_stats']['running'] }} {{_('Online')}}< / p >
< p class = "mb-0 text-warning" > {{ data['server_stats']['stopped'] }} {{_('Shutdown')}}< / 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" >
< h5 class = "mb-1 font-weight-medium text-primary" > Players< / h5 >
< h3 class = "mb-0 font-weight-semibold" > 18< / h3 >
< / div >
< div class = "wrapper my-auto ml-auto ml-lg-4" >
2020-09-22 22:23:14 +00:00
< p class = "mb-0 text-success" > 35 Max< / p >
< p class = "mb-0 text-warning" > 10 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" >
< h5 class = "mb-1 font-weight-medium text-primary" > Backups< / h5 >
< h3 class = "mb-0 font-weight-semibold" > 7< / h3 >
< / div >
< div class = "wrapper my-auto ml-auto ml-lg-4" >
< p class = "mb-0 text-success" > Last: 11-31-2020< / p >
< p class = "mb-0 text-success" > Next: 12-05-2020< / p >
< / 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" >
2020-08-28 03:21:55 +00:00
< h4 class = "card-title" > < i class = "fas fa-server" > < / i > All Servers< / h4 >
2020-08-27 23:55:55 +00:00
< div class = "d-md-none" >
< small > Can't see everything on mobile?< br / > Try scrolling the table sideways.< / small >
< / div >
2020-08-28 03:21:55 +00:00
< div > < a class = "nav-link" href = "/server/step1" > < i class = "fas fa-plus-circle" > < / i > Add New Server< / a > < / div >
2020-08-13 14:38:36 +00:00
< / div >
< div class = "card-body" >
< div class = "table-responsive" >
< table class = "table" >
< thead >
< tr class = "rounded" >
< th > Server< / th >
2020-08-24 17:08:17 +00:00
< th > Actions< / th >
2020-08-13 14:38:36 +00:00
< th > CPU< / th >
< th > Memory< / th >
2020-08-24 17:08:17 +00:00
< th > World< / th >
2020-08-13 14:38:36 +00:00
< th > Players< / th >
< th > Status< / th >
< / 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 >
2020-12-10 20:38:44 +00:00
< td class = "actions_serverlist" >
2020-08-24 23:11:17 +00:00
2020-08-27 22:30:56 +00:00
{% if server['stats'][0]['running'] %}
2020-08-31 15:29:32 +00:00
< a class = "stop_button" data-id = "{{server['server_data']['server_id']}}" > < i class = "fas fa-stop" > < / i > < / a >
< a class = "restart_button" data-id = "{{server['server_data']['server_id']}}" > < i class = "fas fa-sync" > < / i > < / a >
2020-08-24 17:08:17 +00:00
{% else %}
2020-08-27 22:30:56 +00:00
< a data-id = "{{server['server_data']['server_id']}}" class = "play_button" > < i class = "fas fa-play" > < / i > < / a >
2021-01-28 18:46:13 +00:00
< a data-id = "{{server['server_data']['server_id']}}" class = "clone_button" > < i class = "fas fa-clone" > < / i > < / a >
2020-08-24 17:08:17 +00:00
{% end %}
2020-09-02 01:30:39 +00:00
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 >
2020-12-10 19:53:03 +00:00
< div class = "progress mb-1" data-toggle = "tooltip" data-placement = "top" title = "{{server['stats'][0]['cpu']}}" >
2020-08-28 00:01:41 +00:00
< div class = "progress-bar
{% if server['stats'][0]['cpu'] < = 33 %}
bg-success
{% elif 34 < = server['stats'][0]['cpu'] < = 66 %}
bg-warning
{% else %}
bg-danger
{% end %}
" role="progressbar" style="width: {{server['stats'][0]['cpu']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">< / div >
2020-08-13 14:38:36 +00:00
< / div >
2020-08-27 22:30:56 +00:00
{{server['stats'][0]['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 >
2020-12-10 19:53:03 +00:00
< div class = "progress mb-1" data-toggle = "tooltip" data-placement = "top" title = "{{server['stats'][0]['mem']}}" >
2020-08-28 00:01:41 +00:00
< div class = "progress-bar
{% if server['stats'][0]['mem_percent'] < = 33 %}
bg-success
{% elif 34 < = server['stats'][0]['mem_percent'] < = 66 %}
bg-warning
{% else %}
bg-danger
{% end %}
" role="progressbar" style="width: {{server['stats'][0]['mem_percent']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">< / div >
2020-08-13 14:38:36 +00:00
< / div >
2020-08-31 17:46:25 +00:00
{{server['stats'][0]['mem_percent']}}% -
{% if server['stats'][0]['mem'] == 0 %}
0 MB
{% else %}
{{server['stats'][0]['mem']}}
{% end %}
2020-08-13 14:38:36 +00:00
< / td >
< td >
2020-08-27 22:30:56 +00:00
{{ server['stats'][0]['world_name'] }} : {{ server['stats'][0]['world_size'] }}
2020-08-13 14:38:36 +00:00
< / td >
< td >
2020-08-27 22:30:56 +00:00
{% if server['stats'][0]['int_ping_results'] %}
{{ server['stats'][0]['online'] }} / {{ server['stats'][0]['max'] }} Max< br / >
2020-08-31 17:46:25 +00:00
{% if server['stats'][0]['desc'] != 'False' %}
{{ server['stats'][0]['desc'] }} < br / >
{% end %}
{% if server['stats'][0]['version'] != 'False' %}
{{ server['stats'][0]['version'] }}
{% 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 >
2020-08-27 22:30:56 +00:00
{% if server['stats'][0]['running'] %}
2020-08-13 14:38:36 +00:00
< i class = "fas fa-thumbs-up" > < / i > < span class = "text-success" > Online< / span >
2020-08-24 17:08:17 +00:00
{% else %}
< i class = "fas fa-thumbs-down" > < / i > < span class = "text-danger" > Offline< / span >
{% 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){
<!-- this getCookie function is in base.html -->
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);
setTimeout(function(){ location.reload(); }, 10000);
}
});
}
$( 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,
title: "Sending your command",
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > Please be patient while we start the server< br / > This screen will refresh in a moment < / div > '
});
});
$( ".stop_button" ).click(function() {
console.log("stopping server");
server_id = $(this).attr("data-id");
send_command(server_id, 'stop_server');
bootbox.alert({
backdrop: true,
title: "Sending your command",
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > Please be patient while we stop the server< br / > This screen will refresh in a moment < / div > '
});
});
$( ".restart_button" ).click(function() {
server_id = $(this).attr("data-id");
send_command(server_id, 'restart_server');
bootbox.alert({
backdrop: true,
title: "Sending your command",
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > Please be patient while we restart the server< br / > This screen will refresh in a moment < / div > '
});
});
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,
title: "Sending your command",
message: '< div align = "center" > < i class = "fas fa-spin fa-spinner" > < / i > Please be patient while we clone the server< br / > This screen will refresh in a moment < / div > '
});
});
2020-08-24 23:11:17 +00:00
});
< / script >
2020-08-13 14:38:36 +00:00
{% end %}