diff --git a/CHANGELOG.md b/CHANGELOG.md index e19211c9..aafad1de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ TBD ### Bug fixes TBD ### Tweaks -TBD +- Improve the UI on several areas of the Crafty Panel ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/547)) ### Lang TBD

diff --git a/app/classes/controllers/servers_controller.py b/app/classes/controllers/servers_controller.py index 029518b6..b7c10ed8 100644 --- a/app/classes/controllers/servers_controller.py +++ b/app/classes/controllers/servers_controller.py @@ -515,6 +515,25 @@ class ServersController(metaclass=Singleton): # ********************************************************************************** # Servers Helpers Methods # ********************************************************************************** + @staticmethod + def get_cached_players(server_id): + srv = ServersController().get_server_instance_by_id(server_id) + stats = srv.stats_helper.get_server_stats() + server_path = stats["server_id"]["path"] + path = os.path.join(server_path, "usercache.json") + + try: + with open( + Helpers.get_os_understandable_path(path), encoding="utf-8" + ) as file: + content = file.read() + file.close() + except Exception as ex: + print(ex) + return None + + return json.loads(content) + @staticmethod def get_banned_players(server_id): srv = ServersController().get_server_instance_by_id(server_id) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 12491638..65bc853a 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -1294,3 +1294,24 @@ class Helpers: if region == "EN": return "en" return lang + "-" + region + + @staticmethod + def get_player_avatar(uuid_player): + mojang_response = requests.get( + f"https://sessionserver.mojang.com/session/minecraft/profile/{uuid_player}", + timeout=10, + ) + if mojang_response.status_code == 200: + uuid_profile = mojang_response.json() + profile_properties = uuid_profile["properties"] + for prop in profile_properties: + if prop["name"] == "textures": + decoded_bytes = base64.b64decode(prop["value"]) + decoded_str = decoded_bytes.decode("utf-8") + texture_json = json.loads(decoded_str) + skin_url = texture_json["textures"]["SKIN"]["url"] + skin_response = requests.get(skin_url, stream=True, timeout=10) + if skin_response.status_code == 200: + return base64.b64encode(skin_response.content) + else: + return diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index b7219ac6..df58263d 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -777,7 +777,34 @@ class PanelHandler(BaseHandler): ): if not superuser: self.redirect("/panel/error?error=Unauthorized access") - page_data["banned_players"] = get_banned_players_html() + page_data["banned_players_html"] = get_banned_players_html() + page_data[ + "banned_players" + ] = self.controller.servers.get_banned_players(server_id) + page_data[ + "cached_players" + ] = self.controller.servers.get_cached_players(server_id) + + page_data["all_players"] = [] + for player in page_data["cached_players"]: + if player["name"] in page_data["get_players"]: + player["status"] = "online" + else: + player["status"] = "offline" + temp_date = datetime.datetime.strptime( + player["expiresOn"], "%Y-%m-%d %H:%M:%S %z" + ) + player["last_seen"] = ( + temp_date - datetime.timedelta(30, 0, 0, 0, 0, 0, 0) + ).strftime("%Y/%m/%d %H:%M:%S") + player["avatar"] = Helpers.get_player_avatar(player["uuid"]) + page_data["all_players"].append(player) + for player in page_data["banned_players"]: + player["banned"] = True + temp_date = datetime.datetime.strptime( + player["created"], "%Y-%m-%d %H:%M:%S %z" + ) + player["banned_on"] = (temp_date).strftime("%Y/%m/%d %H:%M:%S") template = f"panel/server_{subpage}.html" diff --git a/app/frontend/static/assets/css/crafty.css b/app/frontend/static/assets/css/crafty.css index cc1c0262..c8edba8b 100644 --- a/app/frontend/static/assets/css/crafty.css +++ b/app/frontend/static/assets/css/crafty.css @@ -134,4 +134,47 @@ body { .accordion .card { margin-bottom: 0px; -} \ No newline at end of file +} + +/**************************************************************/ +/* CSS for Froms Displays */ +/**************************************************************/ +div>.input-group>.custom-file-input { + position: relative !important; + -webkit-box-flex: 1 !important; + -ms-flex: 1 1 auto !important; + flex: 1 1 auto !important; + width: 1% !important; + margin-bottom: 0 !important; + border: 1px solid var(--outline); +} + +div>.input-group>.form-control-file { + position: relative !important; + -webkit-box-flex: 1 !important; + -ms-flex: 1 1 auto !important; + flex: 1 1 auto !important; + width: 1% !important; + margin-bottom: 0 !important; + border: 1px solid var(--outline); +} + +.custom-picker { + border: 1px solid var(--outline); +} + +div>.input-group>.form-control { + position: relative !important; + -webkit-box-flex: 1 !important; + -ms-flex: 1 1 auto !important; + flex: 1 1 auto !important; + width: 1% !important; + margin-bottom: 0 !important; + border: 1px solid var(--outline); +} + +.input-group>.input-group-append>button.upload-button { + height: calc(1.5em + 0.75rem + 2px); +} + +/**************************************************************/ \ No newline at end of file diff --git a/app/frontend/templates/panel/config_json.html b/app/frontend/templates/panel/config_json.html index 9cc28919..6867fb90 100644 --- a/app/frontend/templates/panel/config_json.html +++ b/app/frontend/templates/panel/config_json.html @@ -6,8 +6,7 @@ {% block title %}Crafty Controller - {{ translate('panelConfig', 'pageTitle', data['lang']) }}{% end %} {% block content %} - +
@@ -30,7 +29,12 @@
{% if data['superuser'] %} - {% include "parts/crafty_config_list.html %} + + {% include "parts/crafty_config_list.html %} + + + {% include "parts/m_crafty_config_list.html %} + {% end %} @@ -69,11 +73,8 @@ {% elif item[0] == 'disabled_language_files' %}
- - {% for lang in data['all_languages'] %} {% if lang in item[1] %} @@ -82,17 +83,12 @@ {% end %} {% end %} - +
{% elif item[0] == 'monitored_mounts'%}
- - {% for mount in data['all_partitions'] %} {% if mount in item[1] %} @@ -101,13 +97,10 @@ {% end %} {% end %} - +
{% elif isinstance(item[1], list) %} - + {% elif isinstance(item[1], bool) %}
{% if item[1] == True %} @@ -123,11 +116,9 @@ {% end %}
{% elif isinstance(item[1], int) %} - + {% else %} - + {% end %}
{% end %} @@ -142,10 +133,6 @@
- +
- +
- +
@@ -195,8 +195,7 @@ Forgot Password
- Crafty Control + Crafty Control 4.0.20
@@ -228,6 +227,10 @@ @@ -630,8 +624,8 @@ bootbox.alert({ title: responseData.error, message: responseData.error_data - }); - } + }); + } }); }); diff --git a/app/frontend/templates/panel/server_schedules.html b/app/frontend/templates/panel/server_schedules.html index 9f92fc6e..e743e843 100644 --- a/app/frontend/templates/panel/server_schedules.html +++ b/app/frontend/templates/panel/server_schedules.html @@ -47,18 +47,14 @@

{{ translate('serverSchedules', 'scheduledTasks', data['lang']) }}

{% if data['user_data']['hints'] %} - + {% end %} -
+
+ +
- +
{{ translate('serverSchedules', 'name', data['lang']) }} @@ -87,7 +83,7 @@

{{schedule.action}}

-

{{schedule.command}}

+

{{schedule.command}}

{% if schedule.interval_type != '' and schedule.interval_type != 'reaction' %} @@ -105,14 +101,10 @@

{{schedule.next_run}}

- + -
@@ -126,8 +118,7 @@

- +
-
{{ translate('serverSchedules', 'action', data['lang']) @@ -145,7 +136,7 @@

{{schedule.action}}

-

{{schedule.command}}

+

{{schedule.command}}

{% if schedule.enabled %} @@ -160,8 +151,7 @@