From b385d1add351a4a132dbcc3736c4c82c58b472ed Mon Sep 17 00:00:00 2001 From: Silversthorn Date: Wed, 19 Jan 2022 22:45:52 +0100 Subject: [PATCH] Add Update Dashboard by websocket --- app/classes/shared/tasks.py | 3 +- app/frontend/templates/panel/dashboard.html | 546 ++++++++++++-------- app/frontend/templates/public/status.html | 9 +- 3 files changed, 348 insertions(+), 210 deletions(-) diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index 9632f096..1a2d633e 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -306,6 +306,7 @@ class TasksManager: srv['raw_ping_result'] = self.controller.stats.get_raw_server_stats(server_id) if ("{}".format(srv['raw_ping_result'].get('icon')) == "b''"): srv['raw_ping_result']['icon'] = False + servers_ping.append({ 'id': srv['raw_ping_result'].get('id'), 'started': srv['raw_ping_result'].get('started'), @@ -326,8 +327,8 @@ class TasksManager: }) if (len(servers_ping) > 0) & (len(websocket_helper.clients) > 0): - #TODO websocket_helper.broadcast_page('/panel/dashboard', 'update_server_status', servers) try: + websocket_helper.broadcast_page('/panel/dashboard', 'update_server_status', servers_ping) websocket_helper.broadcast_page('/status', 'update_server_status', servers_ping) except: console.warning("Can't broadcast server status to websocket") diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 0b584423..6e4b89fd 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -1,7 +1,6 @@ {% extends ../base.html %} {% block meta %} - {% end %} {% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard', data['lang']) }}{% end %} @@ -10,7 +9,7 @@
- +