mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
multisite settings only on services done
This commit is contained in:
parent
65dc538cfb
commit
cf9e0466c4
12 changed files with 21098 additions and 33 deletions
|
|
@ -1,13 +1,21 @@
|
|||
from .utils.form import get_forms, get_service_settings
|
||||
|
||||
|
||||
def easy_mode_builder(templates: list[dict], plugins: list, global_config: dict, total_config: dict, service_name: str, is_new: bool = False) -> str:
|
||||
def easy_mode_builder(
|
||||
templates: list[dict],
|
||||
plugins: list,
|
||||
global_config: dict,
|
||||
total_config: dict,
|
||||
service_name: str,
|
||||
is_new: bool = False,
|
||||
) -> str:
|
||||
"""Render forms with global config data.
|
||||
ATM we don't need templates but we need to pass at least one to the function (it will simply not override anything).
|
||||
"""
|
||||
|
||||
# We need
|
||||
settings = get_service_settings(service_name, global_config, total_config)
|
||||
|
||||
builder = [
|
||||
{
|
||||
"type": "card",
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ def get_plugins_multisite(plugins: list) -> list:
|
|||
plugin_multisite["settings"] = multisite_settings
|
||||
plugins_multisite.append(plugin_multisite)
|
||||
|
||||
return plugins
|
||||
return plugins_multisite
|
||||
|
||||
|
||||
def get_forms(
|
||||
|
|
@ -61,7 +61,19 @@ def get_forms(
|
|||
"""
|
||||
# Copy of the plugins, and get the plugins by context if needed
|
||||
# In services page, we want only multisite settings, but in global config we want both
|
||||
plugins_base = get_plugins_multisite(plugins) if only_multisite else copy.deepcopy(plugins)
|
||||
plugins_base = get_plugins_multisite(plugins) if only_multisite else plugins
|
||||
|
||||
# This template will be used to show default value or value if exists
|
||||
TEMPLATE_DEFAULT = [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [],
|
||||
"configs": {},
|
||||
"settings": {},
|
||||
}
|
||||
]
|
||||
|
||||
templates = TEMPLATE_DEFAULT + templates
|
||||
|
||||
# Update SERVER_NAME to be empty if new
|
||||
if is_new and "SERVER_NAME" in settings:
|
||||
|
|
|
|||
6912
src/ui/client/tests/advanced.json
Normal file
6912
src/ui/client/tests/advanced.json
Normal file
File diff suppressed because it is too large
Load diff
4119
src/ui/client/tests/advanced.py
Normal file
4119
src/ui/client/tests/advanced.py
Normal file
File diff suppressed because it is too large
Load diff
1
src/ui/client/tests/advanced.txt
Normal file
1
src/ui/client/tests/advanced.txt
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -28,7 +28,7 @@ def advanced_mode_builder(templates: list[dict], plugins: list, global_config: d
|
|||
{
|
||||
"type": "Templates",
|
||||
"data": {
|
||||
"templates": get_forms(templates, plugins, settings, ("advanced",), is_new),
|
||||
"templates": get_forms(templates, plugins, settings, ("advanced",), is_new, True),
|
||||
"operation": "new" if is_new else "edit",
|
||||
"oldServerName": service_name if service_name else "",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def easy_mode_builder(templates: list[dict], plugins: list, global_config: dict,
|
|||
{
|
||||
"type": "Templates",
|
||||
"data": {
|
||||
"templates": get_forms(templates, plugins, settings, ("easy",), is_new),
|
||||
"templates": get_forms(templates, plugins, settings, ("easy",), is_new, True),
|
||||
"operation": "new" if is_new else "edit",
|
||||
"oldServerName": service_name if service_name else "",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ def raw_mode_builder(templates: list[dict], plugins: list, global_config: dict,
|
|||
{
|
||||
"type": "Templates",
|
||||
"data": {
|
||||
"templates": get_forms(templates, plugins, settings, ("raw",), is_new),
|
||||
"templates": get_forms(templates, plugins, settings, ("raw",), is_new, True),
|
||||
"operation": "new" if is_new else "edit",
|
||||
"oldServerName": service_name if service_name else "",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ def get_plugins_multisite(plugins: list) -> list:
|
|||
plugin_multisite["settings"] = multisite_settings
|
||||
plugins_multisite.append(plugin_multisite)
|
||||
|
||||
return plugins
|
||||
return plugins_multisite
|
||||
|
||||
|
||||
def get_forms(
|
||||
|
|
@ -61,7 +61,19 @@ def get_forms(
|
|||
"""
|
||||
# Copy of the plugins, and get the plugins by context if needed
|
||||
# In services page, we want only multisite settings, but in global config we want both
|
||||
plugins_base = get_plugins_multisite(plugins) if only_multisite else copy.deepcopy(plugins)
|
||||
plugins_base = get_plugins_multisite(plugins) if only_multisite else plugins
|
||||
|
||||
# This template will be used to show default value or value if exists
|
||||
TEMPLATE_DEFAULT = [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [],
|
||||
"configs": {},
|
||||
"settings": {},
|
||||
}
|
||||
]
|
||||
|
||||
templates = TEMPLATE_DEFAULT + templates
|
||||
|
||||
# Update SERVER_NAME to be empty if new
|
||||
if is_new and "SERVER_NAME" in settings:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -101,17 +101,6 @@ signal(SIGTERM, handle_stop)
|
|||
|
||||
sbin_nginx_path = Path(sep, "usr", "sbin", "nginx")
|
||||
|
||||
|
||||
TEMPLATE_PLACEHOLDER = [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [],
|
||||
"configs": {},
|
||||
"settings": {},
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
# Flask app
|
||||
app = Flask(__name__, static_url_path="/", static_folder="static", template_folder="templates")
|
||||
|
||||
|
|
@ -1347,20 +1336,15 @@ def services_modes():
|
|||
plugins = app.bw_config.get_plugins()
|
||||
|
||||
data_server_builder = None
|
||||
templates = []
|
||||
if mode == "raw":
|
||||
data_server_builder = raw_mode_builder(
|
||||
TEMPLATE_PLACEHOLDER, plugins, global_config, total_config, service_name or "new", False if service_name else True
|
||||
)
|
||||
data_server_builder = raw_mode_builder(templates, plugins, global_config, total_config, service_name or "new", False if service_name else True)
|
||||
|
||||
if mode == "advanced":
|
||||
data_server_builder = advanced_mode_builder(
|
||||
TEMPLATE_PLACEHOLDER, plugins, global_config, total_config, service_name or "new", False if service_name else True
|
||||
)
|
||||
data_server_builder = advanced_mode_builder(templates, plugins, global_config, total_config, service_name or "new", False if service_name else True)
|
||||
|
||||
if mode == "easy":
|
||||
data_server_builder = easy_mode_builder(
|
||||
TEMPLATE_PLACEHOLDER, plugins, global_config, total_config, service_name or "new", False if service_name else True
|
||||
)
|
||||
data_server_builder = easy_mode_builder(templates, plugins, global_config, total_config, service_name or "new", False if service_name else True)
|
||||
|
||||
data_server_builder = base64.b64encode(bytes(json.dumps(data_server_builder), "utf-8")).decode("ascii")
|
||||
|
||||
|
|
@ -1487,7 +1471,8 @@ def global_config():
|
|||
|
||||
global_config = app.bw_config.get_config(global_only=True, methods=True)
|
||||
plugins = app.bw_config.get_plugins()
|
||||
data_server_builder = global_config_builder(TEMPLATE_PLACEHOLDER, plugins, global_config)
|
||||
templates = []
|
||||
data_server_builder = global_config_builder(templates, plugins, global_config)
|
||||
data_server_builder = base64.b64encode(bytes(json.dumps(data_server_builder), "utf-8")).decode("ascii")
|
||||
|
||||
return render_template("global-config.html", data_server_builder=data_server_builder)
|
||||
|
|
|
|||
Loading…
Reference in a new issue