fix form builder + mult del + drop console build

* update vite config to remove all console mehthods unless console.error for production
* update files to update catch console.log by console.error
* fix error on form builder script that didn't check properly prefix and resulted on group value reset
* update form store : on group delete, this will replace value by default
* fix save disabled/enabled state on advanced mode
This commit is contained in:
Jordan Blasenhauer 2024-07-27 18:40:31 +02:00
parent a90fd30c4a
commit 59ae53a2a9
14 changed files with 218 additions and 151 deletions

View file

@ -355,34 +355,41 @@ def get_multiple_from_template(template, multiples):
format_setting = "_".join(setting_split[:-1])
# loop on settings of a multiple group
for mult_name, mult_settings in multiple_plugin.items():
# Check if at least one multiple plugin setting is matching the template setting
if format_setting in mult_settings:
if not mult_name in multiple_template:
multiple_template[mult_name] = {}
# Case it is, we will check if already a group with the right prefix exists
# If not, we will create it
if not prefix in multiple_template[mult_name]:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
new_multiple_group = copy.deepcopy(new_multiple_group)
# Check if at least one settign is matching a multiple setting
if not format_setting in mult_settings:
continue
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
# Case we have at least one multiple setting, we can check if multiple name exists or create it
if not mult_name in multiple_template:
multiple_template[mult_name] = {}
multiple_template[mult_name][prefix] = new_multiple_group
# Case it is, we will check if already a group with the right prefix exists
# If not, we will create it
if not prefix in multiple_template[mult_name]:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
# We can now add the template value to setting using the same setting name with prefix
multiple_template[mult_name][prefix][setting]["value"] = value
new_multiple_group = copy.deepcopy(new_multiple_group)
# Sort key incrementally
for mult_name, mult_settings in multiple_template.items():
multiple_template[mult_name] = dict(sorted(mult_settings.items(), key=lambda item: int(item[0])))
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
multiple_template[mult_name][prefix] = new_multiple_group
# We can now add the template value to setting using the same setting name with prefix
multiple_template[mult_name][prefix][setting]["value"] = value
multiple_template[mult_name][prefix][setting]["prev_value"] = value
multiple_template[mult_name][prefix][setting]["method"] = "default"
# Sort key incrementally
for mult_name, mult_settings in multiple_template.items():
multiple_template[mult_name] = dict(sorted(mult_settings.items(), key=lambda item: int(item[0])))
return multiple_template
@ -409,42 +416,53 @@ def get_multiple_from_settings(settings, multiples):
if setting_split[-1].isdigit():
prefix = setting_split[-1]
format_setting = "_".join(setting_split[:-1])
# loop on settings of a multiple group
for mult_name, mult_settings in multiple_plugins.items():
# Check if at least one multiple plugin setting is matching the template setting
if format_setting in mult_settings:
if not mult_name in multiple_settings:
multiple_settings[mult_name] = {}
# Case it is, we will check if already a group with the right prefix exists
# If not, we will create it
if not prefix in multiple_settings:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
# Check if at least one settign is matching a multiple setting
if not format_setting in mult_settings:
continue
new_multiple_group = copy.deepcopy(new_multiple_group)
# Case we have at least one multiple setting, we can check if multiple name exists or create it
if not mult_name in multiple_settings:
multiple_settings[mult_name] = {}
# Now check if prefix exist for this mult
if not prefix in multiple_settings[mult_name]:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
new_multiple_group = copy.deepcopy(new_multiple_group)
multiple_settings[mult_name][prefix] = new_multiple_group
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
multiple_settings[mult_name][prefix] = new_multiple_group
# Update multiple template with real data
multiple_settings[mult_name][prefix][setting]["value"] = value.get("value", multiple_settings[mult_name][prefix][setting]["value"])
multiple_settings[mult_name][prefix][setting]["prev_value"] = value.get("value", multiple_settings[mult_name][prefix][setting]["value"])
multiple_settings[mult_name][prefix][setting]["method"] = value.get("method", "ui")
multiple_settings[mult_name][prefix][setting]["disabled"] = False if value.get("method", "ui") in ("ui", "default", "manual") else True
# Add popovers if setting is disabled else stop
if not multiple_settings[mult_name][prefix][setting].get("disabled", False):
continue
multiple_settings[mult_name][prefix][setting]["popovers"] = [
{
"iconName": "trespass",
"text": "inp_popover_method_disabled",
}
] + multiple_settings[
mult_name
][prefix][setting].get("popovers", [])
# We can now add the template value to setting using the same setting name with prefix
multiple_settings[mult_name][prefix][setting]["value"] = value.get("value", multiple_settings[mult_name][prefix][setting]["value"])
multiple_settings[mult_name][prefix][setting]["method"] = value.get("method", "ui")
multiple_settings[mult_name][prefix][setting]["disabled"] = False if value.get("method", "ui") in ("ui", "default", "manual") else True
if multiple_settings[mult_name][prefix][setting].get("disabled", False):
multiple_settings[mult_name][prefix][setting]["popovers"] = [
{
"iconName": "trespass",
"text": "inp_popover_method_disabled",
}
] + multiple_settings[mult_name][prefix][setting].get("popovers", [])
return multiple_settings

