mirror of
https://github.com/kenzok8/small-package.git
synced 2026-02-04 13:57:45 +08:00
update 2026-01-19 04:27:49
This commit is contained in:
25
luci-app-kai/luasrc/controller/kai.lua
Normal file
25
luci-app-kai/luasrc/controller/kai.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local http = require "luci.http"
|
||||
|
||||
module("luci.controller.kai", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/kai") then
|
||||
return
|
||||
end
|
||||
local page
|
||||
page = entry({"admin", "services","kai"}, cbi("kai"), _("KAI"), 100)
|
||||
page.dependent = true
|
||||
entry({"admin", "services", "kai_status"}, call("kai_status"))
|
||||
|
||||
end
|
||||
|
||||
function kai_status()
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local status = {
|
||||
running = (sys.call("pidof kai_bin >/dev/null") == 0),
|
||||
port = 8197
|
||||
}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(status)
|
||||
end
|
||||
13
luci-app-kai/luasrc/model/cbi/kai.lua
Normal file
13
luci-app-kai/luasrc/model/cbi/kai.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
local m, s
|
||||
|
||||
m = Map("kai", translate("KAI"), translate("KAI is an efficient data transfer tool."))
|
||||
m:section(SimpleSection).template = "kai/kai_status"
|
||||
|
||||
s=m:section(TypedSection, "kai", translate("Global settings"))
|
||||
s.addremove=false
|
||||
s.anonymous=true
|
||||
|
||||
s:option(Flag, "enabled", translate("Enable")).rmempty=false
|
||||
return m
|
||||
|
||||
|
||||
22
luci-app-kai/luasrc/view/kai/kai_status.htm
Normal file
22
luci-app-kai/luasrc/view/kai/kai_status.htm
Normal file
@@ -0,0 +1,22 @@
|
||||
<script <script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(5, '<%=url("admin/services/kai_status")%>', null,function(x, st){
|
||||
var el = document.getElementById('kai_status');
|
||||
if (st && el){
|
||||
if(!st.running){
|
||||
el.innerHTML = '<br/><em style=\"color:red\"><%:The KAI service is not running.%></em>';
|
||||
}
|
||||
if (st.running){
|
||||
el.innerHTML = '<br/><em style=\"color:green\"><%:The KAI service is running.%></em>'
|
||||
+ "<br/><br/><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:Click to open KAI%> \" onclick=\"window.open('http://" + window.location.hostname + ":" + st.port + "/')\"/>";
|
||||
}
|
||||
}
|
||||
});
|
||||
//]]></script>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend>状态</legend>
|
||||
<p id="kai_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user