fix web ui multiple variables and add default error pages
This commit is contained in:
@@ -39,6 +39,7 @@ class Config :
|
||||
self.__dict_to_env(env_file, conf)
|
||||
proc = subprocess.run(["/bin/su", "-c", "/opt/gen/main.py --settings /opt/settings.json --templates /opt/confs --output /etc/nginx --variables " + env_file, "nginx"], capture_output=True)
|
||||
stderr = proc.stderr.decode("ascii")
|
||||
#stdout = proc.stdout.decode("ascii")
|
||||
if stderr != "" or proc.returncode != 0 :
|
||||
raise Exception("Error from generator (return code = " + str(proc.returncode) + ") : " + stderr)
|
||||
|
||||
@@ -60,12 +61,17 @@ class Config :
|
||||
check = False
|
||||
for category in self.__settings :
|
||||
for param in self.__settings[category]["params"] :
|
||||
multiple = False
|
||||
if param["type"] != "multiple" :
|
||||
real_params = [param]
|
||||
else :
|
||||
real_params = param["params"]
|
||||
multiple = True
|
||||
for real_param in real_params :
|
||||
if k == real_param["env"] and real_param["context"] == "multisite" and re.search(real_param["regex"], v) :
|
||||
if (((not multiple and k == real_param["env"]) or
|
||||
(multiple and re.search("^" + real_param["env"] + "_" + "[0-9]+$", k))) and
|
||||
real_param["context"] == "multisite" and
|
||||
re.search(real_param["regex"], v)) :
|
||||
check = True
|
||||
if not check :
|
||||
raise Exception("Variable " + k + " is not valid.")
|
||||
|
||||
@@ -23,15 +23,25 @@
|
||||
{% for k, v in config["CONFIG"].get_settings().items() %}
|
||||
<div class="tab-pane fade {{ check.class }}" id="edit-{{ v["id"] }}-{{ id_server_name }}" role="tabpanel" aria-labelledby="edit-{{ v["id"] }}-{{ id_server_name }}-tab">
|
||||
{% for param in v["params"] %}
|
||||
<div class="row mb-3" id="form-edit-{{ id_server_name }}-{{ param["id"] }}">
|
||||
{% if param["type"] != "multiple" and param["context"] == "multisite" %}
|
||||
<div class="row mb-3" id="form-edit-{{ id_server_name }}-{{ param["id"] }}">
|
||||
{{ form_service_gen("form-edit-" + id_server_name + "-" + param["id"], param["label"], param["type"], service[param["env"]], param["env"])|safe }}
|
||||
{% elif param["context"] == "multisite" %}
|
||||
</div>
|
||||
{% elif param["type"] == "multiple" %}
|
||||
{% set gen = {"value": False} %}
|
||||
{% for param2 in param["params"] %}
|
||||
{% if param2["context"] == "multisite" %}
|
||||
{% set x = gen.update({"value": True}) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if gen["value"] %}
|
||||
<div class="row mb-3" id="form-edit-{{ id_server_name }}-{{ param["id"] }}">
|
||||
{{ form_service_gen_multiple("form-edit-" + id_server_name + "-" + param["id"], param["label"], param["params"])|safe }}
|
||||
{% if template_data.update({"javascript": template_data.javascript + form_service_gen_multiple_values("form-edit-" + id_server_name + "-" + param["id"], param["params"], service)}) %}
|
||||
{% if template_data.update({"javascript": template_data.javascript + form_service_gen_multiple_values("form-edit-" + id_server_name + "-" + param["id"], param["params"], service)}) %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if check.update({"class": ""}) %}
|
||||
|
||||
@@ -22,25 +22,27 @@
|
||||
{% for k, v in config["CONFIG"].get_settings().items() %}
|
||||
<div class="tab-pane fade {{ check.class }}" id="new-{{ v["id"] }}" role="tabpanel" aria-labelledby="new-{{ v["id"] }}-tab">
|
||||
{% for param in v["params"] %}
|
||||
<div class="row mb-3" id="form-new-{{ param["id"] }}">
|
||||
{% if param["type"] != "multiple" and param["context"] == "multisite" %}
|
||||
<div class="row mb-3" id="form-new-{{ param["id"] }}">
|
||||
{% set default = {"value": param["default"]} %}
|
||||
{% if param["env"] in config["CONFIG"].get_config() %}
|
||||
{% set x = default.update({"value": config["CONFIG"].get_config()[param["env"]]}) %}
|
||||
{% endif %}
|
||||
{{ form_service_gen("form-new-" + param["id"], param["label"], param["type"], default["value"], param["env"])|safe }}
|
||||
</div>
|
||||
{% elif param["type"] == "multiple" %}
|
||||
{% set gen = {"value": False} %}
|
||||
{% for param in param["params"] %}
|
||||
{% if param["context"] == "multisite" %}
|
||||
{% for param2 in param["params"] %}
|
||||
{% if param2["context"] == "multisite" %}
|
||||
{% set x = gen.update({"value": True}) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if gen["value"] %}
|
||||
<div class="row mb-3" id="form-new-{{ param["id"] }}">
|
||||
{{ form_service_gen_multiple("form-new-" + param["id"], param["label"], param["params"])|safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if check.update({"class": ""}) %}
|
||||
|
||||
Reference in New Issue
Block a user