From 855ddaf9f3cb48ce0c1696d9aebab92cf84d0804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Tue, 14 Jan 2025 17:16:47 +0100 Subject: [PATCH] Implement SERVER_NAME handling in raw mode for services_service_page --- src/ui/app/routes/services.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ui/app/routes/services.py b/src/ui/app/routes/services.py index 38a0fc9ed..dbbcd321c 100644 --- a/src/ui/app/routes/services.py +++ b/src/ui/app/routes/services.py @@ -195,6 +195,16 @@ def services_service_page(service: str): del variables["csrf_token"] mode = request.args.get("mode", "easy") + + if mode == "raw": + server_name = variables.get("SERVER_NAME", variables.get("OLD_SERVER_NAME", "")).split(" ")[0] + for variable, value in variables.copy().items(): + if variable.endswith("_SERVER_NAME") and variable != "OLD_SERVER_NAME": + server_name = value.split(" ")[0] + for variable in variables.copy(): + if variable.startswith(f"{server_name}_"): + variables[variable.replace(f"{server_name}_", "", 1)] = variables.pop(variable) + is_draft = variables.pop("IS_DRAFT", "no") == "yes" def update_service(service: str, variables: Dict[str, str], is_draft: bool, mode: str): @@ -267,12 +277,6 @@ def services_service_page(service: str): if "checksum" in data: db_custom_configs[db_custom_config]["checksum"] = data["checksum"] - if mode == "raw": - server_name = variables.get("SERVER_NAME", old_server_name).split(" ")[0] - for variable, value in variables.copy().items(): - if variable.startswith(f"{server_name}_"): - variables[variable.replace(f"{server_name}_", "", 1)] = value - if mode != "easy" or service != "new": # Remove already existing fields for variable, value in variables.copy().items():