From cfbbf2d6591efa13d8871386396860aa3a309eae Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 4 Mar 2023 12:22:20 +0800 Subject: [PATCH] update 2023-03-04 12:22:20 --- luci-app-filebrowser/Makefile | 22 ++++++++++ .../luasrc/controller/filebrowser.lua | 22 ++++++++++ .../luasrc/model/cbi/filebrowser.lua | 43 +++++++++++++++++++ .../view/filebrowser/filebrowser_status.htm | 27 ++++++++++++ .../root/etc/uci-defaults/luci-filebrowser | 11 +++++ .../rpcd/acl.d/luci-app-filebrowser.json | 11 +++++ 6 files changed, 136 insertions(+) create mode 100644 luci-app-filebrowser/Makefile create mode 100644 luci-app-filebrowser/luasrc/controller/filebrowser.lua create mode 100644 luci-app-filebrowser/luasrc/model/cbi/filebrowser.lua create mode 100644 luci-app-filebrowser/luasrc/view/filebrowser/filebrowser_status.htm create mode 100755 luci-app-filebrowser/root/etc/uci-defaults/luci-filebrowser create mode 100644 luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json diff --git a/luci-app-filebrowser/Makefile b/luci-app-filebrowser/Makefile new file mode 100644 index 000000000..3abe46bba --- /dev/null +++ b/luci-app-filebrowser/Makefile @@ -0,0 +1,22 @@ +# +# Copyright (C) 2021 ImmortalWrt +# +# +# This is free software, licensed under the GNU General Public License v3. +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI Support for FileBrowser +LUCI_DEPENDS:=+filebrowser +LUCI_PKGARCH:=all + +PKG_NAME:=luci-app-filebrowser +PKG_VERSION:=snapshot +PKG_RELEASE:=118071b + +PKG_LICENSE:=GPLv3 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-filebrowser/luasrc/controller/filebrowser.lua b/luci-app-filebrowser/luasrc/controller/filebrowser.lua new file mode 100644 index 000000000..061f542ae --- /dev/null +++ b/luci-app-filebrowser/luasrc/controller/filebrowser.lua @@ -0,0 +1,22 @@ +module("luci.controller.filebrowser", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/filebrowser") then + return + end + + entry({"admin", "nas"}, firstchild(), _("NAS"), 45).dependent = false + + local page = entry({"admin", "nas", "filebrowser"}, cbi("filebrowser"), _("文件管理器"), 100) + page.dependent = true + page.acl_depends = { "luci-app-filebrowser" } + + entry({"admin", "nas", "filebrowser", "status"}, call("act_status")).leaf = true +end + +function act_status() + local e = {} + e.running = luci.sys.call("pgrep filebrowser >/dev/null") == 0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/luci-app-filebrowser/luasrc/model/cbi/filebrowser.lua b/luci-app-filebrowser/luasrc/model/cbi/filebrowser.lua new file mode 100644 index 000000000..a1ea4f3f2 --- /dev/null +++ b/luci-app-filebrowser/luasrc/model/cbi/filebrowser.lua @@ -0,0 +1,43 @@ +m = Map("filebrowser", translate("文件管理器")) +m.description = translate("FileBrowser是一个基于Go的在线文件管理器,助您方便的管理设备上的文件。") + +m:section(SimpleSection).template = "filebrowser/filebrowser_status" + +s = m:section(TypedSection, "filebrowser") +s.addremove = false +s.anonymous = true + +o = s:option(Flag, "enabled", translate("启用")) +o.rmempty = false + +o = s:option(ListValue, "addr_type", translate("监听地址")) +o:value("local", translate("监听本机地址")) +o:value("lan", translate("监听局域网地址")) +o:value("wan", translate("监听全部地址")) +o.default = "lan" +o.rmempty = false + +o = s:option(Value, "port", translate("监听端口")) +o.placeholder = 8989 +o.default = 8989 +o.datatype = "port" +o.rmempty = false + +o = s:option(Value, "root_dir", translate("开放目录")) +o.placeholder = "/" +o.default = "/" +o.rmempty = false + +o = s:option(Value, "db_dir", translate("数据库目录")) +o.description = translate("普通用户请勿随意更改") +o.placeholder = "/etc" +o.default = "/etc" +o.rmempty = false + +o = s:option(Value, "db_name", translate("数据库名")) +o.description = translate("普通用户请勿随意更改") +o.placeholder = "filebrowser.db" +o.default = "filebrowser.db" +o.rmempty = false + +return m diff --git a/luci-app-filebrowser/luasrc/view/filebrowser/filebrowser_status.htm b/luci-app-filebrowser/luasrc/view/filebrowser/filebrowser_status.htm new file mode 100644 index 000000000..9da250f53 --- /dev/null +++ b/luci-app-filebrowser/luasrc/view/filebrowser/filebrowser_status.htm @@ -0,0 +1,27 @@ + + +
+

+ <%:Collecting data...%> +

+
diff --git a/luci-app-filebrowser/root/etc/uci-defaults/luci-filebrowser b/luci-app-filebrowser/root/etc/uci-defaults/luci-filebrowser new file mode 100755 index 000000000..df11e7222 --- /dev/null +++ b/luci-app-filebrowser/root/etc/uci-defaults/luci-filebrowser @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@filebrowser[-1] + add ucitrack filebrowser + set ucitrack.@filebrowser[-1].init=filebrowser + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0 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 new file mode 100644 index 000000000..e01bde3d4 --- /dev/null +++ b/luci-app-filebrowser/root/usr/share/rpcd/acl.d/luci-app-filebrowser.json @@ -0,0 +1,11 @@ +{ + "luci-app-filebrowser": { + "description": "Grant UCI access for luci-app-filebrowser", + "read": { + "uci": [ "filebrowser" ] + }, + "write": { + "uci": [ "filebrowser" ] + } + } +}