diff --git a/luci-app-filebrowser/Makefile b/luci-app-filebrowser/Makefile index b25acc24..0b20e6ae 100644 --- a/luci-app-filebrowser/Makefile +++ b/luci-app-filebrowser/Makefile @@ -1,12 +1,14 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# Copyright (C) 2023 ImmortalWrt.org +# This is free software, licensed under the Apache License, Version 2.0 . include $(TOPDIR)/rules.mk -LUCI_TITLE:=LuCI app for FileBrowser -LUCI_PKGARCH:=all -LUCI_DEPENDS:=+filebrowser +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 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js b/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js deleted file mode 100644 index b91e6c58..00000000 --- a/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; -'require form'; -'require poll'; -'require rpc'; -'require uci'; -'require view'; - -var callServiceList = rpc.declare({ - object: 'service', - method: 'list', - params: ['name'], - expect: { '': {} } -}); - -function getServiceStatus() { - return L.resolveDefault(callServiceList('filebrowser'), {}).then(function (res) { - var isRunning = false; - try { - isRunning = res['filebrowser']['instances']['instance1']['running']; - } catch (e) { } - return isRunning; - }); -} - -function renderStatus(isRunning, port) { - var spanTemp = '%s %s'; - var renderHTML; - if (isRunning) { - var button = String.format(' %s', - window.location.hostname, port, _('Open Web Interface')); - renderHTML = spanTemp.format('green', _('FileBrowser'), _('RUNNING')) + button; - } else { - renderHTML = spanTemp.format('red', _('FileBrowser'), _('NOT RUNNING')); - } - - return renderHTML; -} - -return view.extend({ - load: function() { - return uci.load('filebrowser'); - }, - - render: function(data) { - var m, s, o; - var webport = (uci.get(data, 'config', 'listen_port') || '8989'); - - m = new form.Map('filebrowser', _('FileBrowser'), - _('FileBrowser provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files..')); - - s = m.section(form.TypedSection); - s.anonymous = true; - s.render = function () { - poll.add(function () { - return L.resolveDefault(getServiceStatus()).then(function (res) { - var view = document.getElementById('service_status'); - view.innerHTML = renderStatus(res, webport); - }); - }); - - return E('div', { class: 'cbi-section', id: 'status_bar' }, [ - E('p', { id: 'service_status' }, _('Collecting data...')) - ]); - } - - s = m.section(form.NamedSection, 'config', 'filebrowser'); - - o = s.option(form.Flag, 'enabled', _('Enable')); - o.default = o.disabled; - o.rmempty = false; - - o = s.option(form.Value, 'listen_port', _('Listen port')); - o.datatype = 'port'; - o.default = '8989'; - o.rmempty = false; - - o = s.option(form.Value, 'root_path', _('Root directory')); - o.default = '/mnt'; - o.rmempty = false; - - o = s.option(form.Flag, 'disable_exec', _('Disable Command Runner feature')); - o.default = o.enabled; - o.rmempty = false; - - return m.render(); - } -}); diff --git a/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js b/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js new file mode 100644 index 00000000..33fe2614 --- /dev/null +++ b/luci-app-filebrowser/htdocs/luci-static/resources/view/system/filebrowser.js @@ -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/luci-app-filebrowser/po/templates/filebrowser.pot b/luci-app-filebrowser/po/templates/filebrowser.pot index dcec5fba..9970b2c8 100644 --- a/luci-app-filebrowser/po/templates/filebrowser.pot +++ b/luci-app-filebrowser/po/templates/filebrowser.pot @@ -1,51 +1,11 @@ msgid "" msgstr "Content-Type: text/plain; charset=UTF-8" -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:62 -msgid "Collecting data..." -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:81 -msgid "Disable Command Runner feature" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:68 -msgid "Enable" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31 -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33 -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:48 +#: 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 "FileBrowser" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:49 -msgid "" -"FileBrowser provides a file managing interface within a specified directory " -"and it can be used to upload, delete, preview, rename and edit your files.." +msgid "File Browser" msgstr "" #: applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json:3 -msgid "Grant UCI access for luci-app-filebrowser" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:72 -msgid "Listen port" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33 -msgid "NOT RUNNING" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:30 -msgid "Open Web Interface" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31 -msgid "RUNNING" -msgstr "" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:77 -msgid "Root directory" +msgid "Grant access to File Browser" msgstr "" diff --git a/luci-app-filebrowser/po/zh-cn b/luci-app-filebrowser/po/zh-cn deleted file mode 120000 index 8d69574d..00000000 --- a/luci-app-filebrowser/po/zh-cn +++ /dev/null @@ -1 +0,0 @@ -zh_Hans \ No newline at end of file diff --git a/luci-app-filebrowser/po/zh_Hans/filebrowser.po b/luci-app-filebrowser/po/zh_Hans/filebrowser.po deleted file mode 100644 index b1b763df..00000000 --- a/luci-app-filebrowser/po/zh_Hans/filebrowser.po +++ /dev/null @@ -1,60 +0,0 @@ -msgid "" -msgstr "" -"Content-Type: text/plain; charset=UTF-8\n" -"Project-Id-Version: PACKAGE VERSION\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" -"Language: zh-Hans\n" -"MIME-Version: 1.0\n" -"Content-Transfer-Encoding: 8bit\n" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:62 -msgid "Collecting data..." -msgstr "收集数据中..." - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:81 -msgid "Disable Command Runner feature" -msgstr "禁用命令执行功能" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:68 -msgid "Enable" -msgstr "启用" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31 -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33 -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:48 -#: applications/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json:3 -msgid "FileBrowser" -msgstr "FileBrowser" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:49 -msgid "" -"FileBrowser provides a file managing interface within a specified directory " -"and it can be used to upload, delete, preview, rename and edit your files.." -msgstr "" -"FileBrowser 提供指定目录下的文件管理界面,可用于上传、删除、预览、重命名和编" -"辑文件。" - -#: applications/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json:3 -msgid "Grant UCI access for luci-app-filebrowser" -msgstr "授予 luci-app-filebrowser 访问 UCI 配置的权限" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:72 -msgid "Listen port" -msgstr "监听端口" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:33 -msgid "NOT RUNNING" -msgstr "未运行" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:30 -msgid "Open Web Interface" -msgstr "打开 Web 界面" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:31 -msgid "RUNNING" -msgstr "运行中" - -#: applications/luci-app-filebrowser/htdocs/luci-static/resources/view/filebrowser.js:77 -msgid "Root directory" -msgstr "根目录" diff --git a/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json b/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json index 9bd0e410..50670695 100644 --- a/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json +++ b/luci-app-filebrowser/root/usr/share/luci/menu.d/luci-app-filebrowser.json @@ -1,14 +1,13 @@ { - "admin/services/filebrowser": { - "title": "FileBrowser", + "admin/system/filebrowser": { + "title": "File Browser", + "order": 80, "action": { - "order": 30, "type": "view", - "path": "filebrowser" + "path": "system/filebrowser" }, "depends": { - "acl": [ "luci-app-filebrowser" ], - "uci": { "filebrowser": true } + "acl": [ "luci-app-filebrowser" ] } } } diff --git a/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json b/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json index cc5b6b0b..858a8dd7 100644 --- a/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json +++ b/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json @@ -1,14 +1,14 @@ { "luci-app-filebrowser": { - "description": "Grant UCI access for luci-app-filebrowser", - "read": { - "ubus": { - "service": [ "list" ] - }, - "uci": [ "filebrowser" ] - }, + "description": "Grant access to File Browser", "write": { - "uci": [ "filebrowser" ] + "cgi-io": [ "upload", "download" ], + "ubus": { + "file": [ "*" ] + }, + "file": { + "/*": [ "list", "read", "write" ] + } } } }