Fix path generation + precommit

This commit is contained in:
Jordan Blasenhauer 2024-03-21 14:57:54 +01:00
parent 04d536cd7e
commit f095ecdb8c
6 changed files with 91 additions and 79 deletions

View file

@ -10,6 +10,7 @@ import zipfile
import shutil
from contextlib import suppress
def print_md_table(settings) -> MarkdownTableWriter:
writer = MarkdownTableWriter(
headers=["Setting", "Default", "Context", "Multiple", "Description"],
@ -26,6 +27,7 @@ def print_md_table(settings) -> MarkdownTableWriter:
)
return writer
def stream_support(support) -> str:
md = "STREAM support "
if support == "no":
@ -36,9 +38,11 @@ def stream_support(support) -> str:
md += ":warning:"
return md
def pro_title(title: str) -> str:
return f"## {title} <img src='/assets/img/pro-icon.svg' alt='crow pro icon' height='32px' width='32px'>\n"
doc = StringIO()
print("# Settings\n", file=doc)

View file

@ -643,4 +643,3 @@ Allow access based on internal and external IP/network/rDNS/ASN whitelists.
|`WHITELIST_USER_AGENT_URLS`| |global |no |List of URLs, separated with spaces, containing good User-Agent to whitelist. |
|`WHITELIST_URI` | |multisite|no |List of URI (PCRE regex), separated with spaces, to whitelist. |
|`WHITELIST_URI_URLS` | |global |no |List of URLs, separated with spaces, containing bad URI to whitelist. |

View file

@ -58,14 +58,21 @@ class ConfigFiles:
if files or (dirs and basename(root) not in root_dirs):
path_exploded = root.split("/")
for file in files:
# root_dirs is index 4 on path exploded
# in case this is a service config, index 5 is the service id and index 6 is the config name
# else index 5 is the config name
service_id = path_exploded[5] if len(path_exploded) >= 6 else None
root_dir = path_exploded[4]
path_result = (service_id, root_dir, file.replace(".conf", ""))
with open(join(root, file), "r", encoding="utf-8") as f:
custom_configs.append(
{
"value": f.read(),
"exploded": (path_exploded.pop() if path_exploded[-1] not in root_dirs else None, path_exploded[-1], file.replace(".conf", "")),
"exploded": path_result,
}
)
print("custom config", custom_configs, flush=True)
err = self.__db.save_custom_configs(custom_configs, "ui", changed=check_changes)
if err:
self.__logger.error(f"Could not save custom configs: {err}")

View file

@ -297,15 +297,13 @@ class Multiple {
try {
const inps = setting.querySelectorAll("input");
inps.forEach((inp) => {
// case checkbox
if (inp.getAttribute("type") === "checkbox") {
const defaultVal = inp.getAttribute("data-default") || "";
if (defaultVal === "yes" && !inp.checked) {
inp.click();
}
}
// case regular
@ -314,25 +312,28 @@ class Multiple {
inp.setAttribute("value", defaultVal);
inp.value = defaultVal;
}
});
} catch(e) {
}
} catch (e) {}
// for select
try {
const selects = setting.querySelectorAll("button[data-setting-select]");
const selects = setting.querySelectorAll(
"button[data-setting-select]",
);
selects.forEach((select) => {
const defaultVal = select.getAttribute("data-default") || "";
select.querySelector('data-setting-select-text').setAttribute("data-value", defaultVal);
select.querySelector('data-setting-select-text').textContent = defaultVal;
const dropdown = document.querySelector(`[data-setting-select-dropdown="${select.getAttribute('data-setting-select')}"]`);
select
.querySelector("data-setting-select-text")
.setAttribute("data-value", defaultVal);
select.querySelector("data-setting-select-text").textContent =
defaultVal;
const dropdown = document.querySelector(
`[data-setting-select-dropdown="${select.getAttribute(
"data-setting-select",
)}"]`,
);
dropdown.querySelector(`button[value=${defaultVal}]`).click();
});
}catch(e)
{
}
} catch (e) {}
});
}
//remove last child

View file

