From f2ed6f0d4c5d883eddec5f6c1dc9f42239ae9458 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Thu, 21 Sep 2023 09:48:32 +0300 Subject: [PATCH] luci-mod-system: File Browser Add a File Browser based on the FileUpload CBI element. It allows to browse files and directories on a router, delete and upload. This already covers a basic needs. Signed-off-by: Sergey Ponomarev --- .../resources/view/system/filebrowser.js | 26 +++++++++++++++++++ .../share/luci/menu.d/luci-mod-system.json | 13 ++++++++++ .../usr/share/rpcd/acl.d/luci-mod-system.json | 16 ++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 modules/luci-mod-system/htdocs/luci-static/resources/view/system/filebrowser.js diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/filebrowser.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/filebrowser.js new file mode 100644 index 000000000000..64b66de7ebbc --- /dev/null +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/filebrowser.js @@ -0,0 +1,26 @@ +'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; + + return m.render(); + } +}) diff --git a/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json b/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json index ebae989d0e00..a3248f5ec803 100644 --- a/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json +++ b/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json @@ -136,6 +136,19 @@ } }, + + "admin/system/filebrowser": { + "title": "File Browser", + "order": 80, + "action": { + "type": "view", + "path": "system/filebrowser" + }, + "depends": { + "acl": [ "luci-mod-system-filebrowser" ] + } + }, + "admin/system/reboot": { "title": "Reboot", "order": 90, diff --git a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json index 732a73a760c6..2d4f2fbeca0f 100644 --- a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json +++ b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json @@ -175,6 +175,22 @@ } }, + "luci-mod-system-filebrowser": { + "description": "Grant access to File Browser", + "read": { + "cgi-io": [ "*" ], + "ubus": { + "file": [ "*" ] + } + }, + "write": { + "cgi-io": [ "upload" ], + "ubus": { + "file": [ "*" ] + } + } + }, + "luci-mod-system-reboot": { "description": "Allow rebooting the device", "write": {