LuCI support for alist

This commit is contained in:
sbwml 2022-01-23 01:04:29 +08:00
parent 099906f993
commit 30a4c8d40b
6 changed files with 133 additions and 0 deletions

17
luci-app-alist/Makefile Normal file
View File

@ -0,0 +1,17 @@
# 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 alist
LUCI_DEPENDS:=+alist
LUCI_PKGARCH:=all
PKG_VERSION:=1.0.2
PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,25 @@
module("luci.controller.alist", package.seeall)
function index()
if not nixio.fs.access("/etc/config/alist") then
return
end
entry({"admin", "nas", "alist"}, cbi("alist"), _("Alist"), 20).dependent = true
entry({"admin", "nas", "alist_status"}, call("alist_status"))
end
function alist_status()
local sys = require "luci.sys"
local uci = require "luci.model.uci".cursor()
local port = tonumber(uci:get_first("alist", "alist", "port"))
local status = {
running = (sys.call("pidof alist >/dev/null") == 0),
port = (port or 5244)
}
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@ -0,0 +1,21 @@
local m, s
m = Map("alist", translate("Alist"), translate("Alist is an file list program that supports multiple storage. Default password: alist"))
m:section(SimpleSection).template = "alist_status"
s=m:section(TypedSection, "alist", translate("Global settings"))
s.addremove=false
s.anonymous=true
s:option(Flag, "enabled", translate("Enable")).rmempty=false
s:option(Value, "port", translate("Port")).rmempty=false
s=m:section(TypedSection, "alist", translate("Cache settings"))
s.addremove=false
s.anonymous=true
s:option(Value, "expiration", translate("Cache invalidation time (unit: minutes)")).rmempty=false
s:option(Value, "cleanup_interval", translate("Clear the invalidation cache interval")).rmempty=false
return m

View File

@ -0,0 +1,27 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/nas/alist_status")%>', null,
function(x, st)
{
var tb = document.getElementById('alist_status');
if (st && tb)
{
if (st.running)
{
tb.innerHTML = '<em style=\"color:green\"><b><%:The Alist service is running.%></b></em>'
+ "<br/><br/><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:Click to open Alist%> \" onclick=\"window.open('http://" + window.location.hostname + ":" + st.port + "/')\"/>";
}
else
{
tb.innerHTML = '<em style=\"color:red\"><b><%:The Alist service is not running.%></b></em>';
}
}
}
);
//]]></script>
<fieldset class="cbi-section">
<legend><%:Alist Status%></legend>
<p id="alist_status">
<em><b><%:Collecting data...%></b></em>
</p>
</fieldset>

View File

@ -0,0 +1,39 @@
msgid "Alist"
msgstr "Alist 文件列表"
msgid "Running state"
msgstr "运行状态"
msgid "Click to open Alist"
msgstr "点击打开 Alist"
msgid "Alist is an file list program that supports multiple storage. Default password: alist"
msgstr "Alist 是一个支持多存储的文件列表程序。默认密码alist"
msgid "Global settings"
msgstr "全局设置"
msgid "Port"
msgstr "端口"
msgid "Cache settings"
msgstr "缓存设置"
msgid "Cache invalidation time (unit: minutes)"
msgstr "缓存失效时间(分钟)"
msgid "Clear the invalidation cache interval"
msgstr "清理失效缓存间隔"
msgid "The Alist service is running."
msgstr "Alist 服务已启动"
msgid "The Alist service is not running."
msgstr "Alist 服务未启动"
msgid "Alist Status"
msgstr "Alist 服务状态"
msgid "Collecting data..."
msgstr "收集数据..."

View File

@ -0,0 +1,4 @@
#!/bin/sh
rm -f /tmp/luci-indexcache*
exit 0