Skip to content

Commit ae50432

Browse files
committed
bugfix: edit providers, solve js console warnings/errors
1 parent b0588c4 commit ae50432

3 files changed

Lines changed: 114 additions & 98 deletions

File tree

htdocs/luci-static/resources/https-dns-proxy/status.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var status = baseclass.extend({
185185

186186
var header = E("h2", {}, _("HTTPS DNS Proxy - Status"));
187187
var statusTitle = E(
188-
"label",
188+
"div",
189189
{ class: "cbi-value-title" },
190190
_("Service Status")
191191
);
@@ -221,7 +221,7 @@ var status = baseclass.extend({
221221
var instancesDiv = [];
222222
if (reply.ubus.instances && Object.keys(reply.ubus.instances).length > 0) {
223223
var instancesTitle = E(
224-
"label",
224+
"div",
225225
{ class: "cbi-value-title" },
226226
_("Service Instances")
227227
);
@@ -428,7 +428,7 @@ var status = baseclass.extend({
428428
}
429429

430430
var buttonsTitle = E(
431-
"label",
431+
"div",
432432
{ class: "cbi-value-title" },
433433
_("Service Control")
434434
);

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

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ return view.extend({
118118
});
119119
o.depends("dnsmasq_config_update_option", "+");
120120
o.retain = true;
121+
o.renderFrame = function (section_id, in_table, option_index, nodes) {
122+
var frame = form.Value.prototype.renderFrame.apply(this, arguments);
123+
if (frame && frame.querySelector) {
124+
var label = frame.querySelector("label.cbi-value-title");
125+
if (label) {
126+
var div = E("div", { class: label.className });
127+
while (label.firstChild) div.appendChild(label.firstChild);
128+
label.parentNode.replaceChild(div, label);
129+
}
130+
}
131+
return frame;
132+
};
121133
}
122134

123135
o = s.taboption(
@@ -383,6 +395,7 @@ return view.extend({
383395
var _provider;
384396
_provider = s.option(form.ListValue, "_provider", _("Provider"));
385397
_provider.modalonly = true;
398+
_provider.forcewrite = true;
386399
_provider.cfgvalue = function (section_id) {
387400
let resolver = this.map.data.get(
388401
this.map.config,
@@ -459,15 +472,6 @@ return view.extend({
459472
L.uci.unset(pkg.Name, section_id, "resolver_url");
460473
L.uci.unset(pkg.Name, section_id, "bootstrap_dns");
461474
};
462-
_provider.save = function (section_id) {
463-
if (this.isActive(section_id)) {
464-
var fval = this.formvalue(section_id);
465-
if (fval != null && fval !== '') {
466-
return this.write(section_id, fval);
467-
}
468-
}
469-
return this.remove(section_id);
470-
};
471475

472476
function createProviderWidget(s, i, prov) {
473477
if (
@@ -489,6 +493,18 @@ return view.extend({
489493
_paramList.value(val, descr);
490494
});
491495
_paramList.depends("_provider", prov.template);
496+
_paramList.cfgvalue = function (section_id) {
497+
let resolver = this.map.data.get(
498+
this.map.config,
499+
section_id,
500+
"resolver_url"
501+
);
502+
if (resolver === undefined || resolver === null)
503+
return prov.params.option.default || null;
504+
let regexp = pkg.templateToRegexp(prov.template);
505+
let match = resolver.match(regexp);
506+
return (match && match[1]) || prov.params.option.default || null;
507+
};
492508
_paramList.write = function (section_id, formvalue) { };
493509
_paramList.remove = function (section_id, formvalue) { };
494510
} else if (prov.params.option.type === "text") {

0 commit comments

Comments
 (0)