From b039eec857dcfb65a6c7a234c25aa20f9001adfc Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Fri, 5 Aug 2022 17:56:44 -0400 Subject: [PATCH] First commit for unloaded server. Working Frontend --- app/classes/controllers/servers_controller.py | 2 + app/classes/web/panel_handler.py | 1 + app/frontend/templates/panel/dashboard.html | 101 ++++++++++-------- 3 files changed, 60 insertions(+), 44 deletions(-) diff --git a/app/classes/controllers/servers_controller.py b/app/classes/controllers/servers_controller.py index 0e5f3f5f..ba9803c4 100644 --- a/app/classes/controllers/servers_controller.py +++ b/app/classes/controllers/servers_controller.py @@ -146,6 +146,7 @@ class ServersController(metaclass=Singleton): def init_all_servers(self): servers = self.get_all_defined_servers() + self.failed_servers = [] for server in servers: server_id = server.get("server_id") @@ -169,6 +170,7 @@ class ServersController(metaclass=Singleton): f"{server['server_name']} at path {server['path']}. " f"Skipping this server" ) + self.failed_servers.append(server) continue temp_server_dict = { diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index b5a07eb3..00cbbd83 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -287,6 +287,7 @@ class PanelHandler(BaseHandler): "update_available": self.helper.update_available, "serverTZ": tz, "version_data": self.helper.get_version_string(), + "failed_servers": self.controller.servers.failed_servers, "user_data": exec_user, "user_role": exec_user_role, "user_crafty_permissions": exec_user_crafty_permissions, diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 00aee7e1..ec5a21db 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -60,12 +60,12 @@

+ title="{% raw translate('dashboard', 'cpuCores', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cores') }}
{% raw translate('dashboard', 'cpuCurFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cur_freq') }}
{% raw translate('dashboard', 'cpuMaxFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_max_freq') }}"> {{ translate('dashboard', 'cpuUsage', data['lang']) }}: {{ data.get('hosts_data').get('cpu_usage') }}

+ title="{{ translate('dashboard', 'memUsage', data['lang']) }}: {{ data.get('hosts_data').get('mem_usage') }}"> {{ translate('dashboard', 'memUsage', data['lang']) }}: {{ data.get('hosts_data').get('mem_percent') }}%

@@ -116,8 +116,8 @@ {% if len(data['servers']) > 0 %} {% if data['user_data']['hints'] %} + data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" , + data-placement="top"> {% end %} {% end %}
  {{ @@ -125,7 +125,7 @@
- {% if len(data['servers']) == 0%} + {% if len(data['servers']) == 0 and len(data['failed_servers']) == 0 %}

{{ translate('dashboard', 'welcome', data['lang']) }}


@@ -134,7 +134,7 @@
{% end %} - {% if len(data['servers']) > 0 %} + {% if len(data['servers']) > 0 or len(data['failed_servers']) > 0 %}
@@ -156,7 +156,7 @@ {% if server['alert'] %} + href="/panel/server_detail?id={{server['server_data']['server_id']}}"> {{ server['server_data']['server_name'] }}  {% else %} @@ -170,17 +170,17 @@ {% if server['user_command_permission'] %} {% if server['stats']['running'] %} + title="{{ translate('dashboard', 'stop' , data['lang']) }}">   + title="{{ translate('dashboard', 'restart' , data['lang']) }}">   + title="{{ translate('dashboard', 'kill' , data['lang']) }}">   @@ -199,15 +199,15 @@ data['lang']) }} {% else %} + title="{{ translate('dashboard', 'start' , data['lang']) }}">   + title="{{ translate('dashboard', 'clone' , data['lang']) }}">   + title="{{ translate('dashboard', 'kill' , data['lang']) }}">   {% end %} @@ -216,7 +216,7 @@ + data-players="{{ server['stats']['online']}}" data-max="{{ server['stats']['max'] }}"> + + {% end %} + {% for server in data['failed_servers'] %} + + + + + + + + {% end %} @@ -306,27 +319,27 @@
+ class="btn btn-link d-flex justify-content-start" type="button"> {% if server['stats']['running'] %} {{ translate('dashboard', 'online', data['lang']) }} @@ -348,22 +361,22 @@
+ aria-labelledby="heading-{{server['server_data']['server_id']}}" data-parent="#accordionServers">
{{ translate('dashboard', 'cpuUsage', data['lang']) }}
+ title="{{server['stats']['cpu']}}">
+ aria-valuemax="100">
{{server['stats']['cpu']}}%
@@ -452,7 +465,7 @@
{{ translate('dashboard', 'memUsage', data['lang']) }}
+ title="{{server['stats']['mem']}}">
+ aria-valuemin="0" aria-valuemax="100">
{{server['stats']['mem_percent']}}% - @@ -492,7 +505,7 @@ {% if server['stats']['desc'] != 'False' %}
+ style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;"> {{ server['stats']['desc'] }}

{% end %}
+ title="{{server['stats']['cpu']}}">
+ aria-valuemin="0" aria-valuemax="100">
{{server['stats']['cpu']}}%
+ title="{{server['stats']['mem']}}">
+ aria-valuemin="0" aria-valuemax="100">
{{server['stats']['mem_percent']}}% - @@ -263,7 +263,7 @@ {% if server['stats']['desc'] != 'False' %}
{{ + style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{ server['stats']['desc'] }}

{% end %} @@ -287,7 +287,20 @@ {% end %}
 {{server['server_name']}} +  Unloaded