From e43c63a8b754333dc9eb356c0b71c39455a96c30 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 30 Jan 2023 18:31:46 -0500 Subject: [PATCH] Fix db not found issue Add page feedback. --- app/classes/controllers/servers_controller.py | 2 + app/classes/shared/main_controller.py | 31 +++++++++++++- app/classes/shared/server.py | 2 + .../templates/panel/panel_config.html | 41 +++++++++++++++++-- 4 files changed, 72 insertions(+), 4 deletions(-) diff --git a/app/classes/controllers/servers_controller.py b/app/classes/controllers/servers_controller.py index 4c97a6c7..b2b1e126 100644 --- a/app/classes/controllers/servers_controller.py +++ b/app/classes/controllers/servers_controller.py @@ -101,7 +101,9 @@ class ServersController(metaclass=Singleton): server_instance: ServerInstance = ServersController().get_server_instance_by_id( server_obj.server_id ) + print("before update", server_instance.server_path) server_instance.update_server_instance() + print("after update", server_instance.server_path) return ret def get_history_stats(self, server_id, days): diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index d4c5535d..21864b96 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -6,6 +6,7 @@ import platform import shutil import time import logging +import threading from peewee import DoesNotExist # TZLocal is set as a hidden import on win pipeline @@ -1010,6 +1011,22 @@ class Controller: HelpersManagement.set_master_server_dir(server_dir) def update_master_server_dir(self, server_dir, user_id): + move_thread = threading.Thread( + name="dir_move", + target=self.t_update_master_server_dir, + daemon=True, + args=( + server_dir, + user_id, + ), + ) + move_thread.start() + return + + def t_update_master_server_dir(self, server_dir, user_id): + self.helper.websocket_helper.broadcast_page( + "/panel/panel_config", "move_status", "Checking dir" + ) if self.management.get_master_server_dir() == server_dir: logger.info( "Admin tried to change server dir to current server dir. Canceling..." @@ -1021,7 +1038,9 @@ class Controller: " current server dir. This will result in a copy loop." ) self.helper.servers_dir = server_dir - + self.helper.websocket_helper.broadcast_page( + "/panel/panel_config", "move_status", "Checking permissions" + ) if not self.helper.ensure_dir_exists(os.path.join(server_dir, "servers")): self.helper.websocket_helper.broadcast_user( user_id, @@ -1042,6 +1061,11 @@ class Controller: server_dir, "servers", server.get("server_uuid") ) if os.path.isdir(server_path): + self.helper.websocket_helper.broadcast_page( + "/panel/panel_config", + "move_status", + f"Moving {server.get('server_name')}", + ) self.file_helper.move_dir( server_path, new_server_path, @@ -1057,3 +1081,8 @@ class Controller: else: self.servers.update_unloaded_server(server_obj) self.servers.init_all_servers() + self.helper.websocket_helper.broadcast_page( + "/panel/panel_config", + "move_status", + "done", + ) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 1b277a76..3a1ae2d6 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -156,6 +156,8 @@ class ServerInstance: self.jar_update_url = server_data.executable_update_url self.name = server_data.server_name self.server_object = server_data + self.stats_helper.select_database() + self.reload_server_settings() def reload_server_settings(self): server_data = HelperServers.get_server_data_by_id(self.server_id) diff --git a/app/frontend/templates/panel/panel_config.html b/app/frontend/templates/panel/panel_config.html index 92be46db..d002f636 100644 --- a/app/frontend/templates/panel/panel_config.html +++ b/app/frontend/templates/panel/panel_config.html @@ -252,6 +252,8 @@   +
+ @@ -274,6 +276,29 @@ color: white !important; ; } + + .loading:after { + overflow: hidden; + display: inline-block; + vertical-align: bottom; + -webkit-animation: ellipsis steps(4, end) 900ms infinite; + animation: ellipsis steps(4, end) 900ms infinite; + content: "\2026"; + /* ascii code for the ellipsis character */ + width: 0px; + } + + @keyframes ellipsis { + to { + width: 1.25em; + } + } + + @-webkit-keyframes ellipsis { + to { + width: 1.25em; + } + } @@ -281,6 +306,19 @@ {% block js %}