UI - config.json refactoring
This commit is contained in:
parent
bd7b6af668
commit
569ad75c42
1113
ui/config.json
1113
ui/config.json
File diff suppressed because it is too large
Load Diff
@ -11,15 +11,7 @@ if "ABSOLUTE_URI" in os.environ :
|
|||||||
ABSOLUTE_URI = os.environ["ABSOLUTE_URI"]
|
ABSOLUTE_URI = os.environ["ABSOLUTE_URI"]
|
||||||
app.config["ABSOLUTE_URI"] = ABSOLUTE_URI
|
app.config["ABSOLUTE_URI"] = ABSOLUTE_URI
|
||||||
with open("/opt/entrypoint/config.json", "r") as f :
|
with open("/opt/entrypoint/config.json", "r") as f :
|
||||||
config = json.loads(f.read())
|
app.config["CONFIG"] = json.loads(f.read())
|
||||||
app.config["CONFIG"] = {}
|
|
||||||
for k in config :
|
|
||||||
if not config[k]["category"] in app.config["CONFIG"] :
|
|
||||||
app.config["CONFIG"][config[k]["category"]] = []
|
|
||||||
tmp = config[k].copy()
|
|
||||||
tmp["id"] = k
|
|
||||||
app.config["CONFIG"][config[k]["category"]].append(tmp)
|
|
||||||
|
|
||||||
app.jinja_env.globals.update(env_to_summary_class=utils.env_to_summary_class)
|
app.jinja_env.globals.update(env_to_summary_class=utils.env_to_summary_class)
|
||||||
app.jinja_env.globals.update(form_service_gen=utils.form_service_gen)
|
app.jinja_env.globals.update(form_service_gen=utils.form_service_gen)
|
||||||
|
|
||||||
|
|||||||
@ -10,10 +10,9 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
|
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
|
||||||
{% set check = {"active": "active", "selected": "true"} %}
|
{% set check = {"active": "active", "selected": "true"} %}
|
||||||
{% for category in config["CONFIG"] %}
|
{% for k, v in config["CONFIG"].items() %}
|
||||||
{% set id_category = category.replace(" ", "") %}
|
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<a class="nav-link {{ check.active }}" id="edit-{{ id_category }}-{{ id_server_name }}-tab" data-bs-toggle="pill" href="#edit-{{ id_category }}-{{ id_server_name }}" role="tab" aria-controls="edit-{{ id_category }}-{{ id_server_name }}" aria-selected="{{ check.selected }}">{{ category }}</a>
|
<a class="nav-link {{ check.active }}" id="edit-{{ v["id"] }}-{{ id_server_name }}-tab" data-bs-toggle="pill" href="#edit-{{ v["id"] }}-{{ id_server_name }}" role="tab" aria-controls="edit-{{ v["id"] }}-{{ id_server_name }}" aria-selected="{{ check.selected }}">{{ k }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% if check.update({"active": "", "selected": "false"}) %}
|
{% if check.update({"active": "", "selected": "false"}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -21,11 +20,10 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content" id="edit-content-{{ id_server_name }}">
|
<div class="tab-content" id="edit-content-{{ id_server_name }}">
|
||||||
{% set check = {"class": "show active"} %}
|
{% set check = {"class": "show active"} %}
|
||||||
{% for category in config["CONFIG"] %}
|
{% for k, v in config["CONFIG"].items() %}
|
||||||
{% set id_category = category.replace(" ", "") %}
|
<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">
|
||||||
<div class="tab-pane fade {{ check.class }}" id="edit-{{ id_category }}-{{ id_server_name }}" role="tabpanel" aria-labelledby="edit-{{ id_category }}-{{ id_server_name }}-tab">
|
{% for param in v["params"] %}
|
||||||
{% for config in config["CONFIG"][category] %}
|
{{ form_service_gen("edit", id_server_name, param["id"], param["label"], param["type"], service[param["env"]])|safe }}
|
||||||
{{ form_service_gen("edit", service["SERVER_NAME"], config["id"], config["label"], config["type"], service[config["env"]])|safe }}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% if check.update({"class": ""}) %}
|
{% if check.update({"class": ""}) %}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ def env_to_summary_class(var, value) :
|
|||||||
|
|
||||||
def form_service_gen(form, server, id, label, type, value) :
|
def form_service_gen(form, server, id, label, type, value) :
|
||||||
if form == "edit" :
|
if form == "edit" :
|
||||||
new_id = "form-edit-" + server.replace(".", "-") + "-" + id
|
new_id = "form-edit-" + server + "-" + id
|
||||||
elif form == "new" :
|
elif form == "new" :
|
||||||
new_id = "form-new-" + id
|
new_id = "form-new-" + id
|
||||||
if type == "text" :
|
if type == "text" :
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user