diff --git a/src/ui/main.py b/src/ui/main.py index 3475fafea..7ae8fb25e 100755 --- a/src/ui/main.py +++ b/src/ui/main.py @@ -244,7 +244,7 @@ def manage_bunkerweb(method: str, *args, operation: str = "reloads"): if listdir(service_custom_conf): move( service_custom_conf, - service_custom_conf.replace(f"{sep}{args[1]}", f"{sep}{args[2]}").replace(join(sep, "etc"), join(sep, "var", "tmp")), + service_custom_conf.replace(f"{sep}{args[1].split(' ')[0]}", f"{sep}{args[2].split(' ')[0]}").replace(join(sep, "etc"), join(sep, "var", "tmp")), ) moved = True operation, error = app.config["CONFIG"].edit_service(args[1], args[0]) @@ -257,7 +257,7 @@ def manage_bunkerweb(method: str, *args, operation: str = "reloads"): app.config["TO_FLASH"].append({"content": operation, "type": "success"}) if editing and moved and args[1] != args[2] and service_custom_confs: - for tmp_service_custom_conf in glob(join(sep, "var", "tmp", "bunkerweb", "configs", "*", args[2])): + for tmp_service_custom_conf in glob(join(sep, "var", "tmp", "bunkerweb", "configs", "*", args[2].split(" ")[0])): move( tmp_service_custom_conf, tmp_service_custom_conf.replace( @@ -526,12 +526,7 @@ def services(): Thread( target=manage_bunkerweb, name="Reloading instances", - args=( - "services", - variables, - request.form.get("OLD_SERVER_NAME", "").split(" ")[0], - variables.get("SERVER_NAME", "").split(" ")[0], - ), + args=("services", variables, request.form.get("OLD_SERVER_NAME", ""), variables.get("SERVER_NAME", "")), kwargs={"operation": request.form["operation"]}, ).start() @@ -554,6 +549,7 @@ def services(): { "SERVER_NAME": { "value": service["SERVER_NAME"]["value"].split(" ")[0], + "full_value": service["SERVER_NAME"]["value"], "method": service["SERVER_NAME"]["method"], }, "USE_REVERSE_PROXY": service["USE_REVERSE_PROXY"], diff --git a/src/ui/src/Config.py b/src/ui/src/Config.py index 4c4ae9ce7..62149f01b 100644 --- a/src/ui/src/Config.py +++ b/src/ui/src/Config.py @@ -231,12 +231,12 @@ class Config: if changed_server_name: for k in deepcopy(config): - if k.startswith(old_server_name): + if k.startswith(old_server_name_splitted[0]): config.pop(k) self.__gen_conf(config, services) return ( - f"Configuration for {old_server_name.split(' ')[0]} has been edited.", + f"Configuration for {old_server_name_splitted[0]} has been edited.", 0, ) diff --git a/src/ui/static/js/services.js b/src/ui/static/js/services.js index bb31473c8..fbf3272af 100644 --- a/src/ui/static/js/services.js +++ b/src/ui/static/js/services.js @@ -64,7 +64,11 @@ class ServiceModal { ) { //set form info and right form const [action, serviceName] = this.getActionAndServName(e.target); - this.setForm(action, serviceName, this.formNewEdit); + const oldServName = e.target + .closest("[data-services-service]") + .querySelector("[data-old-service-name]") + .getAttribute("data-value"); + this.setForm(action, serviceName, oldServName, this.formNewEdit); //get service data and parse it //multiple type logic is launch at same time on relate class const servicesSettings = e.target @@ -87,7 +91,7 @@ class ServiceModal { ) { //set form info and right form const [action, serviceName] = this.getActionAndServName(e.target); - this.setForm(action, serviceName, this.formNewEdit); + this.setForm(action, serviceName, serviceName, this.formNewEdit); //set default value with method default this.setSettingsDefault(); //server name is unset @@ -110,7 +114,7 @@ class ServiceModal { ) { //set form info and right form const [action, serviceName] = this.getActionAndServName(e.target); - this.setForm(action, serviceName, this.formDelete); + this.setForm(action, serviceName, serviceName, this.formDelete); //show modal this.openModal(); } @@ -202,7 +206,7 @@ class ServiceModal { } } - setForm(action, serviceName, formEl) { + setForm(action, serviceName, oldServName, formEl) { this.modalTitle.textContent = `${action} ${serviceName}`; formEl.setAttribute("id", `form-${action}-${serviceName}`); const opeInp = formEl.querySelector(`input[name="operation"]`); @@ -212,8 +216,8 @@ class ServiceModal { if (action === "edit" || action === "new") { this.showNewEditForm(); const oldNameInp = formEl.querySelector(`input[name="OLD_SERVER_NAME"]`); - oldNameInp.setAttribute("value", serviceName); - oldNameInp.value = serviceName; + oldNameInp.setAttribute("value", oldServName); + oldNameInp.value = oldServName; } if (action === "delete") { diff --git a/src/ui/templates/services.html b/src/ui/templates/services.html index f57db3b07..0ba989f5f 100644 --- a/src/ui/templates/services.html +++ b/src/ui/templates/services.html @@ -32,6 +32,7 @@ class="dark:brightness-110 overflow-hidden hover:scale-102 transition col-span-12 lg:col-span-6 3xl:col-span-4 p-4 w-full shadow-md break-words bg-white dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border" > +
{{ service["SERVER_NAME"]['value'] }}