From: Yousong Zhou Date: Mon, 24 Jul 2017 05:00:37 +0000 (+0800) Subject: luci-app-shadowsocks-libev: auto update instance running state X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=refs%2Fpull%2F1249%2Fhead;p=oweals%2Fluci.git luci-app-shadowsocks-libev: auto update instance running state Signed-off-by: Yousong Zhou --- diff --git a/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua b/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua index e191e59bb..05d12e38b 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua +++ b/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua @@ -19,4 +19,15 @@ function index() entry({"admin", "services", "shadowsocks-libev", "rules"}, cbi("shadowsocks-libev/rules"), _("Redir Rules"), 30).leaf = true + + entry({"admin", "services", "shadowsocks-libev", "status"}, call("ss_status"), nil).leaf = true + +end + +function ss_status() + local ut = require "luci.util" + local rv = ut.ubus("service", "list", {name = "shadowsocks-libev"})["shadowsocks-libev"] or {_=0} + + luci.http.prepare_content("application/json") + luci.http.write_json(rv) end diff --git a/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/instances.lua b/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/instances.lua index 15e57df6b..62a90fb41 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/instances.lua +++ b/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/instances.lua @@ -15,19 +15,10 @@ m = Map("shadowsocks-libev", local instances = {} local cfgtypes = { "ss_local", "ss_redir", "ss_server", "ss_tunnel" } -local instances_data = ut.ubus("service", "list", {name = "shadowsocks-libev"})["shadowsocks-libev"] -if instances_data ~= nil then - instances_data = instances_data["instances"] -end for sname, sdata in pairs(m:get()) do local key, value = ss.cfgvalue_overview(sdata) if key ~= nil then - if instances_data and instances_data[key] and instances_data[key]["running"] then - value["running"] = "yes" - else - value["running"] = "no" - end instances[key] = value end end diff --git a/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm b/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm index 67e1c4f72..219d89b07 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm +++ b/applications/luci-app-shadowsocks-libev/luasrc/view/shadowsocks-libev/add_instance.htm @@ -20,3 +20,26 @@ +