luci-app-snmpd: code fixes
authorPaul Donald <redacted>
Mon, 25 May 2026 20:43:40 +0000 (23:43 +0300)
committerPaul Donald <redacted>
Wed, 27 May 2026 12:49:45 +0000 (15:49 +0300)
Signed-off-by: Paul Donald <redacted>
applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/download.js
applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js

index 479301a3e8904af49373ddf4db0cfb04648e843f..d7b60778beaf6fc462438dad061e36fc8a4d6e5c 100644 (file)
@@ -21,9 +21,9 @@ return L.view.extend({
                const a = document.createElement('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 file = new Blob( [data] , { type: 'text/plain'});
                        const fileUrl = window.URL.createObjectURL(file);
@@ -31,6 +31,7 @@ return L.view.extend({
                        a.href = fileUrl;
                        a.download = fileName;
                        a.click();
+                       window.URL.revokeObjectURL(fileUrl);
                        document.body.removeChild(a);
                });
        },
index e681414a333657d890c9838e1e634c75dfa0c680..61adfd6fe814bfd4b277978534190802e111c496 100644 (file)
@@ -103,6 +103,7 @@ return L.view.extend({
                                return port;
 
                        const s = uci.get_first('snmpd', 'agent');
+                       if (!s) return null;
                        const rawAddr = uci.get('snmpd', s['.name'], 'agentaddress');
                        if (!rawAddr)
                                return null;
@@ -162,13 +163,13 @@ return L.view.extend({
                go.remove = function(section_id) {
                        const s = uci.get_first('snmpd', 'agentx');
                        if (s)
-                               s.remove('snmpd', s['.name']);
+                               uci.remove('snmpd', s['.name']);
                };
 
                go.write = function(section_id, value) {
                        const s = uci.get_first('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.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'));
-               go.value('rwcommunity', _('Read/Write'));
-               go.value('rocommunity', _('Readonly'));
+               mode.value('rwcommunity', _('Read/Write'));
+               mode.value('rocommunity', _('Readonly'));
 
                community = g.option(form.Value, 'CommunityName',
                        _('Community Name'),
@@ -420,7 +421,7 @@ return L.view.extend({
                this.oid.datatype = 'string';
                this.oid.depends('RestrictOID', 'yes');
 
-               if (go === 'rocommunity') {
+               if (uci.get('snmpd', subsection, 'Mode') === 'rocommunity') {
                        this.ro_community = community;
                        this.ro_community_src = community_src;
                } else {
git clone https://git.99rst.org/PROJECT