luci-app-filebrowser: File Browser 6553/head
authorSergey Ponomarev <stokito@gmail.com>
Tue, 9 Apr 2024 07:37:05 +0000 (10:37 +0300)
committerSergey Ponomarev <stokito@gmail.com>
Tue, 9 Apr 2024 08:02:00 +0000 (11:02 +0300)
Add a File Browser based on the FileUpload CBI element.
It allows browsing files and directories on a router, delete and upload.
This covers only basic needs.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
applications/luci-app-filebrowser/Makefile [new file with mode: 0644]
applications/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js [new file with mode: 0644]
applications/luci-app-filebrowser/po/templates/filebrowser.pot [new file with mode: 0644]
applications/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json [new file with mode: 0644]
applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json [new file with mode: 0644]

diff --git a/applications/luci-app-filebrowser/Makefile b/applications/luci-app-filebrowser/Makefile
new file mode 100644 (file)
index 0000000..28b3802
--- /dev/null
@@ -0,0 +1,15 @@
+# This is free software, licensed under the Apache License, Version 2.0 .
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=LuCI File Browser module
+LUCI_DEPENDS:=+luci-base
+
+PKG_LICENSE:=Apache-2.0
+PKG_VERSION:=1.1.0
+PKG_RELEASE:=1
+PKG_MAINTAINER:=Sergey Ponomarev <stokito@gmail.com>
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
diff --git a/applications/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js b/applications/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js
new file mode 100644 (file)
index 0000000..33fe261
--- /dev/null
@@ -0,0 +1,34 @@
+'use strict';
+'require view';
+'require ui';
+'require form';
+
+var formData = {
+       files: {
+               root: null,
+       }
+};
+
+return view.extend({
+       render: function() {
+               var m, s, o;
+
+               m = new form.JSONMap(formData, _('File Browser'), '');
+
+               s = m.section(form.NamedSection, 'files', 'files');
+
+               o = s.option(form.FileUpload, 'root', '');
+               o.root_directory = '/';
+               o.browser = true;
+               o.show_hidden = true;
+               o.enable_upload = true;
+               o.enable_remove = true;
+               o.enable_download = true;
+
+               return m.render();
+       },
+
+       handleSave: null,
+       handleSaveApply: null,
+       handleReset: null
+})
diff --git a/applications/luci-app-filebrowser/po/templates/filebrowser.pot b/applications/luci-app-filebrowser/po/templates/filebrowser.pot
new file mode 100644 (file)
index 0000000..9970b2c
--- /dev/null
@@ -0,0 +1,11 @@
+msgid ""
+msgstr "Content-Type: text/plain; charset=UTF-8"
+
+#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js:16
+#: applications/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json:3
+msgid "File Browser"
+msgstr ""
+
+#: applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json:3
+msgid "Grant access to File Browser"
+msgstr ""
diff --git a/applications/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json b/applications/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json
new file mode 100644 (file)
index 0000000..5067069
--- /dev/null
@@ -0,0 +1,13 @@
+{
+       "admin/system/filebrowser": {
+               "title": "File Browser",
+               "order": 80,
+               "action": {
+                       "type": "view",
+                       "path": "system/filebrowser"
+               },
+               "depends": {
+                       "acl": [ "luci-app-filebrowser" ]
+               }
+       }
+}
diff --git a/applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json b/applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json
new file mode 100644 (file)
index 0000000..858a8dd
--- /dev/null
@@ -0,0 +1,14 @@
+{
+       "luci-app-filebrowser": {
+               "description": "Grant access to File Browser",
+               "write": {
+                       "cgi-io": [ "upload", "download" ],
+                       "ubus": {
+                               "file": [ "*" ]
+                       },
+                       "file": {
+                               "/*": [  "list", "read", "write" ]
+                       }
+               }
+       }
+}