luci-app-alist: Add password view
This commit is contained in:
parent
071721f7ea
commit
d310a6cc2d
@ -15,6 +15,7 @@ function index()
|
|||||||
entry({"admin", "nas", "alist", "alist_status"}, call("alist_status")).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", "get_log"}, call("get_log")).leaf = true
|
||||||
entry({"admin", "nas", "alist", "clear_log"}, call("clear_log")).leaf = true
|
entry({"admin", "nas", "alist", "clear_log"}, call("clear_log")).leaf = true
|
||||||
|
entry({"admin", "nas", "alist", "admin_info"}, call("admin_info")).leaf = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function alist_status()
|
function alist_status()
|
||||||
@ -38,3 +39,11 @@ end
|
|||||||
function clear_log()
|
function clear_log()
|
||||||
luci.sys.call("cat /dev/null > $(uci -q get alist.@alist[0].temp_dir)/alist.log")
|
luci.sys.call("cat /dev/null > $(uci -q get alist.@alist[0].temp_dir)/alist.log")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function admin_info()
|
||||||
|
local username = luci.sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -2 | awk 'NR==1 {print $2}'")
|
||||||
|
local password = luci.sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -2 | awk 'NR==2 {print $2}'")
|
||||||
|
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json({username = username, password = password})
|
||||||
|
end
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
local m, s
|
local m, s
|
||||||
--local sys = require "luci.sys"
|
|
||||||
|
|
||||||
--if sys.call("pidof alist >/dev/null") == 0 then
|
m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "<br/>" .. [[<a href="https://alist.nn.ci/zh/guide/drivers/local.html" target="_blank">]] .. translate("User Manual") .. [[</a>]])
|
||||||
-- local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -1 | awk -F': ' '{print $2}'")
|
|
||||||
-- m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. " " .. translate("manage password:") .. "<font color=\"green\">" .. password .. "</font>" .. "<br/>" .. [[<a href="https://alist.nn.ci/guide/drivers/local.html" target="_blank">]] .. translate("User Manual") .. [[</a>]])
|
|
||||||
--else
|
|
||||||
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/alist_status"
|
m:section(SimpleSection).template = "alist/alist_status"
|
||||||
|
|
||||||
@ -44,4 +38,8 @@ o.datatype = "string"
|
|||||||
o.default = "/tmp/alist"
|
o.default = "/tmp/alist"
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
|
|
||||||
|
o = s:option(Button, "admin_info", translate("View Password"))
|
||||||
|
o.rawhtml = true
|
||||||
|
o.template = "alist/admin_info"
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
26
luci-app-alist/luasrc/view/alist/admin_info.htm
Normal file
26
luci-app-alist/luasrc/view/alist/admin_info.htm
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<%+cbi/valueheader%>
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
function admin_info(btn)
|
||||||
|
{
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.value = '<%:Reading...%>';
|
||||||
|
XHR.get('<%=luci.dispatcher.build_url("admin", "nas", "alist", "admin_info")%>',
|
||||||
|
null,
|
||||||
|
function(x,rv)
|
||||||
|
{
|
||||||
|
var tb = document.getElementById('<%=self.option%>-status');
|
||||||
|
if (tb)
|
||||||
|
{
|
||||||
|
tb.innerHTML = "<%:Username:%>" + "<font color='green'>" + rv.username + "</font>";
|
||||||
|
tb.innerHTML += "<%:Password:%>" + "<font color='green'>" + rv.password + "</font>";
|
||||||
|
}
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.value = '<%:Read%>';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//]]></script>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Read%>" onclick="return admin_info(this)" />
|
||||||
|
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||||
|
<%+cbi/valuefooter%>
|
@ -10,9 +10,6 @@ msgstr "打开 Web 界面"
|
|||||||
msgid "A file list program that supports multiple storage."
|
msgid "A file list program that supports multiple storage."
|
||||||
msgstr "一款支持多种存储的目录文件列表程序。"
|
msgstr "一款支持多种存储的目录文件列表程序。"
|
||||||
|
|
||||||
msgid "manage password:"
|
|
||||||
msgstr "管理密码:"
|
|
||||||
|
|
||||||
msgid "Basic Setting"
|
msgid "Basic Setting"
|
||||||
msgstr "基本设置"
|
msgstr "基本设置"
|
||||||
|
|
||||||
@ -55,11 +52,23 @@ msgstr "用户手册"
|
|||||||
msgid "Allow Access From Internet"
|
msgid "Allow Access From Internet"
|
||||||
msgstr "允许从外网访问"
|
msgstr "允许从外网访问"
|
||||||
|
|
||||||
msgid "Default username and password:"
|
|
||||||
msgstr "默认用户名和密码:"
|
|
||||||
|
|
||||||
msgid "Enable Logs"
|
msgid "Enable Logs"
|
||||||
msgstr "启用日志"
|
msgstr "启用日志"
|
||||||
|
|
||||||
msgid "Clear logs"
|
msgid "Clear logs"
|
||||||
msgstr "清空日志"
|
msgstr "清空日志"
|
||||||
|
|
||||||
|
msgid "View Password"
|
||||||
|
msgstr "查看密码"
|
||||||
|
|
||||||
|
msgid "Username:"
|
||||||
|
msgstr "用户名:"
|
||||||
|
|
||||||
|
msgid "Password:"
|
||||||
|
msgstr "密码:"
|
||||||
|
|
||||||
|
msgid "Reading..."
|
||||||
|
msgstr "读取中..."
|
||||||
|
|
||||||
|
msgid "Read"
|
||||||
|
msgstr "读取"
|
||||||
|
Loading…
Reference in New Issue
Block a user