2021-08-27 01:06:22 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from app.classes.web.base_handler import BaseHandler
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2022-03-23 02:50:12 +00:00
|
|
|
|
2021-08-27 01:06:22 +00:00
|
|
|
class StatusHandler(BaseHandler):
|
|
|
|
def get(self):
|
|
|
|
page_data = {}
|
2022-04-11 05:23:55 +00:00
|
|
|
page_data["lang"] = self.helper.get_setting("language")
|
2022-04-14 23:34:21 +00:00
|
|
|
page_data["lang_page"] = self.helper.get_lang_page(
|
2022-04-11 10:08:36 +00:00
|
|
|
self.helper.get_setting("language")
|
|
|
|
)
|
2022-03-23 02:50:12 +00:00
|
|
|
page_data["servers"] = self.controller.servers.get_all_servers_stats()
|
2022-03-08 00:57:52 +00:00
|
|
|
running = 0
|
2022-03-23 02:50:12 +00:00
|
|
|
for srv in page_data["servers"]:
|
|
|
|
if srv["stats"]["running"]:
|
2022-03-08 00:57:52 +00:00
|
|
|
running += 1
|
2022-03-23 02:50:12 +00:00
|
|
|
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
|
2021-08-27 01:06:22 +00:00
|
|
|
|
2022-03-23 02:50:12 +00:00
|
|
|
page_data["running"] = running
|
2022-03-08 00:57:52 +00:00
|
|
|
|
2022-03-23 02:50:12 +00:00
|
|
|
template = "public/status.html"
|
2021-08-27 01:06:22 +00:00
|
|
|
|
|
|
|
self.render(
|
2022-03-23 02:50:12 +00:00
|
|
|
template,
|
|
|
|
data=page_data,
|
|
|
|
translate=self.translator.translate,
|
|
|
|
)
|
|
|
|
|
2021-08-27 01:06:22 +00:00
|
|
|
def post(self):
|
|
|
|
page_data = {}
|
2022-03-23 02:50:12 +00:00
|
|
|
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"
|
2021-08-27 01:06:22 +00:00
|
|
|
|
|
|
|
self.render(
|
2022-03-23 02:50:12 +00:00
|
|
|
template,
|
|
|
|
data=page_data,
|
|
|
|
translate=self.translator.translate,
|
|
|
|
)
|