luci-app-vnstat2: fix ACL rules, disable button on insufficient ACLs 3962/head
authorJan Hoffmann <jan@3e8.eu>
Fri, 24 Apr 2020 16:43:03 +0000 (18:43 +0200)
committerJan Hoffmann <jan@3e8.eu>
Fri, 24 Apr 2020 16:43:03 +0000 (18:43 +0200)
Signed-off-by: Jan Hoffmann <jan@3e8.eu>
applications/luci-app-vnstat2/htdocs/luci-static/resources/view/vnstat2/config.js
applications/luci-app-vnstat2/root/usr/share/rpcd/acl.d/luci-app-vnstat2.json

index 14e968a0719b8980deabab9a91fd8221b4bc2d1d..46781442a3a7a5d691d811fdd04c26b18da4c7eb 100644 (file)
@@ -8,6 +8,8 @@
 'require form';
 'require tools.widgets as widgets';
 
+var isReadonlyView = !L.hasViewPermission() || null;
+
 return view.extend({
        handleDeleteModal: function(m, iface, ev) {
                L.showModal(_('Delete interface <em>%h</em>').format(iface), [
@@ -88,7 +90,8 @@ return view.extend({
                                        this.interfaces[i],
                                        E('button', {
                                                'class': 'btn cbi-button-remove',
-                                               'click': ui.createHandlerFn(view, 'handleDeleteModal', m, this.interfaces[i])
+                                               'click': ui.createHandlerFn(view, 'handleDeleteModal', m, this.interfaces[i]),
+                                               'disabled': isReadonlyView
                                        }, [ _('Deleteā€¦') ])
                                ]);
                        }
index fb16f09c9aab3bb9213dd2e9960ad520be8709b3..7acf74bd59efa79a8b62c93ae5d906965dc72038 100644 (file)
@@ -6,7 +6,8 @@
                        "file": {
                                "/usr/bin/vnstat --json f 1": [ "exec" ],
                                "/usr/bin/vnstati -[5dhmsty] -i * -o -": [ "exec" ]
-                       }
+                       },
+                       "uci": [ "vnstat" ]
                },
                "write": {
                        "file": {