Skip to content

Commit fd04718

Browse files
committed
use single section write instead of individual option writes
1 parent 9265452 commit fd04718

2 files changed

Lines changed: 58 additions & 57 deletions

File tree

htdocs/luci-static/resources/view/https-dns-proxy/overview.js

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -274,19 +274,6 @@ return view.extend({
274274
_paramList.value(val, descr);
275275
});
276276
_paramList.depends("_provider", prov.template);
277-
_paramList.write = function (section_id, formvalue) {
278-
let template = this.map.data.get(
279-
this.map.config,
280-
section_id,
281-
"resolver_url"
282-
);
283-
if (!formvalue && _paramList.template !== template) return 0;
284-
let resolver = pkg.templateToResolver(_paramList.template, {
285-
option: formvalue || "",
286-
});
287-
L.uci.set(pkg.Name, section_id, "resolver_url", resolver);
288-
};
289-
_paramList.remove = _paramList.write;
290277
} else if (prov.params.option.type === "text") {
291278
let optName = prov.params.option.description || _("Parameter");
292279
var _paramText = s.option(form.Value, "_paramText_" + i, optName);
@@ -307,19 +294,6 @@ return view.extend({
307294
let match = resolver.match(regexp);
308295
return (match && match[1]) || null;
309296
};
310-
_paramText.write = function (section_id, formvalue) {
311-
let template = this.map.data.get(
312-
this.map.config,
313-
section_id,
314-
"resolver_url"
315-
);
316-
if (!formvalue && _paramText.template !== template) return 0;
317-
let resolver = pkg.templateToResolver(_paramText.template, {
318-
option: formvalue || "",
319-
});
320-
L.uci.set(pkg.Name, section_id, "resolver_url", resolver);
321-
};
322-
_paramText.remove = _paramText.write;
323297
}
324298
}
325299
}
@@ -341,18 +315,6 @@ return view.extend({
341315
);
342316
return c_value || prov.bootstrap_dns || "";
343317
};
344-
_boot_dns.write = function (section_id, formvalue) {
345-
if (formvalue)
346-
L.uci.set(pkg.Name, section_id, "bootstrap_dns", formvalue);
347-
else
348-
L.uci.set(
349-
pkg.Name,
350-
section_id,
351-
"bootstrap_dns",
352-
this.cfgvalue(section_id)
353-
);
354-
_boot_dns.remove = _boot_dns.write;
355-
};
356318
}
357319

358320
reply.providers.forEach((prov, i) => {
@@ -363,6 +325,45 @@ return view.extend({
363325
createBootstrapWidget(s, i, prov);
364326
});
365327

328+
s.write = function (section_id, formvalues) {
329+
let providerTemplate = formvalues["_provider"];
330+
let resolverUrl = providerTemplate;
331+
let bootstrapDns = "";
332+
333+
reply.providers.forEach((prov, i) => {
334+
if (prov.template === providerTemplate) {
335+
let paramValue = "";
336+
if (prov.params && prov.params.option) {
337+
if (prov.params.option.type === "select") {
338+
paramValue = formvalues["_paramList_" + i] || "";
339+
} else if (prov.params.option.type === "text") {
340+
paramValue = formvalues["_paramText_" + i] || "";
341+
}
342+
}
343+
344+
resolverUrl = pkg.templateToResolver(providerTemplate, {
345+
option: paramValue
346+
});
347+
348+
bootstrapDns = formvalues["_bootstrap_dns_" + i];
349+
350+
// Fallback to default if empty
351+
if (!bootstrapDns) {
352+
bootstrapDns = prov.bootstrap_dns || "";
353+
}
354+
}
355+
});
356+
357+
if (resolverUrl) {
358+
L.uci.set(pkg.Name, section_id, "resolver_url", resolverUrl);
359+
}
360+
361+
if (bootstrapDns) {
362+
L.uci.set(pkg.Name, section_id, "bootstrap_dns", bootstrapDns);
363+
}
364+
};
365+
366+
366367
o = s.option(form.Value, "listen_addr", _("Listen Address"));
367368
o.datatype = "ipaddr('nomask')";
368369
o.default = "";

po/templates/https-dns-proxy.pot

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ msgid ""
8686
"use router for DNS resolution (%smore information%s)."
8787
msgstr ""
8888

89-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:335
89+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:305
9090
msgid "Bootstrap DNS"
9191
msgstr ""
9292

@@ -146,7 +146,7 @@ msgstr ""
146146
msgid "DNSlify DNS"
147147
msgstr ""
148148

149-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:399
149+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:389
150150
msgid "DSCP Codepoint"
151151
msgstr ""
152152

@@ -238,11 +238,11 @@ msgstr ""
238238
msgid "Force Router DNS server to all local devices"
239239
msgstr ""
240240

241-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:437
241+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:427
242242
msgid "Force use of HTTP/1"
243243
msgstr ""
244244

245-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:449
245+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:439
246246
msgid "Force use of IPv6 DNS resolvers"
247247
msgstr ""
248248

@@ -335,12 +335,12 @@ msgstr ""
335335
msgid "LibreDNS (GR)"
336336
msgstr ""
337337

338-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:377
338+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:367
339339
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/status/include/71_https-dns-proxy.js:56
340340
msgid "Listen Address"
341341
msgstr ""
342342

343-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:383
343+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:373
344344
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/status/include/71_https-dns-proxy.js:57
345345
msgid "Listen Port"
346346
msgstr ""
@@ -350,11 +350,11 @@ msgstr ""
350350
msgid "Location"
351351
msgstr ""
352352

353-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:416
353+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:406
354354
msgid "Logging File Path"
355355
msgstr ""
356356

357-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:410
357+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:400
358358
msgid "Logging Verbosity"
359359
msgstr ""
360360

@@ -406,8 +406,8 @@ msgstr ""
406406
msgid "OpenNameServer"
407407
msgstr ""
408408

409-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:267
410-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:299
409+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:264
410+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:278
411411
msgid "Parameter"
412412
msgstr ""
413413

@@ -425,7 +425,7 @@ msgstr ""
425425
msgid "Poland"
426426
msgstr ""
427427

428-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:421
428+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:411
429429
msgid "Polling Interval"
430430
msgstr ""
431431

@@ -457,7 +457,7 @@ msgstr ""
457457
msgid "Provider"
458458
msgstr ""
459459

460-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:427
460+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:417
461461
msgid "Proxy Server"
462462
msgstr ""
463463

@@ -489,11 +489,11 @@ msgstr ""
489489
msgid "RubyFish (CN)"
490490
msgstr ""
491491

492-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:394
492+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:384
493493
msgid "Run As Group"
494494
msgstr ""
495495

496-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:389
496+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:379
497497
msgid "Run As User"
498498
msgstr ""
499499

@@ -542,7 +542,7 @@ msgstr ""
542542
msgid "Snopyta DNS (FI)"
543543
msgstr ""
544544

545-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:405
545+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:395
546546
msgid "Source Address"
547547
msgstr ""
548548

@@ -629,19 +629,19 @@ msgstr ""
629629
msgid "Update select configs"
630630
msgstr ""
631631

632-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:432
632+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:422
633633
msgid "Use HTTP/1"
634634
msgstr ""
635635

636-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:443
636+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:433
637637
msgid "Use IPv6 resolvers"
638638
msgstr ""
639639

640-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:448
640+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:438
641641
msgid "Use any family DNS resolvers"
642642
msgstr ""
643643

644-
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:436
644+
#: applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js:426
645645
msgid "Use negotiated HTTP version"
646646
msgstr ""
647647

0 commit comments

Comments
 (0)