From cb1679806e5f7ea883606dbef65e71b3e39780a4 Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Thu, 3 Mar 2022 23:13:40 +0100 Subject: [PATCH] Seperate refresh statistics for each server Fixing Broken Things --- app/classes/shared/server.py | 12 +++++++----- app/classes/web/status_handler.py | 7 +++++++ app/frontend/templates/panel/dashboard.html | 21 ++++++++------------- app/frontend/templates/public/status.html | 6 +++--- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index f3a27fa9..0668e847 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -148,6 +148,8 @@ class Server: self.name = serverName self.settings = server_data_obj + self.record_server_stats() + # build our server run command if server_data_obj['auto_start']: @@ -832,8 +834,8 @@ class Server: self.record_server_stats() -#TODO How I do ? -# websocket_helper.broadcast_user_page('/panel/dashboard', user.user_id, 'update_player_status', players_ping) + #TODO How I do ? + #websocket_helper.broadcast_user_page('/panel/dashboard', user.user_id, 'update_player_status', players_ping) if (len(servers_ping) > 0) & (len(websocket_helper.clients) > 0): try: @@ -858,7 +860,7 @@ class Server: self.reload_server_settings() # world data - server_name = server['server_name'] + world_name = server['server_name'] server_path = server['path'] # process stats @@ -867,7 +869,7 @@ class Server: # TODO: search server properties file for possible override of 127.0.0.1 internal_ip = server['server_ip'] server_port = server['server_port'] - server = server.get('server_name', f"ID#{server_id}") + server_name = server.get('server_name', f"ID#{server_id}") logger.debug("Pinging server '{server}' on {internal_ip}:{server_port}") if servers_helper.get_server_type_by_id(server_id) == 'minecraft-bedrock': @@ -1002,7 +1004,7 @@ class Server: server_port = server_dt['server_port'] - logger.debug(f"Pinging server '{server.name}' on {internal_ip}:{server_port}") + logger.debug(f"Pinging server '{self.name}' on {internal_ip}:{server_port}") if servers_helper.get_server_type_by_id(server_id) == 'minecraft-bedrock': int_mc_ping = ping_bedrock(internal_ip, int(server_port)) else: diff --git a/app/classes/web/status_handler.py b/app/classes/web/status_handler.py index 9e76a972..a5b869a8 100644 --- a/app/classes/web/status_handler.py +++ b/app/classes/web/status_handler.py @@ -16,6 +16,10 @@ class StatusHandler(BaseHandler): 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) + srv['raw_ping_result'] + { + 'icon': False, + } template = 'public/status.html' @@ -31,6 +35,9 @@ class StatusHandler(BaseHandler): 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) + { + 'icon': False, + } template = 'public/status.html' diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 9e5a434f..2be0863b 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -155,9 +155,7 @@ data['lang']) }} {% elif server['stats']['waiting_start']%} - {{ translate('dashboard', 'starting', - data['lang']) }} + {{ translate('dashboard', 'starting', data['lang']) }} {% else %} @@ -438,10 +436,7 @@ } function update_servers_status(data) { - console.log(data); - for (server of data) { - update_one_server_status(server); - } + update_one_server_status(data[0]); display_motd(); } @@ -571,15 +566,15 @@