diff --git a/docs/json2md.py b/docs/json2md.py index aa9034417..761771819 100755 --- a/docs/json2md.py +++ b/docs/json2md.py @@ -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} crow pro icon\n" + doc = StringIO() print("# Settings\n", file=doc) diff --git a/docs/settings.md b/docs/settings.md index 1517c3039..5c656237e 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -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. | - diff --git a/src/ui/src/ConfigFiles.py b/src/ui/src/ConfigFiles.py index beb30a90b..af5f2e778 100644 --- a/src/ui/src/ConfigFiles.py +++ b/src/ui/src/ConfigFiles.py @@ -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}") diff --git a/src/ui/static/js/global_config.js b/src/ui/static/js/global_config.js index 804515d0a..2098e5275 100644 --- a/src/ui/static/js/global_config.js +++ b/src/ui/static/js/global_config.js @@ -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 diff --git a/src/ui/static/js/services.js b/src/ui/static/js/services.js index 03e196df7..95e5ae1bd 100644 --- a/src/ui/static/js/services.js +++ b/src/ui/static/js/services.js @@ -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) => { diff --git a/tests/SwarmTest.py b/tests/SwarmTest.py index 2d6880a81..f2c2081a5 100644 --- a/tests/SwarmTest.py +++ b/tests/SwarmTest.py @@ -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,