diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 4a5615a5..e25ee545 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -208,17 +208,14 @@ class PanelHandler(BaseHandler): user_order = user_order['server_order'].split(',') page_servers = [] server_ids = [] - un_used_servers = defined_servers for server_id in user_order: - for server in un_used_servers: + for server in defined_servers: if str(server['server_id']) == str(server_id): page_servers.append(server) - un_used_servers.remove(server) - user_order.remove(server_id) - for server in un_used_servers: + for server in defined_servers: server_ids.append(str(server['server_id'])) if server not in page_servers: page_servers.append(server) @@ -340,30 +337,18 @@ class PanelHandler(BaseHandler): un_used_servers = page_data['servers'] flag = 0 - for server_id in user_order: - for server in un_used_servers: - if flag == 0: - server['stats']['downloading'] = self.controller.servers.get_download_status( - str(server['stats']['server_id']['server_id'])) - server['stats']['crashed'] = self.controller.servers.is_crashed( - str(server['stats']['server_id']['server_id'])) - try: - server['stats']['waiting_start'] = self.controller.servers.get_waiting_start( - str(server['stats']['server_id']['server_id'])) - except Exception as e: - logger.error(f"Failed to get server waiting to start: {e}") - server['stats']['waiting_start'] = False + user_order = self.controller.users.get_user_by_id(exec_user['user_id']) + user_order = user_order['server_order'].split(',') + page_servers = [] + server_ids = [] + for server_id in user_order: + for server in page_data['servers']: if str(server['server_data']['server_id']) == str(server_id): page_servers.append(server) - un_used_servers.remove(server) - user_order.remove(server_id) - #we only want to set these server stats values once. We need to update the flag so it only hits that if once. - flag += 1 - - for server in un_used_servers: + for server in page_data['servers']: server_ids.append(str(server['server_data']['server_id'])) if server not in page_servers: page_servers.append(server) @@ -374,6 +359,17 @@ class PanelHandler(BaseHandler): page_data['servers'] = page_servers + for data in page_data['servers']: + data['stats']['crashed'] = self.controller.servers.is_crashed( + str(data['stats']['server_id']['server_id'])) + try: + data['stats']['waiting_start'] = self.controller.servers.get_waiting_start( + str(data['stats']['server_id']['server_id'])) + except Exception as e: + logger.error(f"Failed to get server waiting to start: {e}") + data['stats']['waiting_start'] = False + + for data in page_data['servers']: data['stats']['crashed'] = self.controller.servers.is_crashed( str(data['stats']['server_id']['server_id']))