ui - show only multisite vars for settings

This commit is contained in:
bunkerity 2021-06-01 10:54:59 +02:00
parent 82e47f147d
commit 7323525b69
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
4 changed files with 25 additions and 17 deletions

View File

@ -1,4 +1,4 @@
import json, uuid, glob
import json, uuid, glob, copy
class Config :
@ -36,15 +36,11 @@ class Config :
if stderr != "" or proc.returncode != 0 :
raise Exception("Error from generator (return code = " + str(proc.returncode) + ") : " + stderr)
def get_config(self) :
config = self.__env_to_dict("/etc/nginx/global.env")
for service in self.get_services() :
for k, v in service.items() :
config[service["FIRST_SERVER"] + "_" + k] = v
return config
def get_settings(self) :
return self.__settings
def get_config(self) :
return self.__env_to_dict("/etc/nginx/global.env")
def get_services(self) :
services = []

View File

@ -5,7 +5,7 @@ from flask import Flask, render_template, current_app, request
from Docker import Docker
from Config import Config
import utils
import os, json, re
import os, json, re, traceback
app = Flask(__name__, static_url_path="/", static_folder="static", template_folder="templates")
ABSOLUTE_URI = ""
@ -104,4 +104,4 @@ def services():
return render_template("services.html", title="Services", services=services, operation=operation)
except Exception as e :
return render_template("error.html", title="Error", error=str(e))
return render_template("error.html", title="Error", error=str(e) + traceback.format_exc())

View File

@ -8,7 +8,7 @@
<div class="modal-body">
<ul class="nav nav-pills mb-3" id="pills-tab-edit" role="tablist">
{% set check = {"active": "active", "selected": "true"} %}
{% for k, v in config["CONFIG"].get_config().items() %}
{% for k, v in config["CONFIG"].get_settings().items() %}
<li class="nav-item" role="presentation">
<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>
@ -20,7 +20,7 @@
<input type="hidden" value="{{ service["SERVER_NAME"] }}" name="OLD_SERVER_NAME">
<div class="tab-content" id="edit-content-{{ id_server_name }}">
{% set check = {"class": "show active"} %}
{% for k, v in config["CONFIG"].get_config().items() %}
{% 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"] }}">

View File

@ -8,7 +8,7 @@
<div class="modal-body">
<ul class="nav nav-pills mb-3" id="pills-tab-new" role="tablist">
{% set check = {"active": "active", "selected": "true"} %}
{% for k, v in config["CONFIG"].get_config().items() %}
{% for k, v in config["CONFIG"].get_settings().items() %}
<li class="nav-item" role="presentation">
<a class="nav-link {{ check.active }}" id="new-{{ v["id"] }}-tab" data-bs-toggle="pill" href="#new-{{ v["id"] }}" role="tab" aria-controls="new-{{ v["id"] }}" aria-selected="{{ check.selected }}">{{ k }}</a>
</li>
@ -19,14 +19,26 @@
<form id="form-new">
<div class="tab-content" id="new-content">
{% set check = {"class": "show active"} %}
{% for k, v in config["CONFIG"].get_config().items() %}
{% 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" %}
{{ form_service_gen("form-new-" + param["id"], param["label"], param["type"], param["default"], param["env"])|safe }}
{% else %}
{% if param["type"] != "multiple" and param["context"] == "multisite" %}
{% 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 }}
{% elif param["type"] == "multiple" %}
{% set gen = {"value": False} %}
{% for param in param["params"] %}
{% if param["context"] == "multisite" %}
{% set x = gen.update({"value": True}) %}
{% endif %}
{% endfor %}
{% if gen["value"] %}
{{ form_service_gen_multiple("form-new-" + param["id"], param["label"], param["params"])|safe }}
{% endif %}
{% endif %}
</div>
{% endfor %}