diff --git a/files/app/main/status/e/tunnels.ut b/files/app/main/status/e/tunnels.ut
index 65ae84ea..71c091f4 100755
--- a/files/app/main/status/e/tunnels.ut
+++ b/files/app/main/status/e/tunnels.ut
@@ -272,11 +272,12 @@ function t2t(type)
@@ -379,42 +380,45 @@ This value is used by default, but each tunnel may overide it.
const available = {{sprintf("%J", available)}};
function updateTunnels()
{
- if (!htmx.closest(htmx.find("#tunnels"), "form").checkValidity()) {
- return;
- }
const tunnels = [];
let servercount = 0;
const tuns = htmx.findAll("#tunnels .tunnel");
+ const isvalid = htmx.closest(htmx.find("#tunnels"), "form").checkValidity();
for (let i = 0; i < tuns.length; i++) {
const t = tuns[i];
- const index = t.dataset.index;
- const name = htmx.find(t, "input[name=name]");
- const password = htmx.find(t, "input[name=password]");
- const key = htmx.find(t, "input[name=key]");
const type = htmx.find(t, "div[data-type]").dataset.type;
- const network = htmx.find(t, "input[name=network]");
- const notes = htmx.find(t, "input[name=notes]");
- const enable = htmx.find(t, "input[name=enable]");
- const weight = htmx.find(t, "input[name=weight]");
- tunnels.push({
- index: index,
- type: type,
- name: name.value,
- enabled: enable.checked,
- notes: notes.value || "",
- network: network.value,
- passwd: password.value,
- key: key && key.value,
- weight: weight.value
- });
+ if (isvalid) {
+ const index = t.dataset.index;
+ const name = htmx.find(t, "input[name=name]");
+ const password = htmx.find(t, "input[name=password]");
+ const key = htmx.find(t, "input[name=key]");
+ const network = htmx.find(t, "input[name=network]");
+ const notes = htmx.find(t, "input[name=notes]");
+ const enable = htmx.find(t, "input[name=enable]");
+ const weight = htmx.find(t, "input[name=weight]");
+ tunnels.push({
+ index: index,
+ type: type,
+ name: name.value,
+ enabled: enable.checked,
+ notes: notes.value || "",
+ network: network.value,
+ passwd: password.value,
+ key: key && key.value,
+ weight: weight.value
+ });
+ }
if (type === "ls" || type === "ws") {
servercount++;
}
}
- htmx.ajax("PUT", "{{request.env.REQUEST_URI}}", {
- swap: "none",
- values: { tunnels: JSON.stringify(tunnels) }
- });
+ if (isvalid) {
+ htmx.ajax("PUT", "{{request.env.REQUEST_URI}}", {
+ swap: "none",
+ values: { tunnels: JSON.stringify(tunnels) }
+ });
+ }
+ htmx.find("input[name=tunnel_server]").required = servercount > 0 ? true : false;
{% if (includeAdvanced) { %}
htmx.find("input[name=tunnel_range_start]").disabled = servercount > 0 ? true : false;
{% } %}
@@ -551,6 +555,7 @@ This value is used by default, but each tunnel may overide it.
}
{% } %}
htmx.find("#dialog-done").disabled = true;
+ updateTunnels();
}
htmx.on("#tunnel-templates button", "click", newTunnelEntry);
htmx.on("#tunnels", "change", updateTunnels);