mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
206dc956cf
Move background to top of html for better loading
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
import logging
|
|
|
|
from app.classes.web.base_handler import BaseHandler
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class StatusHandler(BaseHandler):
|
|
def get(self):
|
|
page_data = {"background": self.controller.cached_login}
|
|
page_data["lang"] = self.helper.get_setting("language")
|
|
page_data["lang_page"] = self.helper.get_lang_page(
|
|
self.helper.get_setting("language")
|
|
)
|
|
page_data["servers"] = self.controller.servers.get_all_servers_stats()
|
|
running = 0
|
|
for srv in page_data["servers"]:
|
|
if srv["stats"]["running"]:
|
|
running += 1
|
|
server_data = srv.get("server_data", False)
|
|
server_id = server_data.get("server_id", False)
|
|
srv["raw_ping_result"] = self.controller.servers.get_server_stats_by_id(
|
|
server_id
|
|
)
|
|
if "icon" not in srv["raw_ping_result"]:
|
|
srv["raw_ping_result"]["icon"] = False
|
|
|
|
page_data["running"] = running
|
|
|
|
template = "public/status.html"
|
|
|
|
self.render(
|
|
template,
|
|
data=page_data,
|
|
translate=self.translator.translate,
|
|
)
|
|
|
|
def post(self):
|
|
page_data = {}
|
|
page_data["servers"] = self.controller.servers.get_all_servers_stats()
|
|
for srv in page_data["servers"]:
|
|
server_data = srv.get("server_data", False)
|
|
server_id = server_data.get("server_id", False)
|
|
srv["raw_ping_result"] = self.controller.servers.get_server_stats_by_id(
|
|
server_id
|
|
)
|
|
template = "public/status.html"
|
|
|
|
self.render(
|
|
template,
|
|
data=page_data,
|
|
translate=self.translator.translate,
|
|
)
|