mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-18 17:15:13 +01:00
added version string to page footer
created/working on server details subpages. added "may take a few seconds" to cmd error page is now available to panel created server_id_exists function more error checking around database returns from db_helper starting styling / backend for virtual terminal
This commit is contained in:
parent
c5bf170a33
commit
ab1772397d
@ -42,7 +42,7 @@ class MainPrompt(cmd.Cmd):
|
||||
|
||||
def do_exit(self, line):
|
||||
logger.info("Stopping all server daemons / threads")
|
||||
console.info("Stopping all server daemons / threads")
|
||||
console.info("Stopping all server daemons / threads - This may take a few seconds")
|
||||
self._clean_shutdown()
|
||||
while True:
|
||||
if tasks_manager.get_main_thread_run_status():
|
||||
|
@ -202,7 +202,11 @@ class db_shortcuts:
|
||||
return rows
|
||||
|
||||
def get_server_data_by_id(self, server_id):
|
||||
query = Servers.get_by_id(server_id)
|
||||
try:
|
||||
query = Servers.get_by_id(server_id)
|
||||
except DoesNotExist:
|
||||
return {}
|
||||
|
||||
return model_to_dict(query)
|
||||
|
||||
def get_all_defined_servers(self):
|
||||
@ -218,6 +222,15 @@ class db_shortcuts:
|
||||
server_data.append({'server_data': s, "stats": self.return_rows(latest)})
|
||||
return server_data
|
||||
|
||||
def get_server_stats_by_id(self, server_id):
|
||||
stats = Server_Stats.select().where(Server_Stats.server_id == server_id).order_by(Server_Stats.created.desc()).limit(1)
|
||||
return self.return_rows(stats)
|
||||
|
||||
def server_id_exists(self, server_id):
|
||||
if not self.get_server_data_by_id(server_id):
|
||||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def get_latest_hosts_stats():
|
||||
query = Host_Stats.select().order_by(Host_Stats.id.desc()).get()
|
||||
@ -254,7 +267,6 @@ class db_shortcuts:
|
||||
Commands.executed: True
|
||||
}).where(Commands.command_id == command_id).execute()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def add_to_audit_log(user_id, log_msg, server_id=None, source_ip=None):
|
||||
logger.debug("Adding to audit log User:{} - Message: {} ".format(user_id, log_msg))
|
||||
|
@ -51,7 +51,8 @@ class TasksManager:
|
||||
self._main_graceful_exit()
|
||||
time.sleep(5)
|
||||
|
||||
def command_watcher(self):
|
||||
@staticmethod
|
||||
def command_watcher():
|
||||
while True:
|
||||
# select any commands waiting to be processed
|
||||
commands = db_helper.get_unactioned_commands()
|
||||
@ -74,8 +75,6 @@ class TasksManager:
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
# def parse_command(self, command):
|
||||
|
||||
|
||||
def _main_graceful_exit(self):
|
||||
try:
|
||||
|
@ -18,15 +18,15 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
@tornado.web.authenticated
|
||||
def get(self, page):
|
||||
# name = tornado.escape.json_decode(self.current_user)
|
||||
user_data = json.loads(self.get_secure_cookie("user_data"))
|
||||
error = bleach.clean(self.get_argument('error', "WTF Error!"))
|
||||
|
||||
template = "panel/denied.html"
|
||||
|
||||
defined_servers = controller.list_defined_servers()
|
||||
|
||||
page_data = {
|
||||
'version_data': "version_data_here",
|
||||
'version_data': helper.get_version_string(),
|
||||
'user_data': user_data,
|
||||
'server_stats': {
|
||||
'total': len(defined_servers),
|
||||
@ -35,7 +35,8 @@ class PanelHandler(BaseHandler):
|
||||
},
|
||||
'menu_servers': defined_servers,
|
||||
'hosts_data': db_helper.get_latest_hosts_stats(),
|
||||
'show_contribute': helper.get_setting("show_contribute_link", True)
|
||||
'show_contribute': helper.get_setting("show_contribute_link", True),
|
||||
'error': error
|
||||
}
|
||||
|
||||
# if no servers defined, let's go to the build server area
|
||||
@ -47,6 +48,9 @@ class PanelHandler(BaseHandler):
|
||||
if page == 'unauthorized':
|
||||
template = "panel/denied.html"
|
||||
|
||||
elif page == "error":
|
||||
template = "public/error.html"
|
||||
|
||||
elif page == 'credits':
|
||||
template = "panel/credits.html"
|
||||
|
||||
@ -66,8 +70,31 @@ class PanelHandler(BaseHandler):
|
||||
template = "panel/dashboard.html"
|
||||
|
||||
elif page == 'server_detail':
|
||||
server_id = self.get_argument('id', None)
|
||||
subpage = bleach.clean(self.get_argument('subpage', ""))
|
||||
|
||||
template = "panel/server_details.html"
|
||||
if server_id is None:
|
||||
self.redirect("/panel/error?error=Invalid Server ID")
|
||||
return False
|
||||
else:
|
||||
server_id = bleach.clean(server_id)
|
||||
|
||||
# does this server id exist?
|
||||
if not db_helper.server_id_exists(server_id):
|
||||
self.redirect("/panel/error?error=Invalid Server ID")
|
||||
return False
|
||||
|
||||
valid_subpages = ['term']
|
||||
|
||||
if subpage not in valid_subpages:
|
||||
subpage = 'term'
|
||||
|
||||
# server_data isn't needed since the server_stats also pulls server data
|
||||
# page_data['server_data'] = db_helper.get_server_data_by_id(server_id)
|
||||
page_data['server_stats'] = db_helper.get_server_stats_by_id(server_id)
|
||||
|
||||
# template = "panel/server_details.html"
|
||||
template = "panel/server_{subpage}.html".format(subpage=subpage)
|
||||
|
||||
|
||||
self.render(
|
||||
|
@ -77,13 +77,13 @@ class PublicHandler(BaseHandler):
|
||||
|
||||
# if we don't have a user
|
||||
if not user_data:
|
||||
next_page = "/public/login?error=Login_Failed"
|
||||
next_page = "/public/error?error=Login_Failed"
|
||||
self.redirect(next_page)
|
||||
return False
|
||||
|
||||
# if they are disabled
|
||||
if not user_data.enabled:
|
||||
next_page = "/public/login?error=Login_Failed"
|
||||
next_page = "/public/error?error=Login_Failed"
|
||||
self.redirect(next_page)
|
||||
return False
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"last_refreshed": "08/31/2020, 11:13:52",
|
||||
"last_refreshed": "09/01/2020, 12:53:08",
|
||||
"servers": {
|
||||
"nukkitx": [
|
||||
"1.14"
|
||||
|
@ -1,56 +0,0 @@
|
||||
{% extends ../base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<!-- <meta http-equiv="refresh" content="60">-->
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - Blank Page{% 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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
{% end %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
|
||||
$( document ).ready(function() {
|
||||
console.log('ready for JS!')
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
{% end %}
|
99
app/frontend/templates/panel/server_term.html
Normal file
99
app/frontend/templates/panel/server_term.html
Normal file
@ -0,0 +1,99 @@
|
||||
{% 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-->
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-12 grid-margin">
|
||||
<div class="card">
|
||||
<div class="card-body pt-0">
|
||||
|
||||
<div class="row ">
|
||||
<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>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#message-2-2" 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">
|
||||
<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">
|
||||
<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">
|
||||
<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">
|
||||
<i class="fas fa-cogs"></i>Config</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="col-md-11">
|
||||
<div class="input-group">
|
||||
<textarea id="virt_console" rows="20" readonly class="form-control" style="background-color:#2a2c44;"></textarea>
|
||||
</div>
|
||||
<br />
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="server_command" name="server_command" placeholder="Enter your server command" autofocus="">
|
||||
<span class="input-group-btn ml-5">
|
||||
<button id="submit" class="btn btn-sm btn-info" type="button">Send Command</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ data['server_stats'] }}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
{% end %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
|
||||
$( document ).ready(function() {
|
||||
console.log('ready for JS!')
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
{% end %}
|
@ -7,7 +7,8 @@
|
||||
"cookie_secret": "random",
|
||||
"show_errors": true,
|
||||
"history_max_age": 7,
|
||||
"stats_update_frequency": 5,
|
||||
"stats_update_frequency": 60,
|
||||
"max_stats_count": 1000,
|
||||
"delete_default_json": false,
|
||||
"show_contribute_link": false
|
||||
"show_contribute_link": true
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user