Skip to content

Commit

Permalink
refactor: improve service handling logic in services.py to support ne…
Browse files Browse the repository at this point in the history
…w service creation and enhance redirect behavior
  • Loading branch information
TheophileDiot committed Feb 11, 2025
1 parent 0813236 commit 42490df
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/ui/app/routes/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@ def update_service(service: str, variables: Dict[str, str], is_draft: bool, mode
DATA["RELOADING"] = False

DATA.update({"RELOADING": True, "LAST_RELOAD": time(), "CONFIG_CHANGED": True})
Thread(target=update_service, args=(service, variables, is_draft, mode)).start()
Thread(target=update_service, args=(service, variables.copy(), is_draft, mode)).start()

new_service = False
if service == "new":
if "SERVER_NAME" not in variables:
return redirect(url_for("loading", next=url_for("services.services_page")))
new_service = True
service = variables["SERVER_NAME"].split(" ")[0]

arguments = {}
Expand All @@ -354,11 +356,15 @@ def update_service(service: str, variables: Dict[str, str], is_draft: bool, mode
return redirect(
url_for(
"loading",
next=url_for(
"services.services_service_page",
service=service,
)
+ f"?{'&'.join([f'{k}={v}' for k, v in arguments.items()])}",
next=(
url_for(
"services.services_service_page",
service=service,
)
+ f"?{'&'.join([f'{k}={v}' for k, v in arguments.items()])}"
if new_service or variables.get("SERVER_NAME", "").split(" ")[0] == variables.get("OLD_SERVER_NAME", "").split(" ")[0]
else url_for("services.services_page")
),
message=f"{'Saving' if service != 'new' else 'Creating'} configuration for {'draft ' if is_draft else ''}service {service}",
)
)
Expand Down

0 comments on commit 42490df

Please sign in to comment.