From 819e84ec4cdba27f3a9016359aa54a3aa01132a8 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 30 Jan 2023 23:27:40 -0500 Subject: [PATCH 01/25] Translate additions to backups page --- app/frontend/templates/panel/server_backup.html | 16 ++++++++-------- app/translations/en_EN.json | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/frontend/templates/panel/server_backup.html b/app/frontend/templates/panel/server_backup.html index 4af0ba1a..ab9b4f2e 100644 --- a/app/frontend/templates/panel/server_backup.html +++ b/app/frontend/templates/panel/server_backup.html @@ -110,15 +110,15 @@
{% if data['backup_config']['before'] %} - Run - Command Before Backup + {{ + translate('serverBackups', 'before', data['lang']) }}
{% else %} - Run Command - Before Backup + {{ + translate('serverBackups', 'before', data['lang']) }}
@@ -127,15 +127,15 @@
{% if data['backup_config']['after'] %} - Run - Command After Backup + {{ + translate('serverBackups', 'after', data['lang']) }}
{% else %} - Run Command - Before Backup + {{ + translate('serverBackups', 'after', data['lang']) }}
diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index 15a8ed27..7c5c99d4 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -297,7 +297,9 @@ "shutdown": "Shutdown server for duration of backup", "size": "Size", "storageLocation": "Storage Location", - "storageLocationDesc": "Where do you want to store backups?" + "storageLocationDesc": "Where do you want to store backups?", + "before": "Run command before backup", + "after": "Run command after backup" }, "serverConfig": { "bePatientDelete": "Please be patient while we remove your server from the Crafty panel. This screen will close in a few moments.", From 683c9cecbaf2efc052c8ed11489012a31cd6e1fd Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 31 Jan 2023 13:11:03 -0500 Subject: [PATCH 02/25] Add background key to server_handler page_data --- app/classes/web/server_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/classes/web/server_handler.py b/app/classes/web/server_handler.py index 1c0d5962..7e01d73a 100644 --- a/app/classes/web/server_handler.py +++ b/app/classes/web/server_handler.py @@ -183,6 +183,7 @@ class ServerHandler(BaseHandler): "version_data": "version_data_here", # TODO "user_data": exec_user, "show_contribute": self.helper.get_setting("show_contribute_link", True), + # "background": self.controller.cached_login, "lang": self.controller.users.get_user_lang_by_id(exec_user["user_id"]), "lang_page": Helpers.get_lang_page( self.controller.users.get_user_lang_by_id(exec_user["user_id"]) From ed30cbd4cb12750ba9cf3ab77a1588472e2579bd Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 31 Jan 2023 13:11:28 -0500 Subject: [PATCH 03/25] Refactor public handler keys --- app/classes/web/status_handler.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/classes/web/status_handler.py b/app/classes/web/status_handler.py index 410e3a36..ff4eb290 100644 --- a/app/classes/web/status_handler.py +++ b/app/classes/web/status_handler.py @@ -7,12 +7,12 @@ logger = logging.getLogger(__name__) class StatusHandler(BaseHandler): def get(self): - page_data = {"background": self.controller.cached_login} - page_data["lang"] = self.helper.get_setting("language") - page_data["lang_page"] = self.helper.get_lang_page( - self.helper.get_setting("language") - ) - page_data["servers"] = self.controller.servers.get_all_servers_stats() + page_data = { + "background": self.controller.cached_login, + "lang": self.helper.get_setting("language"), + "lang_page": self.helper.get_lang_page(self.helper.get_setting("language")), + "servers": self.controller.servers.get_all_servers_stats(), + } running = 0 for srv in page_data["servers"]: if srv["stats"]["running"]: From 6e0805a8a1c1f9541338e2f897f68cb61416f3ef Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 31 Jan 2023 13:14:01 -0500 Subject: [PATCH 04/25] Lol uncomment the fix --- app/classes/web/server_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/web/server_handler.py b/app/classes/web/server_handler.py index 7e01d73a..da854cc5 100644 --- a/app/classes/web/server_handler.py +++ b/app/classes/web/server_handler.py @@ -183,7 +183,7 @@ class ServerHandler(BaseHandler): "version_data": "version_data_here", # TODO "user_data": exec_user, "show_contribute": self.helper.get_setting("show_contribute_link", True), - # "background": self.controller.cached_login, + "background": self.controller.cached_login, "lang": self.controller.users.get_user_lang_by_id(exec_user["user_id"]), "lang_page": Helpers.get_lang_page( self.controller.users.get_user_lang_by_id(exec_user["user_id"]) From 750e4f40c018153c330dcee0a3be4d51aa6bcc23 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 31 Jan 2023 13:30:41 -0500 Subject: [PATCH 05/25] Remove "my secret" from authentication --- app/classes/shared/authentication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/classes/shared/authentication.py b/app/classes/shared/authentication.py index d9b2c053..1a809bfc 100644 --- a/app/classes/shared/authentication.py +++ b/app/classes/shared/authentication.py @@ -13,7 +13,6 @@ logger = logging.getLogger(__name__) class Authentication: def __init__(self, helper): self.helper = helper - self.secret = "my secret" try: self.secret = ManagementController.get_crafty_api_key() if self.secret == "": From 5bccfab7b60bbc5d2c3cbd3620d48c46ec5c6f07 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 31 Jan 2023 13:53:27 -0500 Subject: [PATCH 06/25] add ignored names in conditional --- app/classes/shared/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 92226425..6320d60e 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -1013,7 +1013,7 @@ class Helpers: for item in file_list: if os.path.isdir(os.path.join(folder, item)): dir_list.append(item) - elif str(item) != "crafty.sqlite": + elif str(item) != self.ignored_names: unsorted_files.append(item) file_list = sorted(dir_list, key=str.casefold) + sorted( unsorted_files, key=str.casefold @@ -1054,7 +1054,7 @@ class Helpers: for item in file_list: if os.path.isdir(os.path.join(folder, item)): dir_list.append(item) - elif str(item) != "crafty.sqlite": + elif str(item) != self.ignored_names: unsorted_files.append(item) file_list = sorted(dir_list, key=str.casefold) + sorted( unsorted_files, key=str.casefold From 238b8da4d9b27058799060a393cea852f9ca22c6 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Wed, 1 Feb 2023 15:31:43 -0500 Subject: [PATCH 07/25] Add upload progress bar for file uploads --- app/frontend/templates/panel/server_files.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/frontend/templates/panel/server_files.html b/app/frontend/templates/panel/server_files.html index 5734f3a6..553baed0 100644 --- a/app/frontend/templates/panel/server_files.html +++ b/app/frontend/templates/panel/server_files.html @@ -705,6 +705,15 @@ let mimeType = file.type let size = file.size + xmlHttpRequest.upload.addEventListener('progress', function (e) { + + if (e.loaded <= size) { + var percent = Math.round(e.loaded / size * 100); + $(`#upload-progress-bar-${i + 1}`).css('width', percent + '%'); + $(`#upload-progress-bar-${i + 1}`).html(percent + '%'); + } + }); + xmlHttpRequest.open('POST', target, true); xmlHttpRequest.setRequestHeader('X-Content-Type', mimeType); xmlHttpRequest.setRequestHeader('X-XSRFToken', token); @@ -826,7 +835,7 @@ await sendFile(files.files[i], path, serverId, nFiles - i - 1, i, (progress) => { $(`#upload-progress-bar-${i + 1}`).attr('aria-valuenow', progress) - $(`#upload-progress-bar-${i + 1}`).css('width', progress + '%') + $(`#upload-progress-bar-${i + 1}`).css('width', progress + '%'); }); } hideUploadBox(); From 20ce8996d7ba2c6f8b14e9374eaa6c725d2a0712 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Wed, 1 Feb 2023 15:43:17 -0500 Subject: [PATCH 08/25] Add better upload feedback for users --- .../templates/panel/custom_login.html | 33 ++++++++++++------- .../templates/server/bedrock_wizard.html | 11 ++++++- app/frontend/templates/server/wizard.html | 11 ++++++- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/app/frontend/templates/panel/custom_login.html b/app/frontend/templates/panel/custom_login.html index 018eb006..3b5df8ba 100644 --- a/app/frontend/templates/panel/custom_login.html +++ b/app/frontend/templates/panel/custom_login.html @@ -56,11 +56,11 @@
+ multiple="false" required>
+ disabled>UPLOAD

@@ -74,7 +74,7 @@
+ onchange="previewOpacity()" min="0" max="100" value="{{ data['login_opacity'] }}">
Responsive image + class="img-fluid" alt="Responsive image">