mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Adds status page at /status
This commit is contained in:
parent
4210dfbe77
commit
e4d94fbda5
47
app/classes/web/status_handler.py
Normal file
47
app/classes/web/status_handler.py
Normal file
@ -0,0 +1,47 @@
|
||||
from re import template
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
import tornado.web
|
||||
import tornado.escape
|
||||
import requests
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.web.base_handler import BaseHandler
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.models import Users, fn, db_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import bleach
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical("Import Error: Unable to load {} module".format(e.name), exc_info=True)
|
||||
console.critical("Import Error: Unable to load {} module".format(e.name))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class StatusHandler(BaseHandler):
|
||||
def get(self):
|
||||
page_data = {}
|
||||
page_data['servers'] = db_helper.get_all_servers_stats()
|
||||
|
||||
template = 'public/status.html'
|
||||
|
||||
self.render(
|
||||
template,
|
||||
data=page_data,
|
||||
translate=self.translator.translate,
|
||||
)
|
||||
def post(self):
|
||||
page_data = {}
|
||||
page_data['servers'] = db_helper.get_all_servers_stats()
|
||||
|
||||
template = 'public/status.html'
|
||||
|
||||
self.render(
|
||||
template,
|
||||
data=page_data,
|
||||
translate=self.translator.translate,
|
||||
)
|
@ -29,6 +29,7 @@ try:
|
||||
from app.classes.shared.translation import translation
|
||||
from app.classes.web.upload_handler import UploadHandler
|
||||
from app.classes.web.http_handler import HTTPHandler, HTTPHandlerPage
|
||||
from app.classes.web.status_handler import StatusHandler
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical("Import Error: Unable to load {} module".format(e, e.name))
|
||||
@ -132,6 +133,7 @@ class Webserver:
|
||||
(r'/api/stats/node', NodeStats, handler_args),
|
||||
(r'/ws', SocketHandler, handler_args),
|
||||
(r'/upload', UploadHandler),
|
||||
(r'/status', StatusHandler, handler_args)
|
||||
]
|
||||
|
||||
app = tornado.web.Application(
|
||||
|
@ -80,3 +80,8 @@ body { background-color: var(--dark) !important; /* Firefox */ }
|
||||
.actions_serverlist > a > i {
|
||||
cursor: pointer;
|
||||
}
|
||||
.corner {
|
||||
position: absolute;
|
||||
margin-top: 0;
|
||||
margin-left: 0;
|
||||
}
|
BIN
app/frontend/static/assets/images/logo_long.png
Normal file
BIN
app/frontend/static/assets/images/logo_long.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
@ -11,6 +11,7 @@
|
||||
<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/css/vendor.bundle.base.css">
|
||||
<link rel="stylesheet" href="/static/assest/vendors/css/crafty.css"
|
||||
<!-- endinject -->
|
||||
<!-- Plugin css for this page -->
|
||||
<!-- End Plugin css for this page -->
|
||||
@ -24,7 +25,7 @@
|
||||
<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">
|
||||
<div class="row w-100">
|
||||
<div class="col-lg-4 mx-auto">
|
||||
<div class="mx-auto">
|
||||
|
||||
{% block content %}
|
||||
{% end %}
|
||||
|
68
app/frontend/templates/public/status.html
Normal file
68
app/frontend/templates/public/status.html
Normal file
@ -0,0 +1,68 @@
|
||||
{% extends ../blank_base.html %}
|
||||
|
||||
{% block meta %}
|
||||
<meta http-equiv="refresh" content="30">
|
||||
{% end %}
|
||||
|
||||
{% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard') }}{% end %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content-wrapper col-md login-modal" style="background-color: #222437;">
|
||||
<img src="/static/assets/images/logo_long.png" style='width: 25%; margin-left: 38%;'></img>
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr class="rounded">
|
||||
<th>{{ translate('dashboard', 'server') }}</th>
|
||||
<th>{{ translate('dashboard', 'players') }}</th>
|
||||
<th>{{ translate('dashboard', 'status') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for server in data['servers'] %}
|
||||
<tr>
|
||||
<td>
|
||||
<i class="fas fa-server"></i>
|
||||
{{ server['server_data']['server_name'] }}
|
||||
</td>
|
||||
<td>
|
||||
{% if server['stats']['int_ping_results'] %}
|
||||
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max') }}<br />
|
||||
|
||||
{% if server['stats']['desc'] != 'False' %}
|
||||
{{ server['stats']['desc'] }} <br />
|
||||
{% end %}
|
||||
|
||||
{% if server['stats']['version'] != 'False' %}
|
||||
{{ server['stats']['version'] }}
|
||||
{% end %}
|
||||
{% end %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{% if server['stats']['running'] %}
|
||||
<i class="fas fa-thumbs-up"></i> <span class="text-success">{{ translate('dashboard', 'online') }}</span>
|
||||
{% else %}
|
||||
<i class="fas fa-thumbs-down"></i> <span class="text-danger">{{ translate('dashboard', 'offline') }}</span>
|
||||
{% end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% end %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
|
||||
|
||||
{% end %}
|
||||
|
||||
{% block js %}
|
||||
|
||||
{% end %}
|
Loading…
Reference in New Issue
Block a user