From 4f7e1bfa24bd6c1328f57310fbf3219a6ee98772 Mon Sep 17 00:00:00 2001 From: luukas Date: Wed, 6 Jul 2022 19:00:17 +0300 Subject: [PATCH 01/23] Check for None when getting the CPU frequency data Default to -1 when an error occurs --- app/classes/minecraft/stats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/classes/minecraft/stats.py b/app/classes/minecraft/stats.py index 64cbf894..ab75da51 100644 --- a/app/classes/minecraft/stats.py +++ b/app/classes/minecraft/stats.py @@ -87,7 +87,9 @@ class Stats: try: cpu_freq = psutil.cpu_freq() except NotImplementedError: - cpu_freq = psutil._common.scpufreq(current=0, min=0, max=0) + cpu_freq = None + if cpu_freq is None: + cpu_freq = psutil._common.scpufreq(current=-1, min=-1, max=-1) memory = psutil.virtual_memory() try: node_stats: NodeStatsDict = { From 11260a34d68a18f3d543d7159084a3c118760999 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 14 Jul 2022 18:26:42 -0400 Subject: [PATCH 02/23] Toggle Visible servers on status page --- app/classes/models/servers.py | 5 ++ app/classes/web/panel_handler.py | 2 + app/frontend/static/assets/css/crafty.css | 12 +++++ .../templates/panel/server_config.html | 47 +++++++++++++++---- app/frontend/templates/public/status.html | 2 + app/migrations/20220226_server_order copy.py | 16 +++++++ app/translations/en_EN.json | 3 +- 7 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 app/migrations/20220226_server_order copy.py diff --git a/app/classes/models/servers.py b/app/classes/models/servers.py index 5a9bb268..0e2d0f80 100644 --- a/app/classes/models/servers.py +++ b/app/classes/models/servers.py @@ -1,3 +1,4 @@ +from http import server import logging import datetime import typing as t @@ -37,6 +38,7 @@ class Servers(BaseModel): server_port = IntegerField(default=25565) logs_delete_after = IntegerField(default=0) type = CharField(default="minecraft-java") + show_status = BooleanField(default=1) class Meta: table_name = "servers" @@ -63,6 +65,7 @@ class HelperServers: server_log_file: str, server_stop: str, server_type: str, + show_status: bool, server_port: int = 25565, server_host: str = "127.0.0.1", ) -> int: @@ -80,6 +83,7 @@ class HelperServers: server_type: This is the type of server you're creating. server_port: The port the server will be monitored on, defaults to 25565 server_host: The host the server will be monitored on, defaults to 127.0.0.1 + show_status: Should Crafty show this server on the public status page Returns: int: The new server's id @@ -103,6 +107,7 @@ class HelperServers: Servers.stop_command: server_stop, Servers.backup_path: backup_path, Servers.type: server_type, + Servers.show_status: show_status, } ).execute() diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 53c45986..b81800bb 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1384,6 +1384,7 @@ class PanelHandler(BaseHandler): server_ip = self.get_argument("server_ip", None) server_port = self.get_argument("server_port", None) executable_update_url = self.get_argument("executable_update_url", None) + show_status = int(float(self.get_argument("show_status", "0"))) else: execution_command = server_obj.execution_command executable = server_obj.executable @@ -1461,6 +1462,7 @@ class PanelHandler(BaseHandler): server_obj.server_ip = server_ip server_obj.server_port = server_port server_obj.executable_update_url = executable_update_url + server_obj.show_status = show_status else: server_obj.path = server_obj.path server_obj.log_path = server_obj.log_path diff --git a/app/frontend/static/assets/css/crafty.css b/app/frontend/static/assets/css/crafty.css index a4bfe57c..7c533ee2 100644 --- a/app/frontend/static/assets/css/crafty.css +++ b/app/frontend/static/assets/css/crafty.css @@ -21,6 +21,18 @@ display: block; } +.toggle-handle { + background-color: white !important; +} + +.toggle-on { + color: black !important; +} + +.toggle { + height: 0px !important; +} + .sidebar>.nav>.nav-item:not(.nav-profile)>.nav-link:before { content: none; position: absolute; diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index 3c107d30..9bb03a71 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -176,24 +176,35 @@
+ {% if data['super_user'] %} + + {% end %}