diff --git a/CHANGELOG.md b/CHANGELOG.md index ec750a2d..f01f84c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,15 @@ # Changelog ## --- [4.0.21] - 2023/TBD ### New features -TBD +- Add better feedback for uploads with a progress bar ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/546)) ### Bug fixes -TBD +- Fix exception related to page data on server start ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/544)) ### Tweaks -TBD +- Cleanup authentication helpers ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/545)) +- Optimize file upload progress WS ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/546)) +- Truncate sidebar servers to a max of 10 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/552)) ### Lang -TBD +- Add additional translations to backups page strings ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/543))

## --- [4.0.20] - 2023/01/29 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 == "": 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 diff --git a/app/classes/web/server_handler.py b/app/classes/web/server_handler.py index 1c0d5962..da854cc5 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"]) 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"]: diff --git a/app/classes/web/upload_handler.py b/app/classes/web/upload_handler.py index 785d5783..11e1c4b8 100644 --- a/app/classes/web/upload_handler.py +++ b/app/classes/web/upload_handler.py @@ -52,18 +52,19 @@ class UploadHandler(BaseHandler): f"User with ID {user_id} attempted to upload a file that" f" exceeded the max body size." ) - self.helper.websocket_helper.broadcast_user( - user_id, - "send_start_error", + + return self.finish_json( + 413, { - "error": self.helper.translation.translate( + "status": "error", + "error": "TOO LARGE", + "info": self.helper.translation.translate( "error", "fileTooLarge", self.controller.users.get_user_lang_by_id(user_id), ), }, ) - return self.do_upload = True if superuser: @@ -141,48 +142,50 @@ class UploadHandler(BaseHandler): f"User with ID {user_id} attempted to upload a file that" f" exceeded the max body size." ) - self.helper.websocket_helper.broadcast_user( - user_id, - "send_start_error", + + return self.finish_json( + 413, { - "error": self.helper.translation.translate( + "status": "error", + "error": "TOO LARGE", + "info": self.helper.translation.translate( "error", "fileTooLarge", self.controller.users.get_user_lang_by_id(user_id), ), }, ) - return self.do_upload = True if not superuser: - self.helper.websocket_helper.broadcast_user( - user_id, - "send_start_error", + return self.finish_json( + 401, { - "error": self.helper.translation.translate( + "status": "error", + "error": "UNAUTHORIZED ACCESS", + "info": self.helper.translation.translate( "error", "superError", self.controller.users.get_user_lang_by_id(user_id), ), }, ) - return if not self.request.headers.get("X-Content-Type", None).startswith( "image/" ): - self.helper.websocket_helper.broadcast_user( - user_id, - "send_start_error", + + return self.finish_json( + 415, { - "error": self.helper.translation.translate( + "status": "error", + "error": "TYPE ERROR", + "info": self.helper.translation.translate( "error", "fileError", self.controller.users.get_user_lang_by_id(user_id), ), }, ) - return if user_id is None: logger.warning("User ID not found in upload handler call") Console.warning("User ID not found in upload handler call") @@ -219,18 +222,19 @@ class UploadHandler(BaseHandler): f"User with ID {user_id} attempted to upload a file that" f" exceeded the max body size." ) - self.helper.websocket_helper.broadcast_user( - user_id, - "send_start_error", + + return self.finish_json( + 413, { - "error": self.helper.translation.translate( + "status": "error", + "error": "TOO LARGE", + "info": self.helper.translation.translate( "error", "fileTooLarge", self.controller.users.get_user_lang_by_id(user_id), ), }, ) - return self.do_upload = True if superuser: diff --git a/app/frontend/templates/base.html b/app/frontend/templates/base.html index ed4c5a74..4dbfd719 100755 --- a/app/frontend/templates/base.html +++ b/app/frontend/templates/base.html @@ -15,7 +15,7 @@ + href="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css" /> @@ -41,14 +41,14 @@ + integrity="sha512-ElRFoEQdI5Ht6kZvyzXhYG9NqjtkmlkfYk0wr6wHxU9JEHakS7UJZNeml5ALk+8IKlU6jDgMabC3vkumRokgJA==" + crossorigin="anonymous" referrerpolicy="no-referrer"> + integrity="sha512-UXumZrZNiOwnTcZSHLOfcTs0aos2MzBWHXOHOuB0J/R44QB0dwY5JgfbvljXcklVf65Gc4El6RjZ+lnwd2az2g==" + crossorigin="anonymous" referrerpolicy="no-referrer"> + integrity="sha512-klQv6lz2YR+MecyFYMFRuU2eAl8IPRo6zHnsc9n142TJuJHS8CG0ix4Oq9na9ceeg1u5EkBfZsFcV3U7J51iew==" + crossorigin="anonymous" referrerpolicy="no-referrer"> @@ -82,7 +82,7 @@ {% include notify.html %} @@ -174,7 +174,7 @@ + src="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.js"> diff --git a/app/frontend/templates/main_menu.html b/app/frontend/templates/main_menu.html index 6f5da3d0..e5e8f7ab 100644 --- a/app/frontend/templates/main_menu.html +++ b/app/frontend/templates/main_menu.html @@ -75,13 +75,13 @@