View file

@ -57,7 +57,6 @@ const data = reactive({
@returns {void}
*/
function updateRaw(v) {
console.log("update");
// Transform to a possible valid JSON
rawForm.setRawData(v, true);
let dataToCheck = v;
@ -90,7 +89,7 @@ function updateRaw(v) {
rawForm.setTemplate(json, true);
data.isValid = true;
} catch (e) {
console.log(e);
console.error(e);
data.isValid = false;
}
}

View file

@ -198,7 +198,7 @@ class Editor {
currTabIndex++;
}
} catch (err) {
console.log(err);
console.error(err);
}
},
readOnly: true,
@ -228,7 +228,7 @@ class Editor {
currTabIndex++;
}
} catch (err) {
console.log(err);
console.error(err);
}
},
readOnly: true,
@ -300,7 +300,7 @@ function removeErrCSS() {
editor.style = dictStyle;
});
} catch (e) {
console.log(e);
console.error(e);
}
}, 100);
}
@ -327,7 +327,7 @@ function setEditorAttrs() {
editorEl.editor.gotoLine(editorRange.start.row, editorRange.start.column);
});
} catch (e) {
console.log(e);
console.error(e);
}
}

View file

@ -84,16 +84,14 @@ export const createFormStore = (storeName, formType) => {
);
// For back end, we need to keep the group but updating values to default in order to delete it
for (const [key, value] of Object.entries(
for (const [settName, setting] of Object.entries(
templateBase.value[index].multiples[multName][groupName]
)) {
value.value = value.default;
setting.value = setting.default;
}
// For UI, we can delete the group to avoid rendering it
delete templateUI.value[index].multiples[multName][groupName];
updateCount.value++;
_updateTempState();
}

View file

@ -17,7 +17,7 @@ function useForm() {
const data = JSON.parse(e.target.getAttribute("data-submit-form"));
useSubmitForm(data);
} catch (e) {
console.log(e);
console.error(e);
}
});
}

View file

