diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md index 2acf3b1e..a82cb3f8 100644 --- a/.gitlab/merge_request_templates/Default.md +++ b/.gitlab/merge_request_templates/Default.md @@ -27,4 +27,3 @@ This checklist encourages us to confirm any changes have been analyzed to reduce * [ ] Have you resolved any lint issues? * [ ] Have you assigned a reviewer? * [ ] Have you applied correct labels? -* [ ] Have you updated CHANGELOG.md? diff --git a/CHANGELOG.md b/CHANGELOG.md index ba6ef7dc..c8c773fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,21 @@ # Changelog -## --- [4.0.6] - 2022/07/06 +## --- [4.0.7] - 2022/07/18 ### New features -- Task toggle (!398+) -- Basic API for modifying tasks (!398+) +- Task toggle ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/398)) +- Basic API for modifying tasks ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/398)) +- Toggle Visible servers on status page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/399)) +### Bug fixes +- Fixes stats recording for Oracle hosts ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/397)) +- Improve the use of the object oriented architecture ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/400)) +- Fix issue with API Server Instance is not serializable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/401)) +### Tweaks +None +### Lang +None +

+ +## --- [4.0.6] - 2022/07/06 ### Bug fixes - Fix an issue where the motd were not displayed properly one small screens ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/402)) - Remove redundant path check on backup restore ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/390)) diff --git a/app/classes/minecraft/stats.py b/app/classes/minecraft/stats.py index 64cbf894..4d7524c4 100644 --- a/app/classes/minecraft/stats.py +++ b/app/classes/minecraft/stats.py @@ -7,9 +7,7 @@ import base64 import typing as t from app.classes.shared.null_writer import NullWriter -from app.classes.minecraft.mc_ping import ping from app.classes.models.management import HostStats -from app.classes.models.servers import HelperServers from app.classes.shared.helpers import Helpers with redirect_stderr(NullWriter()): @@ -87,7 +85,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 = { @@ -218,32 +218,6 @@ class Stats: return level_total_size - def get_server_players(self, server_id): - - server = HelperServers.get_server_data_by_id(server_id) - - logger.info(f"Getting players for server {server}") - - # get our settings and data dictionaries - # server_settings = server.get('server_settings', {}) - # server_data = server.get('server_data_obj', {}) - - # TODO: search server properties file for possible override of 127.0.0.1 - internal_ip = server["server_ip"] - server_port = server["server_port"] - - logger.debug(f"Pinging {internal_ip} on port {server_port}") - if HelperServers.get_server_type_by_id(server_id) != "minecraft-bedrock": - int_mc_ping = ping(internal_ip, int(server_port)) - - ping_data = {} - - # if we got a good ping return, let's parse it - if int_mc_ping: - ping_data = Stats.parse_server_ping(int_mc_ping) - return ping_data["players"] - return [] - @staticmethod def parse_server_ping(ping_obj: object): online_stats = {} diff --git a/app/classes/models/servers.py b/app/classes/models/servers.py index 5a9bb268..71ca4851 100644 --- a/app/classes/models/servers.py +++ b/app/classes/models/servers.py @@ -37,6 +37,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" @@ -80,6 +81,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 diff --git a/app/classes/web/base_handler.py b/app/classes/web/base_handler.py index fd3ee638..b9a69c48 100644 --- a/app/classes/web/base_handler.py +++ b/app/classes/web/base_handler.py @@ -10,6 +10,7 @@ from app.classes.models.users import ApiKeys from app.classes.shared.helpers import Helpers from app.classes.shared.main_controller import Controller from app.classes.shared.translation import Translation +from app.classes.models.management import DatabaseShortcuts logger = logging.getLogger(__name__) @@ -204,6 +205,10 @@ class BaseHandler(tornado.web.RequestHandler): authorized_servers = self.controller.servers.get_authorized_servers( user["user_id"] # TODO: API key authorized servers? ) + authorized_servers = [ + DatabaseShortcuts.get_data_obj(x.server_object) + for x in authorized_servers + ] logger.debug("Checking results") if user: diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 53c45986..f161ab47 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -192,9 +192,9 @@ class PanelHandler(BaseHandler): total_players = 0 for server in page_data["servers"]: total_players += len( - self.controller.servers.stats.get_server_players( + self.controller.servers.get_server_instance_by_id( server["server_data"]["server_id"] - ) + ).get_server_players() ) page_data["num_players"] = total_players @@ -539,9 +539,7 @@ class PanelHandler(BaseHandler): except Exception as e: logger.error(f"Failed to get server waiting to start: {e}") page_data["waiting_start"] = False - page_data[ - "get_players" - ] = lambda: self.controller.servers.stats.get_server_players(server_id) + page_data["get_players"] = server.get_server_players() page_data["active_link"] = subpage page_data["permissions"] = { "Commands": EnumPermissionsServer.COMMANDS, @@ -877,9 +875,6 @@ class PanelHandler(BaseHandler): page_data["schedules"] = HelpersManagement.get_schedules_by_server( server_id ) - page_data[ - "get_players" - ] = lambda: self.controller.servers.stats.get_server_players(server_id) page_data["active_link"] = "schedules" page_data["permissions"] = { "Commands": EnumPermissionsServer.COMMANDS, @@ -945,9 +940,6 @@ class PanelHandler(BaseHandler): self.redirect("/panel/error?error=Invalid Schedule ID") return schedule = self.controller.management.get_scheduled_task_model(sch_id) - page_data[ - "get_players" - ] = lambda: self.controller.servers.stats.get_server_players(server_id) page_data["active_link"] = "schedules" page_data["permissions"] = { "Commands": EnumPermissionsServer.COMMANDS, @@ -1384,6 +1376,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 +1454,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_admin_controls.html b/app/frontend/templates/panel/server_admin_controls.html index 7149bb85..542f2ce7 100644 --- a/app/frontend/templates/panel/server_admin_controls.html +++ b/app/frontend/templates/panel/server_admin_controls.html @@ -73,7 +73,7 @@

{{ translate('serverPlayerManagement', 'players', data['lang']) }}: