luci-app-clouddrive2: add clouddrive2 luci package

This commit is contained in:
coolsnowwolf 2025-04-21 02:54:12 +08:00
parent 7b29d99c11
commit 0715d9a38b
8 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,20 @@
# Copyright (C) 2016 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for CloudDrive2
LUCI_DEPENDS:=+clouddrive2
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-clouddrive2
PKG_VERSION:=1
PKG_RELEASE:=7
include ../../luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,17 @@
module("luci.controller.clouddrive2", package.seeall)
function index()
if not nixio.fs.access("/etc/config/clouddrive2") then
return
end
entry({"admin", "nas"}, firstchild(), _("NAS"), 45).dependent = false
entry({"admin","nas","clouddrive2"},cbi("clouddrive2"),_("CloudDrive2"), 10).acl_depends = { "luci-app-clouddrive2" }
entry({"admin", "nas", "clouddrive2", "status"}, call("act_status")).leaf = true
end
function act_status()
local e={}
e.running=luci.sys.call("pgrep clouddrive >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -0,0 +1,21 @@
local m, s, o
m = Map("clouddrive2", translate("CloudDrive2"), translate("Configure and manage CloudDrive2"))
m:section(SimpleSection).template="clouddrive2/status"
s = m:section(TypedSection, "clouddrive2", translate("Settings"))
s.anonymous = true
s.addremove = false
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o = s:option(Value, "port", translate("Port"))
o.datatype = "port"
o.default = "19798"
--
-- o = s:option(Value, "mount_point", translate("Mount Point"))
-- o.default = "/mnt/clouddrive"
return m

View File

@ -0,0 +1,27 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[nas]], [[clouddrive2]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('clouddrive_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>CloudDrive2 <%:RUNNING%></font></b></em><input class="cbi-button mar-10" type="button" value="<%:Open Web Interface%>" onclick="openwebui();" />';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>CloudDrive2 <%:NOT RUNNING%></font></b></em>';
}
}
}
);
function openwebui(){
var url = window.location.host+":<%=luci.sys.exec("uci -q get clouddrive2.main.port"):gsub("^%s*(.-)%s*$", "%1")%>";
window.open('http://'+url,'target','');
};
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="clouddrive_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1 @@
zh_Hans

View File

@ -0,0 +1,32 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "Configure and manage CloudDrive2"
msgstr "配置和管理CloudDrive2"
msgid "Settings"
msgstr "设置"
msgid "Enable"
msgstr "启用"
msgid "Port"
msgstr "端口"
msgid "Mount Point"
msgstr "挂载点"
msgid "CloudDrive2 Status"
msgstr "CloudDrive2状态"
msgid "Running Status"
msgstr "运行状态"
msgid "Collecting data..."
msgstr "正在收集数据..."
msgid "CloudDrive2 is running"
msgstr "CloudDrive2 正在运行"
msgid "CloudDrive2 is not running"
msgstr "CloudDrive2 未运行"

View File

@ -0,0 +1,16 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@clouddrive2[-1]
add ucitrack clouddrive2
set ucitrack.@clouddrive2[-1].init=clouddrive2
commit ucitrack
EOF
mkdir -p /lib/upgrade/keep.d
cat > "/lib/upgrade/keep.d/luci-clouddrive2" <<-EOF
/Waytech/CloudDrive2/
EOF
rm -f /tmp/luci-indexcache
exit 0

View File

@ -0,0 +1,11 @@
{
"luci-app-clouddrive2": {
"description": "Grant UCI access for luci-app-clouddrive2",
"read": {
"uci": [ "clouddrive2" ]
},
"write": {
"uci": [ "clouddrive2" ]
}
}
}