@ -4361,6 +4361,7 @@
},
"disabled": false,
"value": "",
"method": "default",
"prev_value": "",
"popovers": [
{
@ -5650,7 +5651,8 @@
"text": "URL (PCRE regex) where the limit request will be applied or special value / for all requests."
}
],
"containerClass": "z-6"
"containerClass": "z-6",
"method": "default"
},
"LIMIT_REQ_RATE": {
"context": "multisite",
@ -8617,8 +8619,8 @@
"mobile": 12
},
"disabled": false,
"value": "",
"prev_value": "",
"value": "dzq",
"prev_value": "dzq",
"popovers": [
{
"iconName": "disk",
@ -8629,7 +8631,8 @@
"text": "Full URL of the proxied resource (proxy_pass)."
}
],
"containerClass": "z-26"
"containerClass": "z-26",
"method": "ui"
},
"REVERSE_PROXY_URL": {
"context": "multisite",
@ -8661,7 +8664,8 @@
"text": "Location URL that will be proxied."
}
],
"containerClass": "z-25"
"containerClass": "z-25",
"method": "default"
},
"REVERSE_PROXY_WS": {
"context": "multisite",
@ -8693,7 +8697,8 @@
"text": "Enable websocket on the proxied resource."
}
],
"containerClass": "z-24"
"containerClass": "z-24",
"method": "default"
},
"REVERSE_PROXY_HEADERS": {
"context": "multisite",
@ -8725,7 +8730,8 @@
"text": "List of HTTP headers to send to proxied resource separated with semicolons (values for proxy_set_header directive)."
}
],
"containerClass": "z-23"
"containerClass": "z-23",
"method": "default"
},
"REVERSE_PROXY_HEADERS_CLIENT": {
"context": "multisite",
@ -8757,7 +8763,8 @@
"text": "List of HTTP headers to send to client separated with semicolons (values for add_header directive)."
}
],
"containerClass": "z-22"
"containerClass": "z-22",
"method": "default"
},
"REVERSE_PROXY_BUFFERING": {
"context": "multisite",
@ -8789,7 +8796,8 @@
"text": "Enable or disable buffering of responses from proxied resource."
}
],
"containerClass": "z-21"
"containerClass": "z-21",
"method": "default"
},
"REVERSE_PROXY_KEEPALIVE": {
"context": "multisite",
@ -8821,7 +8829,8 @@
"text": "Enable or disable keepalive connections with the proxied resource."
}
],
"containerClass": "z-20"
"containerClass": "z-20",
"method": "default"
},
"REVERSE_PROXY_AUTH_REQUEST": {
"context": "multisite",
@ -8853,7 +8862,8 @@
"text": "Enable authentication using an external provider (value of auth_request directive)."
}
],
"containerClass": "z-19"
"containerClass": "z-19",
"method": "default"
},
"REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL": {
"context": "multisite",
@ -8885,7 +8895,8 @@
"text": "Redirect clients to sign-in URL when using REVERSE_PROXY_AUTH_REQUEST (used when auth_request call returned 401)."
}
],
"containerClass": "z-18"
"containerClass": "z-18",
"method": "default"
},
"REVERSE_PROXY_AUTH_REQUEST_SET": {
"context": "multisite",
@ -8917,7 +8928,8 @@
"text": "List of variables to set from the authentication provider, separated with semicolons (values of auth_request_set directives)."
}
],
"containerClass": "z-17"
"containerClass": "z-17",
"method": "default"
},
"REVERSE_PROXY_CONNECT_TIMEOUT": {
"context": "multisite",
@ -8949,7 +8961,8 @@
"text": "Timeout when connecting to the proxied resource."
}
],
"containerClass": "z-16"
"containerClass": "z-16",
"method": "default"
},
"REVERSE_PROXY_READ_TIMEOUT": {
"context": "multisite",
@ -8981,7 +8994,8 @@
"text": "Timeout when reading from the proxied resource."
}
],
"containerClass": "z-15"
"containerClass": "z-15",
"method": "default"
},
"REVERSE_PROXY_SEND_TIMEOUT": {
"context": "multisite",
@ -9013,7 +9027,8 @@
"text": "Timeout when sending to the proxied resource."
}
],
"containerClass": "z-14"
"containerClass": "z-14",
"method": "default"
},
"REVERSE_PROXY_INCLUDES": {
"context": "multisite",
@ -9873,7 +9888,6 @@
},
"disabled": false,
"value": "",
"method": "default",
"prev_value": "",
"popovers": [
{
@ -9998,7 +10012,8 @@
"KEEP_UPSTREAM_HEADERS": "Content-Security-Policy Permissions-Policy X-Frame-Options",
"STRICT_TRANSPORT_SECURITY": "max-age=31536000; includeSubDomains; preload",
"PERMISSIONS_POLICY": "accelerometer=(), ambient-light-sensor=(), attribution-reporting=(), autoplay=(), battery=(), bluetooth=(), browsing-topics=(), camera=(), compute-pressure=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), gamepad=(), geolocation=(), gyroscope=(), hid=(), identity-credentials-get=(), idle-detection=(), local-fonts=(), magnetometer=(), microphone=(), midi=(), otp-credentials=(), payment=(), picture-in-picture=(), publickey-credentials-create=(), publickey-credentials-get=(), screen-wake-lock=(), serial=(), speaker-selection=(), storage-access=(), usb=(), web-share=(), window-management=(), xr-spatial-tracking=()",
"MODSECURITY_CRS_VERSION": "4"
"MODSECURITY_CRS_VERSION": "4",
"REVERSE_PROXY_HOST": "dzq"
}
}
}

