mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
update services page and modes
* delete form done * fix draft form value send * add missing new state to some form builder * fix store send data (now operation and mode are send) * fix csrf token parameters name check
This commit is contained in:
parent
adf0d4f4f2
commit
9289864808
20 changed files with 81 additions and 58 deletions
|
|
@ -39,7 +39,7 @@ def raw_mode_builder(templates: list[dict], plugins: list, global_config: dict,
|
|||
{
|
||||
"type": "Templates",
|
||||
"data": {
|
||||
"templates": get_forms(templates, plugins, settings, ("raw",)),
|
||||
"templates": get_forms(templates, plugins, settings, ("raw",), is_new),
|
||||
"operation": "new" if is_new else "edit",
|
||||
"oldServerName": service_name if service_name else "",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -192,13 +192,14 @@ def services_action(
|
|||
"color": "delete",
|
||||
"size": "normal",
|
||||
"attrs": {
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : {server_name}, "operation" : "{operation}" }}""",
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : "{server_name}", "operation" : "{operation}" }}""",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if operation == "draft":
|
||||
draft_value = "yes" if is_draft else "no"
|
||||
# get reverse of current state for update
|
||||
draft_value = "no" if is_draft else "yes"
|
||||
buttons.append(
|
||||
{
|
||||
"id": f"{operation}-service-btn-{server_name}",
|
||||
|
|
@ -207,7 +208,7 @@ def services_action(
|
|||
"color": "success",
|
||||
"size": "normal",
|
||||
"attrs": {
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : {server_name}, "OLD_SERVER_NAME" : {server_name}, "operation" : "edit", "IS_DRAFT" : {draft_value} }}""",
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : "{server_name}", "OLD_SERVER_NAME" : "{server_name}", "operation" : "edit", "IS_DRAFT" : "{draft_value}" }}""",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,14 @@ def get_forms(templates: list = [], plugins: list = [], settings: dict = {}, ren
|
|||
We will run on each plugins, set template value if one, and override by the custom settings value if exists.
|
||||
We will format to fit each form type (easy, advanced, raw) in case
|
||||
"""
|
||||
|
||||
# Update SERVER_NAME to be empty if new
|
||||
if is_new and "SERVER_NAME" in settings:
|
||||
settings["SERVER_NAME"]["value"] = ""
|
||||
|
||||
if is_new and not "SERVER_NAME" in settings:
|
||||
settings["SERVER_NAME"] = {"value": "", "method": "ui", "global": True}
|
||||
|
||||
forms = {}
|
||||
for form in render_forms:
|
||||
forms[form] = {}
|
||||
|
|
@ -121,9 +129,6 @@ def set_raw(template: list, plugins_base: list, settings: dict, is_new: bool) ->
|
|||
if val != default_val:
|
||||
raw_value = val
|
||||
|
||||
if setting == "SERVER_NAME" and is_new:
|
||||
raw_value = ""
|
||||
|
||||
# Add value only if exists
|
||||
if raw_value:
|
||||
raw_settings[setting] = raw_value
|
||||
|
|
@ -384,9 +389,6 @@ def format_setting(
|
|||
# Update value or set default as value
|
||||
setting_value["value"] = template_settings.get(setting_name, setting_value.get("default"))
|
||||
|
||||
if setting_name == "SERVER_NAME" and is_new:
|
||||
setting_value["value"] = ""
|
||||
|
||||
# Then override by service settings if not a multiple
|
||||
# Case multiple, we need to keep the default value and override only each multiple group
|
||||
if setting_name in settings and not "multiple" in setting_value:
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ def move_template(folder: Path, target_folder: Path):
|
|||
|
||||
for file in folder.rglob("index.html"):
|
||||
file_html = base_html
|
||||
if "global-config" in file.parts or "jobs" in file.parts or "services" in file.parts or "raw" in file.parts:
|
||||
if "global-config" in file.parts or "jobs" in file.parts or "services" in file.parts or "modes" in file.parts:
|
||||
file_html = base_html.replace("data_server_builder[1:-1]", "data_server_builder")
|
||||
|
||||
content = file.read_text()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<link rel="stylesheet" href="/css/style.css" />
|
||||
<link rel="stylesheet" href="/css/flag-icons.min.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BunkerWeb | Raw mode</title>
|
||||
<title>BunkerWeb | Modes</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="hidden" data-server-global='{"username" : "admin"}'></div>
|
||||
|
|
|
|||
|
|
@ -353,10 +353,11 @@ export const createFormStore = (storeName, formType) => {
|
|||
_updateTempState();
|
||||
if (!isUpdateData.value) return;
|
||||
|
||||
data = JSON.parse(JSON.stringify(formattedData.value));
|
||||
const data = JSON.parse(JSON.stringify(formattedData.value));
|
||||
data["operation"] = operation.value;
|
||||
data["OLD_SERVER_NAME"] = oldServerName.value;
|
||||
print(data);
|
||||
data["mode"] = type.value;
|
||||
useSubmitForm(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ def advanced_mode_builder(templates: list[dict], plugins: list, global_config: d
|
|||
"data": {
|
||||
"templates": get_forms(templates, plugins, settings, ("advanced",), is_new),
|
||||
"operation": "new" if is_new else "edit",
|
||||
"old_service_name": service_name if not service_name else "",
|
||||
"oldServerName": service_name if service_name else "",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ def easy_mode_builder(templates: list[dict], plugins: list, global_config: dict,
|
|||
"data": {
|
||||
"templates": get_forms(templates, plugins, settings, ("easy",), is_new),
|
||||
"operation": "new" if is_new else "edit",
|
||||
"old_service_name": service_name if not service_name else "",
|
||||
"oldServerName": service_name if service_name else "",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ def raw_mode_builder(templates: list[dict], plugins: list, global_config: dict,
|
|||
{
|
||||
"type": "Templates",
|
||||
"data": {
|
||||
"templates": get_forms(templates, plugins, settings, ("raw",)),
|
||||
"templates": get_forms(templates, plugins, settings, ("raw",), is_new),
|
||||
"operation": "new" if is_new else "edit",
|
||||
"old_service_name": service_name if not service_name else "",
|
||||
"oldServerName": service_name if service_name else "",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def services_builder(services):
|
|||
},
|
||||
]
|
||||
|
||||
return builder
|
||||
return base64.b64encode(bytes(json.dumps(builder), "utf-8")).decode("ascii")
|
||||
|
||||
|
||||
def services_settings(settings: dict) -> dict:
|
||||
|
|
@ -184,7 +184,7 @@ def services_action(
|
|||
"color": "delete",
|
||||
"size": "normal",
|
||||
"attrs": {
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : {server_name}, "operation" : "{operation}" }}""",
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : "{server_name}", "operation" : "{operation}" }}""",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
@ -199,7 +199,7 @@ def services_action(
|
|||
"color": "success",
|
||||
"size": "normal",
|
||||
"attrs": {
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : {server_name}, "OLD_SERVER_NAME" : {server_name}, "operation" : "edit", "IS_DRAFT" : {draft_value} }}""",
|
||||
"data-submit-form": f"""{{"SERVER_NAME" : "{server_name}", "OLD_SERVER_NAME" : "{server_name}", "operation" : "edit", "IS_DRAFT" : "{draft_value}" }}""",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,14 @@ def get_forms(templates: list = [], plugins: list = [], settings: dict = {}, ren
|
|||
We will run on each plugins, set template value if one, and override by the custom settings value if exists.
|
||||
We will format to fit each form type (easy, advanced, raw) in case
|
||||
"""
|
||||
|
||||
# Update SERVER_NAME to be empty if new
|
||||
if is_new and "SERVER_NAME" in settings:
|
||||
settings["SERVER_NAME"]["value"] = ""
|
||||
|
||||
if is_new and not "SERVER_NAME" in settings:
|
||||
settings["SERVER_NAME"] = {"value": "", "method": "ui", "global": True}
|
||||
|
||||
forms = {}
|
||||
for form in render_forms:
|
||||
forms[form] = {}
|
||||
|
|
@ -121,9 +129,6 @@ def set_raw(template: list, plugins_base: list, settings: dict, is_new: bool) ->
|
|||
if val != default_val:
|
||||
raw_value = val
|
||||
|
||||
if setting == "SERVER_NAME" and is_new:
|
||||
raw_value = ""
|
||||
|
||||
# Add value only if exists
|
||||
if raw_value:
|
||||
raw_settings[setting] = raw_value
|
||||
|
|
@ -384,9 +389,6 @@ def format_setting(
|
|||
# Update value or set default as value
|
||||
setting_value["value"] = template_settings.get(setting_name, setting_value.get("default"))
|
||||
|
||||
if setting_name == "SERVER_NAME" and is_new:
|
||||
setting_value["value"] = ""
|
||||
|
||||
# Then override by service settings if not a multiple
|
||||
# Case multiple, we need to keep the default value and override only each multiple group
|
||||
if setting_name in settings and not "multiple" in setting_value:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
"raw": {
|
||||
"default": {
|
||||
"MULTISITE": "yes",
|
||||
"SERVER_NAME": "app1.example.com",
|
||||
"LOG_LEVEL": "info",
|
||||
"API_WHITELIST_IP": "127.0.0.0/24 10.20.30.0/24",
|
||||
"BUNKERWEB_INSTANCES": "bunkerweb",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
W3sidHlwZSI6ICJjYXJkIiwgImNvbnRhaW5lckNvbHVtbnMiOiB7InBjIjogMTIsICJ0YWJsZXQiOiAxMiwgIm1vYmlsZSI6IDEyfSwgIndpZGdldHMiOiBbeyJ0eXBlIjogIlRpdGxlIiwgImRhdGEiOiB7InRpdGxlIjogImFwcDEuZXhhbXBsZS5jb20iLCAidHlwZSI6ICJjb250YWluZXIiLCAibG93ZXJjYXNlIjogdHJ1ZX19LCB7InR5cGUiOiAiU3VidGl0bGUiLCAiZGF0YSI6IHsic3VidGl0bGUiOiAic2VydmljZXNfbWFuYWdlX3N1YnRpdGxlIiwgInR5cGUiOiAiY29udGFpbmVyIiwgInN1YnRpdGxlQ2xhc3MiOiAibWItNCJ9fSwgeyJ0eXBlIjogIlRlbXBsYXRlcyIsICJkYXRhIjogeyJ0ZW1wbGF0ZXMiOiB7InJhdyI6IHsiZGVmYXVsdCI6IHsiTVVMVElTSVRFIjogInllcyIsICJMT0dfTEVWRUwiOiAiaW5mbyIsICJBUElf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WluLXBpY3R1cmU9KCksIHB1YmxpY2tleS1jcmVkZW50aWFscy1jcmVhdGU9KCksIHB1YmxpY2tleS1jcmVkZW50aWFscy1nZXQ9KCksIHNjcmVlbi13YWtlLWxvY2s9KCksIHNlcmlhbD0oKSwgc3BlYWtlci1zZWxlY3Rpb249KCksIHN0b3JhZ2UtYWNjZXNzPSgpLCB1c2I9KCksIHdlYi1zaGFyZT0oKSwgd2luZG93LW1hbmFnZW1lbnQ9KCksIHhyLXNwYXRpYWwtdHJhY2tpbmc9KCkiLCAiRElTQUJMRV9ERUZBVUxUX1NFUlZFUiI6ICJ5ZXMiLCAiU0VSVkVfRklMRVMiOiAibm8iLCAiU0VORF9BTk9OWU1PVVNfUkVQT1JUIjogIm5vIiwgIk1PRFNFQ1VSSVRZX0NSU19WRVJTSU9OIjogIjQiLCAiVVNFX1JFVkVSU0VfUFJPWFkiOiAieWVzIiwgIlJFVkVSU0VfUFJPWFlfSE9TVCI6ICJodHRwOi8vYXBwMTo4MDgwIiwgIlVTRV9XSElURUxJU1QiOiAibm8ifX19LCAib3BlcmF0aW9uIjogImVkaXQiLCAib2xkX3NlcnZpY2VfbmFtZSI6ICIifX1dfV0=
|
||||
|
|
@ -1147,8 +1147,8 @@ def instances():
|
|||
def get_service_data(page_name: str):
|
||||
|
||||
verify_data_in_form(
|
||||
data={"csrf-token": None},
|
||||
err_message=f"Missing csrf-token parameter on /{page_name}.",
|
||||
data={"csrf_token": None},
|
||||
err_message=f"Missing csrf_token parameter on /{page_name}.",
|
||||
redirect_url="services",
|
||||
)
|
||||
|
||||
|
|
@ -1168,13 +1168,18 @@ def get_service_data(page_name: str):
|
|||
# Check variables
|
||||
variables = deepcopy(request.form.to_dict())
|
||||
print(variables, flush=True)
|
||||
mode = None
|
||||
try:
|
||||
mode = variables.pop("mode")
|
||||
except:
|
||||
pass
|
||||
|
||||
del variables["csrf_token"]
|
||||
operation = variables.pop("operation")
|
||||
|
||||
# Delete custom client variables
|
||||
try:
|
||||
variables.pop("SECURITY_LEVEL", None)
|
||||
variables.pop("mode", None)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
@ -1240,10 +1245,10 @@ def get_service_data(page_name: str):
|
|||
del variables[variable]
|
||||
|
||||
variables = app.bw_config.check_variables(variables, config)
|
||||
return config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged
|
||||
return config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged, mode
|
||||
|
||||
|
||||
def update_service(config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged, redirect_name):
|
||||
def update_service(config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged):
|
||||
if request.form["operation"] == "edit":
|
||||
if is_draft_unchanged and len(variables) == 1 and "SERVER_NAME" in variables and server_name == old_server_name:
|
||||
return handle_error("The service was not edited because no values were changed.", "services", True)
|
||||
|
|
@ -1300,7 +1305,7 @@ def update_service(config, variables, format_configs, server_name, old_server_na
|
|||
elif request.form["operation"] == "delete":
|
||||
message = f"Deleting {'draft ' if was_draft and is_draft else ''}service {request.form.get('SERVER_NAME', '').split(' ')[0]}"
|
||||
|
||||
return redirect(url_for("loading", next=url_for(redirect_name, service_name=[server_name]), message=message))
|
||||
return message
|
||||
|
||||
|
||||
@app.route("/modes", methods=["GET", "POST"])
|
||||
|
|
@ -1310,8 +1315,16 @@ def services_modes():
|
|||
if DB.readonly:
|
||||
return handle_error("Database is in read-only mode", "services")
|
||||
|
||||
config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged = get_service_data("modes")
|
||||
update_service(config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged, "raw-mode")
|
||||
config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged, mode = get_service_data("modes")
|
||||
message = update_service(config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged)
|
||||
print(message, flush=True)
|
||||
print("mode", mode, "service name", server_name, flush=True)
|
||||
# TODO: redirect to /mode?service_name=my_service&mode=my_mode
|
||||
# Following is not working :
|
||||
# return redirect(url_for("loading", next=url_for("modes", mode=mode, service_name=server_name), message=message))
|
||||
# or
|
||||
# return redirect(url_for("loading", next=url_for(f"modes?service_name={server_name}&mode={mode}"), message=message))
|
||||
return redirect(url_for("loading", next=url_for(request.endpoint), message=message))
|
||||
|
||||
if not request.args.get("mode"):
|
||||
return handle_error("Mode type is missing to access /modes.", "services")
|
||||
|
|
@ -1353,8 +1366,11 @@ def services():
|
|||
if DB.readonly:
|
||||
return handle_error("Database is in read-only mode", "services")
|
||||
|
||||
config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged = get_service_data("services")
|
||||
update_service(config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged, "services")
|
||||
config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged, mode = get_service_data("services")
|
||||
|
||||
message = update_service(config, variables, format_configs, server_name, old_server_name, operation, is_draft, was_draft, is_draft_unchanged)
|
||||
|
||||
return redirect(url_for("loading", next=url_for("services"), message=message))
|
||||
|
||||
# Display services
|
||||
services = []
|
||||
|
|
|
|||
8
src/ui/templates/global-config.html
vendored
8
src/ui/templates/global-config.html
vendored
|
|
@ -7,10 +7,10 @@
|
|||
<link rel="stylesheet" href="css/flag-icons.min.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BunkerWeb | Global config</title>
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/global_config-CZ0G5nSa.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-BIcESj1V.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-BydAGXrY.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Templates-DP-xygY2.js">
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/global_config-Bbd-rVb6.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-Bzn9Bwnl.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-D8ODdwjg.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Templates--9yerr1U.js">
|
||||
<link rel="stylesheet" crossorigin href="assets/ButtonGroup-D2kv0NCW.css">
|
||||
</head>
|
||||
|
||||
|
|
|
|||
4
src/ui/templates/home.html
vendored
4
src/ui/templates/home.html
vendored
|
|
@ -7,8 +7,8 @@
|
|||
<link rel="stylesheet" href="css/flag-icons.min.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BunkerWeb | Home</title>
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/home-NrasATfu.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-BIcESj1V.js">
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/home-ICmkvFmx.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-Bzn9Bwnl.js">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
|||
6
src/ui/templates/instances.html
vendored
6
src/ui/templates/instances.html
vendored
|
|
@ -7,9 +7,9 @@
|
|||
<link rel="stylesheet" href="css/flag-icons.min.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BunkerWeb | Instances</title>
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/instances-DxqGoKEC.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-BIcESj1V.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-BydAGXrY.js">
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/instances-CzjX3yAI.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-Bzn9Bwnl.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-D8ODdwjg.js">
|
||||
<link rel="stylesheet" crossorigin href="assets/ButtonGroup-D2kv0NCW.css">
|
||||
</head>
|
||||
|
||||
|
|
|
|||
6
src/ui/templates/jobs.html
vendored
6
src/ui/templates/jobs.html
vendored
|
|
@ -7,9 +7,9 @@
|
|||
<link rel="stylesheet" href="css/flag-icons.min.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BunkerWeb | Jobs</title>
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/jobs-DeJBFKqF.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-BIcESj1V.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-BydAGXrY.js">
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/jobs-BV_6EZGr.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-Bzn9Bwnl.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-D8ODdwjg.js">
|
||||
<link rel="stylesheet" crossorigin href="assets/ButtonGroup-D2kv0NCW.css">
|
||||
</head>
|
||||
|
||||
|
|
|
|||
10
src/ui/templates/modes.html
vendored
10
src/ui/templates/modes.html
vendored
|
|
@ -6,11 +6,11 @@
|
|||
<link rel="stylesheet" href="css/style.css" />
|
||||
<link rel="stylesheet" href="css/flag-icons.min.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BunkerWeb | Raw mode</title>
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/modes-5pzf6B6M.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-BIcESj1V.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-BydAGXrY.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Templates-DP-xygY2.js">
|
||||
<title>BunkerWeb | Modes</title>
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/modes-BwlKIq_9.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-Bzn9Bwnl.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-D8ODdwjg.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Templates--9yerr1U.js">
|
||||
<link rel="stylesheet" crossorigin href="assets/ButtonGroup-D2kv0NCW.css">
|
||||
</head>
|
||||
|
||||
|
|
|
|||
6
src/ui/templates/services.html
vendored
6
src/ui/templates/services.html
vendored
|
|
@ -7,9 +7,9 @@
|
|||
<link rel="stylesheet" href="css/flag-icons.min.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BunkerWeb | Services</title>
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/services-DZJyCK1K.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-BIcESj1V.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-BydAGXrY.js">
|
||||
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/services-DCDrkWrE.js"></script>
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-Bzn9Bwnl.js">
|
||||
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/ButtonGroup-D8ODdwjg.js">
|
||||
<link rel="stylesheet" crossorigin href="assets/ButtonGroup-D2kv0NCW.css">
|
||||
</head>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue