luci-app-alist: Add log preview support
This commit is contained in:
parent
9656557fdf
commit
641a8a91dc
@ -5,9 +5,16 @@ function index()
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "nas", "alist"}, alias("admin", "nas", "alist", "basic"), _("Alist"), 20)
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-alist" }
|
||||
|
||||
entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false
|
||||
entry({"admin", "nas", "alist"}, cbi("alist"), _("Alist"), 20).dependent = true
|
||||
entry({"admin", "nas", "alist_status"}, call("alist_status"))
|
||||
entry({"admin", "nas", "alist", "basic"}, cbi("alist/basic"), _("Basic Setting"), 1).leaf = true
|
||||
entry({"admin", "nas", "alist", "log"}, cbi("alist/log"), _("Logs"), 2).leaf = true
|
||||
entry({"admin", "nas", "alist", "alist_status"}, call("alist_status")).leaf = true
|
||||
entry({"admin", "nas", "alist", "get_log"}, call("get_log")).leaf = true
|
||||
entry({"admin", "nas", "alist", "clear_log"}, call("clear_log")).leaf = true
|
||||
end
|
||||
|
||||
function alist_status()
|
||||
@ -23,3 +30,11 @@ function alist_status()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(status)
|
||||
end
|
||||
|
||||
function get_log()
|
||||
luci.http.write(luci.sys.exec("cat $(uci -q get alist.@alist[0].temp_dir)/alist.log"))
|
||||
end
|
||||
|
||||
function clear_log()
|
||||
luci.sys.call("cat /dev/null > $(uci -q get alist.@alist[0].temp_dir)/alist.log")
|
||||
end
|
||||
|
@ -8,9 +8,9 @@ local m, s
|
||||
m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. translate("Default username and password:") .. "<font color=\"green\">admin / admin</font>" .. "<br/>" .. [[<a href="https://alist.nn.ci/guide/drivers/local.html" target="_blank">]] .. translate("User Manual") .. [[</a>]])
|
||||
--end
|
||||
|
||||
m:section(SimpleSection).template = "alist_status"
|
||||
m:section(SimpleSection).template = "alist/alist_status"
|
||||
|
||||
s = m:section(TypedSection, "alist", translate("Global settings"))
|
||||
s = m:section(TypedSection, "alist")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
@ -21,6 +21,10 @@ o = s:option(Value, "port", translate("Port"))
|
||||
o.datatype = "and(port,min(1))"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "log", translate("Enable Logs"))
|
||||
o.default = 1
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "ssl", translate("Enable SSL"))
|
||||
o.rmempty=false
|
||||
|
5
luci-app-alist/luasrc/model/cbi/log.lua
Normal file
5
luci-app-alist/luasrc/model/cbi/log.lua
Normal file
@ -0,0 +1,5 @@
|
||||
m = Map("alist")
|
||||
|
||||
m:append(Template("alist/alist_log"))
|
||||
|
||||
return m
|
29
luci-app-alist/luasrc/view/alist_log.htm
Normal file
29
luci-app-alist/luasrc/view/alist_log.htm
Normal file
@ -0,0 +1,29 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clear_log(btn) {
|
||||
XHR.get('<%=url([[admin]], [[nas]], [[alist]], [[clear_log]])%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = "";
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(2, '<%=url([[admin]], [[nas]], [[alist]], [[get_log]])%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = x.responseText;
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<fieldset class="cbi-section" id="_log_fieldset">
|
||||
<input class="cbi-button cbi-input-remove" type="button" onclick="clear_log()" value="<%:Clear logs%>" style="margin-left: 10px; margin-top: 10px;">
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 500px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
@ -9,7 +9,7 @@
|
||||
%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(5, '<%=url("admin/nas/alist_status")%>', null,
|
||||
XHR.poll(5, '<%=url("admin/nas/alist/alist_status")%>', null,
|
||||
function(x, st)
|
||||
{
|
||||
var tb = document.getElementById('alist_status');
|
||||
@ -17,11 +17,11 @@
|
||||
{
|
||||
if (st.running)
|
||||
{
|
||||
tb.innerHTML = '<em style=\"color:green\"><b><%:The Alist service is running.%></b></em>' + "<input class=\"cbi-button-reload mar-10\" type=\"button\" value=\" <%:Click to open Alist%> \" onclick=\"window.open('<%=protocol%>" + window.location.hostname + ":" + st.port + "/')\"/>";
|
||||
tb.innerHTML = '<em style=\"color:green\"><b>Alist <%:RUNNING%></b></em>' + "<input class=\"cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('<%=protocol%>" + window.location.hostname + ":" + st.port + "/')\"/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.innerHTML = '<em style=\"color:red\"><b><%:The Alist service is not running.%></b></em>';
|
||||
tb.innerHTML = '<em style=\"color:red\"><b>Alist <%:NOT RUNNING%></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ msgstr "Alist 文件列表"
|
||||
msgid "Running state"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "Click to open Alist"
|
||||
msgstr "点击打开 Alist"
|
||||
msgid "Open Web Interface"
|
||||
msgstr "打开 Web 界面"
|
||||
|
||||
msgid "A file list program that supports multiple storage."
|
||||
msgstr "一款支持多种存储的目录文件列表程序。"
|
||||
@ -13,8 +13,8 @@ msgstr "一款支持多种存储的目录文件列表程序。"
|
||||
msgid "manage password:"
|
||||
msgstr "管理密码:"
|
||||
|
||||
msgid "Global settings"
|
||||
msgstr "全局设置"
|
||||
msgid "Basic Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Port"
|
||||
msgstr "端口"
|
||||
@ -37,11 +37,11 @@ msgstr "SSL 密钥文件路径"
|
||||
msgid "Cache directory"
|
||||
msgstr "缓存目录"
|
||||
|
||||
msgid "The Alist service is running."
|
||||
msgstr "Alist 服务已启动"
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "The Alist service is not running."
|
||||
msgstr "Alist 服务未启动"
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "收集数据..."
|
||||
@ -52,9 +52,14 @@ msgstr "网络存储"
|
||||
msgid "User Manual"
|
||||
msgstr "用户手册"
|
||||
|
||||
#: luci-app-alist/luasrc/model/cbi/alist.lua:35
|
||||
msgid "Allow Access From Internet"
|
||||
msgstr "允许从外网访问"
|
||||
|
||||
msgid "Default username and password:"
|
||||
msgstr "默认用户名和密码:"
|
||||
|
||||
msgid "Enable Logs"
|
||||
msgstr "启用日志"
|
||||
|
||||
msgid "Clear logs"
|
||||
msgstr "清空日志"
|
||||
|
@ -8,6 +8,7 @@ CONFIG=/etc/alist/config.json
|
||||
get_config() {
|
||||
config_get_bool enabled $1 enabled 1
|
||||
config_get port $1 port 5244
|
||||
config_get log $1 log 1
|
||||
config_get temp_dir $1 temp_dir "/tmp/alist"
|
||||
config_get ssl $1 ssl 0
|
||||
config_get ssl_cert $1 ssl_cert ""
|
||||
@ -46,6 +47,11 @@ start_service() {
|
||||
else
|
||||
SSL=false
|
||||
fi
|
||||
if [ "$log" -eq 1 ];then
|
||||
LOG=true
|
||||
else
|
||||
LOG=false
|
||||
fi
|
||||
if [ "$allow_wan" -eq "1" ]; then
|
||||
listen_addr="0.0.0.0"
|
||||
external_access="allow"
|
||||
@ -55,7 +61,7 @@ start_service() {
|
||||
fi
|
||||
set_firewall
|
||||
cat > $CONFIG <<EOF
|
||||
{"force":false,"address":"$listen_addr","port":$port,"jwt_secret":"","cdn":"","database":{"type":"sqlite3","host":"","port":0,"user":"","password":"","name":"","db_file":"/etc/alist/data.db","table_prefix":"x_","ssl_mode":""},"scheme":{"https":$SSL,"cert_file":"$ssl_cert","key_file":"$ssl_key"},"temp_dir":"$temp_dir","log":{"enable":false,"name":"$temp_dir/alist.log","max_size":10,"max_backups":5,"max_age":28,"compress":false}}
|
||||
{"force":false,"address":"$listen_addr","port":$port,"jwt_secret":"","cdn":"","database":{"type":"sqlite3","host":"","port":0,"user":"","password":"","name":"","db_file":"/etc/alist/data.db","table_prefix":"x_","ssl_mode":""},"scheme":{"https":$SSL,"cert_file":"$ssl_cert","key_file":"$ssl_key"},"temp_dir":"$temp_dir","log":{"enable":$LOG,"name":"$temp_dir/alist.log","max_size":10,"max_backups":5,"max_age":28,"compress":false}}
|
||||
EOF
|
||||
procd_open_instance alist
|
||||
procd_set_param command $PROG
|
||||
|
Loading…
Reference in New Issue
Block a user