View file

@ -3032,6 +3032,7 @@ global_config = {
"PRO_LICENSE_KEY": {"value": "", "global": True, "method": "default"},
"SESSIONS_SECRET": {"value": "random", "global": True, "method": "default"},
"USE_MODSECURITY": {"value": "yes", "global": True, "method": "default"},
"USE_SECURITYTXT": {"value": "no", "global": True, "method": "default"},
"USE_BAD_BEHAVIOR": {"value": "yes", "global": True, "method": "default"},
"USE_CLIENT_CACHE": {"value": "yes", "global": True, "method": "scheduler"},
"USE_REVERSE_SCAN": {"value": "no", "global": True, "method": "default"},
@ -3068,6 +3069,7 @@ global_config = {
"BACKUP_SCHEDULE": {"value": "daily", "global": True, "method": "default"},
"CUSTOM_SSL_CERT": {"value": "", "global": True, "method": "default"},
"REMOTE_PHP_PATH": {"value": "", "global": True, "method": "default"},
"SECURITYTXT_URI": {"value": "/.well-known/security.txt", "global": True, "method": "default"},
"BUNKERNET_SERVER": {"value": "https://api.bunkerweb.io", "global": True, "method": "default"},
"CORS_ALLOW_ORIGIN": {"value": "self", "global": True, "method": "default"},
"WHITELIST_COUNTRY": {"value": "", "global": True, "method": "default"},
@ -3105,6 +3107,7 @@ global_config = {
"CLIENT_CACHE_ETAG": {"value": "yes", "global": True, "method": "default"},
"CORS_ALLOW_METHODS": {"value": "GET, POST, OPTIONS", "global": True, "method": "default"},
"DATABASE_LOG_LEVEL": {"value": "warning", "global": True, "method": "default"},
"SECURITYTXT_CONTACT": {"value": "", "global": True, "method": "default"},
"ANTIBOT_TIME_RESOLVE": {"value": "60", "global": True, "method": "default"},
"REVERSE_SCAN_TIMEOUT": {"value": "500", "global": True, "method": "default"},
"SELF_SIGNED_SSL_SUBJ": {"value": "/CN=www.example.com/", "global": True, "method": "default"},
@ -3128,6 +3131,7 @@ global_config = {
"ANTIBOT_TIME_VALID": {"value": "86400", "global": True, "method": "default"},
"CORS_ALLOW_HEADERS": {"value": "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range", "global": True, "method": "default"},
"AUTH_BASIC_PASSWORD": {"value": "changeme", "global": True, "method": "default"},
"SECURITYTXT_EXPIRES": {"value": "", "global": True, "method": "default"},
"CLIENT_CACHE_CONTROL": {"value": "public, max-age=15552000", "global": True, "method": "default"},
"CUSTOM_SSL_CERT_DATA": {"value": "", "global": True, "method": "default"},
"GREYLIST_RDNS_GLOBAL": {"value": "yes", "global": True, "method": "default"},
@ -3154,6 +3158,7 @@ global_config = {
"LIMIT_CONN_MAX_HTTP1": {"value": "10", "global": True, "method": "default"},
"BAD_BEHAVIOR_BAN_TIME": {"value": "86400", "global": True, "method": "default"},
"CORS_ALLOW_CREDENTIALS": {"value": "no", "global": True, "method": "default"},
"SECURITYTXT_ENCRYPTION": {"value": "", "global": True, "method": "default"},
"ANTIBOT_RECAPTCHA_SCORE": {"value": "0.7", "global": True, "method": "default"},
"SESSIONS_ABSOLUTE_TIMEOUT": {"value": "86400", "global": True, "method": "default"},
"REVERSE_PROXY_SSL_SNI_NAME": {"value": "", "global": True, "method": "default"},
@ -3163,7 +3168,7 @@ global_config = {
"REDIS_SSL_VERIFY": {"value": "no", "global": True, "method": "default"},
"REAL_IP_FROM_URLS": {"value": "", "global": True, "method": "default"},
"SESSIONS_CHECK_IP": {"value": "yes", "global": True, "method": "default"},
"REVERSE_PROXY_HOST": {"value": "", "global": True, "method": "default"},
"REVERSE_PROXY_HOST": {"value": "dzq", "global": True, "method": "ui"},
"CORS_EXPOSE_HEADERS": {"value": "Content-Length,Content-Range", "global": True, "method": "default"},
"GREYLIST_USER_AGENT": {"value": "", "global": True, "method": "default"},
"BLACKLIST_USER_AGENT": {"value": "", "global": True, "method": "default"},
@ -3172,6 +3177,7 @@ global_config = {
"COOKIE_AUTO_SECURE_FLAG": {"value": "yes", "global": True, "method": "default"},
"ANTIBOT_RECAPTCHA_SITEKEY": {"value": "", "global": True, "method": "default"},
"MODSECURITY_SEC_AUDIT_ENGINE": {"value": "RelevantOnly", "global": True, "method": "default"},
"SECURITYTXT_ACKNOWLEDGEMENTS": {"value": "", "global": True, "method": "default"},
"SERVE_FILES": {"value": "no", "global": True, "method": "scheduler"},
"GREYLIST_URI": {"value": "", "global": True, "method": "default"},
"BLACKLIST_URI": {"value": "", "global": True, "method": "default"},
@ -3184,6 +3190,7 @@ global_config = {
"ANTIBOT_RECAPTCHA_SECRET": {"value": "", "global": True, "method": "default"},
"SESSIONS_CHECK_USER_AGENT": {"value": "yes", "global": True, "method": "default"},
"CROSS_ORIGIN_OPENER_POLICY": {"value": "same-origin", "global": True, "method": "default"},
"SECURITYTXT_PREFERRED_LANG": {"value": "en", "global": True, "method": "default"},
"MODSECURITY_SEC_RULE_ENGINE": {"value": "On", "global": True, "method": "default"},
"ROOT_FOLDER": {"value": "", "global": True, "method": "default"},
"REDIS_USERNAME": {"value": "", "global": True, "method": "default"},
@ -3192,6 +3199,7 @@ global_config = {
"WHITELIST_IP_URLS": {"value": "", "global": True, "method": "default"},
"BLACKLIST_IGNORE_IP": {"value": "", "global": True, "method": "default"},
"WORKER_RLIMIT_NOFILE": {"value": "2048", "global": True, "method": "default"},
"SECURITYTXT_CANONICAL": {"value": "", "global": True, "method": "default"},
"ANTIBOT_HCAPTCHA_SITEKEY": {"value": "", "global": True, "method": "default"},
"CROSS_ORIGIN_EMBEDDER_POLICY": {"value": "require-corp", "global": True, "method": "default"},
"MODSECURITY_SEC_AUDIT_LOG_PARTS": {"value": "ABCFHZ", "global": True, "method": "default"},
@ -3200,8 +3208,9 @@ global_config = {
"REDIS_PASSWORD": {"value": "", "global": True, "method": "default"},
"REFERRER_POLICY": {"value": "strict-origin-when-cross-origin", "global": True, "method": "default"},
"GREYLIST_RDNS_URLS": {"value": "", "global": True, "method": "default"},
"SECURITYTXT_POLICY": {"value": "", "global": True, "method": "default"},
"WORKER_CONNECTIONS": {"value": "1024", "global": True, "method": "default"},
"WHITELIST_RDNS_URLS": {"value": "", "global": True, "method": "default"},
"WHITELIST_2024-07-27T15:51:01.203516525Z RDNS_URLS": {"value": "", "global": True, "method": "default"},
"BLACKLIST_IGNORE_RDNS": {"value": "", "global": True, "method": "default"},
"REVERSE_PROXY_HEADERS": {"value": "", "global": True, "method": "default"},
"ANTIBOT_HCAPTCHA_SECRET": {"value": "", "global": True, "method": "default"},
@ -3213,12 +3222,13 @@ global_config = {
"method": "default",
},
"CORS_MAX_AGE": {"value": "86400", "global": True, "method": "default"},
"GR2024-07-23T07:35:15.190324876Z EYLIST_ASN_URLS": {"value": "", "global": True, "method": "default"},
"GREYLIST_ASN_URLS": {"value": "", "global": True, "method": "default"},
"PERMISSIONS_POLICY": {
"value": "accelerometer=(), ambient-light-sensor=(), attribution-reporting=(), autoplay=(), battery=(), bluetooth=(), browsing-topics=(), camera=(), compute-pressure=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), gamepad=(), geolocation=(), gyroscope=(), hid=(), identity-credentials-get=(), idle-detection=(), local-fonts=(), magnetometer=(), microphone=(), midi=(), otp-credentials=(), payment=(), picture-in-picture=(), publickey-credentials-create=(), publickey-credentials-get=(), screen-wake-lock=(), serial=(), speaker-selection=(), storage-access=(), usb=(), web-share=(), window-management=(), xr-spatial-tracking=()",
"global": True,
"method": "default",
},
"SECURITYTXT_HIRING": {"value": "", "global": True, "method": "default"},
"WHITELIST_ASN_URLS": {"value": "", "global": True, "method": "default"},
"BLACKLIST_IGNORE_ASN": {"value": "", "global": True, "method": "default"},
"REDIS_SENTINEL_HOSTS": {"value": "", "global": True, "method": "default"},
@ -3227,6 +3237,7 @@ global_config = {
"HTTP3": {"value": "no", "global": True, "method": "default"},
"LOG_LEVEL": {"value": "info", "global": True, "method": "scheduler"},
"DISABLE_FLOC": {"value": "yes", "global": True, "method": "default"},
"SECURITYTXT_CSAF": {"value": "", "global": True, "method": "default"},
"CORS_DENY_REQUEST": {"value": "yes", "global": True, "method": "default"},
"REDIS_SENTINEL_USERNAME": {"value": "", "global": True, "method": "default"},
"REVERSE_PROXY_BUFFERING": {"value": "yes", "global": True, "method": "default"},
@ -3473,34 +3484,41 @@ def get_multiple_from_template(template, multiples):
format_setting = "_".join(setting_split[:-1])
# loop on settings of a multiple group
for mult_name, mult_settings in multiple_plugin.items():
# Check if at least one multiple plugin setting is matching the template setting
if format_setting in mult_settings:
if not mult_name in multiple_template:
multiple_template[mult_name] = {}
# Case it is, we will check if already a group with the right prefix exists
# If not, we will create it
if not prefix in multiple_template[mult_name]:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
new_multiple_group = copy.deepcopy(new_multiple_group)
# Check if at least one settign is matching a multiple setting
if not format_setting in mult_settings:
continue
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
# Case we have at least one multiple setting, we can check if multiple name exists or create it
if not mult_name in multiple_template:
multiple_template[mult_name] = {}
# Case it is, we will check if already a group with the right prefix exists
# If not, we will create it
if not prefix in multiple_template[mult_name]:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
multiple_template[mult_name][prefix] = new_multiple_group
new_multiple_group = copy.deepcopy(new_multiple_group)
# We can now add the template value to setting using the same setting name with prefix
multiple_template[mult_name][prefix][setting]["value"] = value
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
# Sort key incrementally
for mult_name, mult_settings in multiple_template.items():
multiple_template[mult_name] = dict(sorted(mult_settings.items(), key=lambda item: int(item[0])))
multiple_template[mult_name][prefix] = new_multiple_group
# We can now add the template value to setting using the same setting name with prefix
multiple_template[mult_name][prefix][setting]["value"] = value
multiple_template[mult_name][prefix][setting]["prev_value"] = value
multiple_template[mult_name][prefix][setting]["method"] = "default"
# Sort key incrementally
for mult_name, mult_settings in multiple_template.items():
multiple_template[mult_name] = dict(sorted(mult_settings.items(), key=lambda item: int(item[0])))
return multiple_template
@ -3527,42 +3545,53 @@ def get_multiple_from_settings(settings, multiples):
if setting_split[-1].isdigit():
prefix = setting_split[-1]
format_setting = "_".join(setting_split[:-1])
# loop on settings of a multiple group
for mult_name, mult_settings in multiple_plugins.items():
# Check if at least one multiple plugin setting is matching the template setting
if format_setting in mult_settings:
if not mult_name in multiple_settings:
multiple_settings[mult_name] = {}
# Case it is, we will check if already a group with the right prefix exists
# If not, we will create it
if not prefix in multiple_settings:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
# Check if at least one settign is matching a multiple setting
if not format_setting in mult_settings:
continue
new_multiple_group = copy.deepcopy(new_multiple_group)
# Case we have at least one multiple setting, we can check if multiple name exists or create it
if not mult_name in multiple_settings:
multiple_settings[mult_name] = {}
# Now check if prefix exist for this mult
if not prefix in multiple_settings[mult_name]:
# We want each settings to have the prefix if exists
# We will get the value of the setting without the prefix and create a prefix key with the same value
# And after that we can delete the original setting
new_multiple_group = {}
for multSett, multValue in mult_settings.items():
new_multiple_group[f"{multSett}{f'_{prefix}' if prefix != '0' else ''}"] = multValue
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
new_multiple_group = copy.deepcopy(new_multiple_group)
multiple_settings[mult_name][prefix] = new_multiple_group
# Update id for each settings
for multSett, multValue in new_multiple_group.items():
multValue["id"] = f"{multValue['id']}{f'-{prefix}' if prefix != '0' else ''}"
multiple_settings[mult_name][prefix] = new_multiple_group
# Update multiple template with real data
multiple_settings[mult_name][prefix][setting]["value"] = value.get("value", multiple_settings[mult_name][prefix][setting]["value"])
multiple_settings[mult_name][prefix][setting]["prev_value"] = value.get("value", multiple_settings[mult_name][prefix][setting]["value"])
multiple_settings[mult_name][prefix][setting]["method"] = value.get("method", "ui")
multiple_settings[mult_name][prefix][setting]["disabled"] = False if value.get("method", "ui") in ("ui", "default", "manual") else True
# Add popovers if setting is disabled else stop
if not multiple_settings[mult_name][prefix][setting].get("disabled", False):
continue
multiple_settings[mult_name][prefix][setting]["popovers"] = [
{
"iconName": "trespass",
"text": "inp_popover_method_disabled",
}
] + multiple_settings[
mult_name
][prefix][setting].get("popovers", [])
# We can now add the template value to setting using the same setting name with prefix
multiple_settings[mult_name][prefix][setting]["value"] = value.get("value", multiple_settings[mult_name][prefix][setting]["value"])
multiple_settings[mult_name][prefix][setting]["method"] = value.get("method", "ui")
multiple_settings[mult_name][prefix][setting]["disabled"] = False if value.get("method", "ui") in ("ui", "default", "manual") else True
if multiple_settings[mult_name][prefix][setting].get("disabled", False):
multiple_settings[mult_name][prefix][setting]["popovers"] = [
{
"iconName": "trespass",
"text": "inp_popover_method_disabled",
}
] + multiple_settings[mult_name][prefix][setting].get("popovers", [])
return multiple_settings
@ -3592,6 +3621,7 @@ def set_multiples(template, format_plugins, settings):
multiples[mult_name] = {}
multiples[mult_name][setting] = value
settings_to_delete.append(setting)
# Delete multiple settings from regular settings
@ -3667,7 +3697,7 @@ def format_setting(
if setting_name in settings and not "multiple" in setting_value:
setting_value["value"] = settings[setting_name].get("value", setting_value.get("value", setting_value.get("default")))
setting_value["method"] = settings[setting_name].get("method", "ui")
# Add prev_value in order to check if value has changed to submit it
setting_value["prev_value"] = setting_value.get("value")

File diff suppressed because one or more lines are too long

View file

@ -2,6 +2,7 @@ import { resolve } from "path";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
import { comment } from "postcss";
// https://vitejs.dev/config/
export default defineConfig({
@ -32,6 +33,9 @@ export default defineConfig({
"@public": resolve(__dirname, "./public"),
},
},
esbuild: {
drop: ["console.log"],
},
build: {
minify: "esbuild",
chunkSizeWarningLimit: 1024,

View file

@ -27,6 +27,9 @@ export default defineConfig({
"@public": resolve(__dirname, "./public"),
},
},
esbuild: {
drop: ["console.log", "console.info", "console.warn"],
},
build: {
minify: "esbuild",
chunkSizeWarningLimit: 1024,

View file

@ -4,7 +4,7 @@ class Ping {
btnEl = null, // disabled while fethching
statusTextEl = null, // update text with fetching result
statusColorEl = null, // update color with fetching result
key_to_check = "ping", // key to check in response data
key_to_check = "ping" // key to check in response data
) {
this.url = url;
this.btnEl = btnEl;
@ -48,7 +48,7 @@ class Ping {
],
"bg-sky-500 p-4 mb-1 md:mb-3 md:mr-3 z-[1001] flex flex-col fixed bottom-0 right-0 w-full md:w-1/2 max-w-[300px] min-h-20 rounded-lg dark:brightness-110 hover:scale-102 transition shadow-md break-words dark:shadow-dark-xl bg-clip-border",
"",
"",
""
);
// Status
@ -57,7 +57,7 @@ class Ping {
[["data-fetch-status", ""]],
"text-lg mb-0 text-white dark:text-gray-300",
"Fetching",
this.alertEl,
this.alertEl
);
this.alertMsgEl = this.createEl(
@ -65,7 +65,7 @@ class Ping {
[["data-fetch-msg", ""]],
"text-white dark:text-gray-300 mb-0 text-sm",
"Please wait...",
this.alertEl,
this.alertEl
);
document.body.appendChild(this.alertEl);
@ -87,7 +87,7 @@ class Ping {
// Show error
if (data?.error) {
const error = data?.error || "Action exception, no details available";
console.log(error);
console.error(error);
// Remove previous data-action-error
const prevError = document.querySelectorAll("[data-action-error]");
if (prevError.length) prevError.forEach((el) => el.remove());
@ -124,7 +124,7 @@ class Ping {
"226",
];
const isSuccess = successValues.includes(
data[this.key_to_check].toString(),
data[this.key_to_check].toString()
);
if (isSuccess) {

View file

@ -7,12 +7,12 @@
<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-sP0XfldY.js"></script>
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/global_config-K7hHVP1z.js"></script>
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Title-Dk3fE87D.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Subtitle-EK-_CGmV.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-CrOYIQ2t.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Filter-ByMTlYtF.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/form-DBYbte-L.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Filter-Bx6Njejh.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/form-CNPgGkGx.js">
<link rel="stylesheet" crossorigin href="assets/Filter-D2kv0NCW.css">
</head>

View file

@ -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-ByhYrW6H.js"></script>
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/instances-BYLkx-sA.js"></script>
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Title-Dk3fE87D.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/form-DBYbte-L.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/form-CNPgGkGx.js">
</head>
<body>

View file

@ -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 | Jobs</title>
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/jobs-fcsA3eYf.js"></script>
<script type="module" crossorigin nonce="{{ script_nonce }}" src="assets/jobs-DMDsbVex.js"></script>
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Title-Dk3fE87D.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Text-CrOYIQ2t.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Filter-ByMTlYtF.js">
<link rel="modulepreload" crossorigin nonce="{{ script_nonce }}" href="assets/Filter-Bx6Njejh.js">
<link rel="stylesheet" crossorigin href="assets/Filter-D2kv0NCW.css">
</head>