@ -711,68 +711,69 @@ class Multiple {
//remove last child
} catch (err) {}
//REMOVE BTN
try {
if (
e.target
.closest("button")
.hasAttribute(`data-${this.prefix}-multiple-delete`)
) {
// We are not removing it really, just hiding it and update values to defaut
// By setting default value, group will be send to server and delete (because a setting with default value is useless to keep)
const multContainer = e.target.closest(
`[data-${this.prefix}-settings-multiple]`,
);
multContainer.classList.add("hidden-multiple");
// get setting container
const settings = multContainer.querySelectorAll(
`[data-setting-container]`,
);
settings.forEach((setting) => {
// for regular input
try {
const inps = setting.querySelectorAll("input");
inps.forEach((inp) => {
// case checkbox
if (inp.getAttribute("type") === "checkbox") {
const defaultVal = inp.getAttribute("data-default") || "";
if (defaultVal === "yes" && !inp.checked) {
inp.click();
}
//REMOVE BTN
try {
if (
e.target
.closest("button")
.hasAttribute(`data-${this.prefix}-multiple-delete`)
) {
// We are not removing it really, just hiding it and update values to defaut
// By setting default value, group will be send to server and delete (because a setting with default value is useless to keep)
const multContainer = e.target.closest(
`[data-${this.prefix}-settings-multiple]`,
);
multContainer.classList.add("hidden-multiple");
// get setting container
const settings = multContainer.querySelectorAll(
`[data-setting-container]`,
);
settings.forEach((setting) => {
// for regular input
try {
const inps = setting.querySelectorAll("input");
inps.forEach((inp) => {
// case checkbox
if (inp.getAttribute("type") === "checkbox") {
const defaultVal = inp.getAttribute("data-default") || "";
if (defaultVal === "yes" && !inp.checked) {
inp.click();
}
}
// case regular
if (inp.getAttribute("type") !== "checkbox") {
const defaultVal = inp.getAttribute("data-default") || "";
inp.setAttribute("value", defaultVal);
inp.value = defaultVal;
}
});
} catch(e) {
}
// for select
try {
const selects = setting.querySelectorAll("button[data-setting-select]");
selects.forEach((select) => {
const defaultVal = select.getAttribute("data-default") || "";
select.querySelector('data-setting-select-text').setAttribute("data-value", defaultVal);
select.querySelector('data-setting-select-text').textContent = defaultVal;
const dropdown = document.querySelector(`[data-setting-select-dropdown="${select.getAttribute('data-setting-select')}"]`);
dropdown.querySelector(`button[value=${defaultVal}]`).click();
});
}catch(e)
{
}
});
}
//remove last child
} catch (err) {}
// case regular
if (inp.getAttribute("type") !== "checkbox") {
const defaultVal = inp.getAttribute("data-default") || "";
inp.setAttribute("value", defaultVal);
inp.value = defaultVal;
}
});
} catch (e) {}
// for select
try {
const selects = setting.querySelectorAll(
"button[data-setting-select]",
);
selects.forEach((select) => {
const defaultVal = select.getAttribute("data-default") || "";
select
.querySelector("data-setting-select-text")
.setAttribute("data-value", defaultVal);
select.querySelector("data-setting-select-text").textContent =
defaultVal;
const dropdown = document.querySelector(
`[data-setting-select-dropdown="${select.getAttribute(
"data-setting-select",
)}"]`,
);
dropdown.querySelector(`button[value=${defaultVal}]`).click();
});
} catch (e) {}
});
}
//remove last child
} catch (err) {}
});
}
@ -963,7 +964,7 @@ class Multiple {
label.getAttribute("for").replace("_SCHEMA", suffix),
);
});
//rename popover
const popoverBtns = schemaCtnrClone.querySelectorAll("[data-popover-btn]");
popoverBtns.forEach((popoverBtn) => {

View file

@ -75,7 +75,7 @@ class SwarmTest(Test):
i += 1
if not healthy:
proc = run(
'docker stack ps --no-trunc bunkerweb',
"docker stack ps --no-trunc bunkerweb",
cwd="/tmp/swarm",
shell=True,
capture_output=True,
@ -179,7 +179,7 @@ class SwarmTest(Test):
)
for service in proc.stdout.decode().splitlines():
proc2 = run(
'docker service ps ' + service,
"docker service ps " + service,
cwd="/tmp/swarm",
shell=True,
capture_output=True,