luci-app-snmpd: code fixes

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald
2026-05-25 23:43:40 +03:00
parent a818ac89bb
commit 395a7a8b96
2 changed files with 10 additions and 8 deletions
@@ -21,9 +21,9 @@ return L.view.extend({
const a = document.createElement('a'); const a = document.createElement('a');
document.body.appendChild(a); document.body.appendChild(a);
a.display = 'none'; a.style.display = 'none';
return mibDownload(base + fileName, false).then(function(res) { return mibDownload(base + fileName).then(function(res) {
const data = res; const data = res;
const file = new Blob( [data] , { type: 'text/plain'}); const file = new Blob( [data] , { type: 'text/plain'});
const fileUrl = window.URL.createObjectURL(file); const fileUrl = window.URL.createObjectURL(file);
@@ -31,6 +31,7 @@ return L.view.extend({
a.href = fileUrl; a.href = fileUrl;
a.download = fileName; a.download = fileName;
a.click(); a.click();
window.URL.revokeObjectURL(fileUrl);
document.body.removeChild(a); document.body.removeChild(a);
}); });
}, },
@@ -103,6 +103,7 @@ return L.view.extend({
return port; return port;
const s = uci.get_first('snmpd', 'agent'); const s = uci.get_first('snmpd', 'agent');
if (!s) return null;
const rawAddr = uci.get('snmpd', s['.name'], 'agentaddress'); const rawAddr = uci.get('snmpd', s['.name'], 'agentaddress');
if (!rawAddr) if (!rawAddr)
return null; return null;
@@ -162,13 +163,13 @@ return L.view.extend({
go.remove = function(section_id) { go.remove = function(section_id) {
const s = uci.get_first('snmpd', 'agentx'); const s = uci.get_first('snmpd', 'agentx');
if (s) if (s)
s.remove('snmpd', s['.name']); uci.remove('snmpd', s['.name']);
}; };
go.write = function(section_id, value) { go.write = function(section_id, value) {
const s = uci.get_first('snmpd', 'agentx'); const s = uci.get_first('snmpd', 'agentx');
var sid = s ? s['.name'] : uci.add('snmpd', 'agentx'); var sid = s ? s['.name'] : uci.add('snmpd', 'agentx');
uci.set('snmpd', sid, 'agentxsocket', value); return uci.set('snmpd', sid, 'agentxsocket', value);
}; };
}, },
@@ -363,10 +364,10 @@ return L.view.extend({
g.nodescriptions = true; g.nodescriptions = true;
g.modaltitle = desc; g.modaltitle = desc;
go = g.option(form.ListValue, 'Mode', _('Access Control'), mode = g.option(form.ListValue, 'Mode', _('Access Control'),
_('Access restriction to readonly or Read/Write')); _('Access restriction to readonly or Read/Write'));
go.value('rwcommunity', _('Read/Write')); mode.value('rwcommunity', _('Read/Write'));
go.value('rocommunity', _('Readonly')); mode.value('rocommunity', _('Readonly'));
community = g.option(form.Value, 'CommunityName', community = g.option(form.Value, 'CommunityName',
_('Community Name'), _('Community Name'),
@@ -420,7 +421,7 @@ return L.view.extend({
this.oid.datatype = 'string'; this.oid.datatype = 'string';
this.oid.depends('RestrictOID', 'yes'); this.oid.depends('RestrictOID', 'yes');
if (go === 'rocommunity') { if (uci.get('snmpd', subsection, 'Mode') === 'rocommunity') {
this.ro_community = community; this.ro_community = community;
this.ro_community_src = community_src; this.ro_community_src = community_src;
} else { } else {