mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
added max_log_lines to config.json, added server_logs subpage, split server details top part to it's own include
This commit is contained in:
parent
adf8d3f51a
commit
9ded6a1a4b
@ -40,6 +40,7 @@ class AjaxHandler(BaseHandler):
|
||||
|
||||
elif page == 'server_log':
|
||||
server_id = self.get_argument('id', None)
|
||||
full_log = self.get_argument('full', False)
|
||||
|
||||
if server_id is None:
|
||||
logger.warning("Server ID not found in server_log ajax call")
|
||||
@ -56,7 +57,12 @@ class AjaxHandler(BaseHandler):
|
||||
if server_data['log_path']:
|
||||
logger.warning("Server ID not found in server_log ajax call")
|
||||
|
||||
log_lines = helper.get_setting('virtual_terminal_lines')
|
||||
if full_log:
|
||||
log_lines = helper.get_setting('max_log_lines')
|
||||
else:
|
||||
log_lines = helper.get_setting('virtual_terminal_lines')
|
||||
|
||||
print(log_lines)
|
||||
data = helper.tail_file(server_data['log_path'], log_lines)
|
||||
|
||||
for d in data:
|
||||
|
@ -84,7 +84,7 @@ class PanelHandler(BaseHandler):
|
||||
self.redirect("/panel/error?error=Invalid Server ID")
|
||||
return False
|
||||
|
||||
valid_subpages = ['term']
|
||||
valid_subpages = ['term', 'logs']
|
||||
|
||||
if subpage not in valid_subpages:
|
||||
subpage = 'term'
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"last_refreshed": "09/01/2020, 12:53:08",
|
||||
"last_refreshed": "09/03/2020, 22:13:41",
|
||||
"servers": {
|
||||
"nukkitx": [
|
||||
"1.14"
|
||||
|
43
app/frontend/templates/panel/parts/details_stats.html
Normal file
43
app/frontend/templates/panel/parts/details_stats.html
Normal file
@ -0,0 +1,43 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-12 grid-margin">
|
||||
<div class="card">
|
||||
<div class="card-body pt-3 pb-3">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 mr-2">
|
||||
<b>Server Status:</b>
|
||||
{% if data['server_stats'][0]['running'] %}
|
||||
<span class="text-success">Online</span><br />
|
||||
<b>Server Started:</b> {{ data['server_stats'][0]['started'] }}
|
||||
{% else %}
|
||||
<span class="text-danger">Offline</span><br />
|
||||
<b>Server Started:</b> Not Started
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mr-2">
|
||||
<b>CPU:</b> {{ data['server_stats'][0]['cpu'] }}% <br />
|
||||
<b>Mem:</b> {{ data['server_stats'][0]['mem'] }} <br />
|
||||
{% if data['server_stats'][0]['int_ping_results'] %}
|
||||
<b>Players:</b> {{ data['server_stats'][0]['online'] }} / {{ data['server_stats'][0]['max'] }}<br />
|
||||
{% else %}
|
||||
<b>Players:</b> 0/0<br />
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mr-2">
|
||||
{% if data['server_stats'][0]['version'] != 'False' %}
|
||||
<b>Server:</b> {{ data['server_stats'][0]['version'] }} <br />
|
||||
<b>Desc:</b> {{ data['server_stats'][0]['desc'] }} <br />
|
||||
{% else %}
|
||||
<b>Server:</b> Unable To Connect <br />
|
||||
<b>Desc:</b> Unable To Connect <br />
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
123
app/frontend/templates/panel/server_logs.html
Normal file
123
app/frontend/templates/panel/server_logs.html
Normal file
@ -0,0 +1,123 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Server Details{% 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">
|
||||
Server Details - {{ data['server_stats'][0]['server_id']['server_name'] }}
|
||||
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Page Title Header Ends-->
|
||||
|
||||
{% include "parts/details_stats.html %}
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-12 grid-margin">
|
||||
<div class="card">
|
||||
<div class="card-body pt-0">
|
||||
|
||||
<ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=term" role="tab" aria-selected="false">
|
||||
<i class="fas fa-terminal"></i>Terminal</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=logs" role="tab" aria-selected="true">
|
||||
<i class="fas fa-file-signature"></i>Logs</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=tasks" role="tab" aria-selected="false">
|
||||
<i class="fas fa-clock"></i>Schedule</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=backup" role="tab" aria-selected="false">
|
||||
<i class="fas fa-save"></i>Backup</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=files" role="tab" aria-selected="false">
|
||||
<i class="fas fa-folder-tree"></i>Files</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=config" role="tab" aria-selected="false">
|
||||
<i class="fas fa-cogs"></i>Config</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="input-group">
|
||||
<div id="virt_console" class="" style="font-size: .8em; padding: 5px 10px; border: 1px solid #383e5d; background-color:#2a2c44;height:500px; overflow: scroll;"></div>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
{% end %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
function get_server_log(){
|
||||
if( !$("#stop_scroll").is(':checked')){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/ajax/server_log?id={{ data['server_stats'][0]['server_id']['server_id'] }}&full=1',
|
||||
dataType: 'text',
|
||||
success: function (data) {
|
||||
console.log('Got Log From Server')
|
||||
$('#virt_console').html(data);
|
||||
scroll();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
|
||||
function getCookie(name) {
|
||||
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
|
||||
return r ? r[1] : undefined;
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
console.log( "ready!" );
|
||||
get_server_log()
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function scroll(){
|
||||
var logview = $('#virt_console');
|
||||
if(logview.length)
|
||||
logview.scrollTop(logview[0].scrollHeight - logview.height());
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{% end %}
|
@ -24,50 +24,7 @@
|
||||
</div>
|
||||
<!-- Page Title Header Ends-->
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-12 grid-margin">
|
||||
<div class="card">
|
||||
<div class="card-body pt-3 pb-3">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 mr-2">
|
||||
<b>Server Status:</b>
|
||||
{% if data['server_stats'][0]['running'] %}
|
||||
<span class="text-success">Online</span><br />
|
||||
<b>Server Started:</b> {{ data['server_stats'][0]['started'] }}
|
||||
{% else %}
|
||||
<span class="text-danger">Offline</span><br />
|
||||
<b>Server Started:</b> Not Started
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mr-2">
|
||||
<b>CPU:</b> {{ data['server_stats'][0]['cpu'] }}% <br />
|
||||
<b>Mem:</b> {{ data['server_stats'][0]['mem'] }} <br />
|
||||
{% if data['server_stats'][0]['int_ping_results'] %}
|
||||
<b>Players:</b> {{ data['server_stats'][0]['online'] }} / {{ data['server_stats'][0]['max'] }}<br />
|
||||
{% else %}
|
||||
<b>Players:</b> 0/0<br />
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mr-2">
|
||||
{% if data['server_stats'][0]['version'] != 'False' %}
|
||||
<b>Server:</b> {{ data['server_stats'][0]['version'] }} <br />
|
||||
<b>Desc:</b> {{ data['server_stats'][0]['desc'] }} <br />
|
||||
{% else %}
|
||||
<b>Server:</b> Unable To Connect <br />
|
||||
<b>Desc:</b> Unable To Connect <br />
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% include "parts/details_stats.html %}
|
||||
|
||||
<div class="row">
|
||||
|
||||
@ -78,26 +35,26 @@
|
||||
<ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=term" role="tab" aria-selected="true">
|
||||
<i class="fas fa-terminal"></i>Terminal</a>
|
||||
<i class="fas fa-file-signature"></i>Terminal</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#message-2-2" role="tab" aria-selected="false">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=logs" role="tab" aria-selected="false">
|
||||
<i class="fas fa-file-signature"></i>Logs</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#campaigns-2-3" role="tab" aria-selected="false">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=tasks" role="tab" aria-selected="false">
|
||||
<i class="fas fa-clock"></i>Schedule</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#influencers-2-4" role="tab" aria-selected="false">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=backup" role="tab" aria-selected="false">
|
||||
<i class="fas fa-save"></i>Backup</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#payments-2-5" role="tab" aria-selected="false">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=files" role="tab" aria-selected="false">
|
||||
<i class="fas fa-folder-tree"></i>Files</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#analytics-2-6" role="tab" aria-selected="false">
|
||||
<a class="nav-link" href="/panel/server_detail?id={{ data['server_stats'][0]['server_id']['server_id'] }}&subpage=config" role="tab" aria-selected="false">
|
||||
<i class="fas fa-cogs"></i>Config</a>
|
||||
</li>
|
||||
<li>
|
||||
@ -108,7 +65,6 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="input-group">
|
||||
<div id="virt_console" class="" style="font-size: .8em; padding: 5px 10px; border: 1px solid #383e5d; background-color:#2a2c44;height:500px; overflow: scroll;"></div>
|
||||
|
@ -11,6 +11,7 @@
|
||||
"max_stats_count": 1000,
|
||||
"delete_default_json": false,
|
||||
"show_contribute_link": true,
|
||||
"virtual_terminal_lines": 100,
|
||||
"virtual_terminal_lines": 10,
|
||||
"max_log_lines": 700,
|
||||
"keywords": ["help", "chunk"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user