From c85af3d7618b55c499ce4bf58e3896068bd413ae Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 31 Oct 2019 16:38:31 +0100 Subject: luci-mod-status: reimplement index status page as client side view Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/admin_status/index.htm | 169 ++++++--------------- .../luasrc/view/admin_status/index/10-system.htm | 29 ---- .../luasrc/view/admin_status/index/20-memory.htm | 31 ---- .../luasrc/view/admin_status/index/30-network.htm | 17 --- .../view/admin_status/index/40-dhcp-leases.htm | 14 -- .../luasrc/view/admin_status/index/50-dsl.htm | 20 --- .../luasrc/view/admin_status/index/60-wifi.htm | 26 ---- 7 files changed, 49 insertions(+), 257 deletions(-) delete mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm delete mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm delete mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm delete mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm delete mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm delete mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm (limited to 'modules/luci-mod-status/luasrc/view') diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index.htm b/modules/luci-mod-status/luasrc/view/admin_status/index.htm index 5b53e8ed34..958212a01f 100644 --- a/modules/luci-mod-status/luasrc/view/admin_status/index.htm +++ b/modules/luci-mod-status/luasrc/view/admin_status/index.htm @@ -4,130 +4,55 @@ Licensed to the public under the Apache License 2.0. -%> -<% - local fs = require "nixio.fs" - local ipc = require "luci.ip" - local util = require "luci.util" - local stat = require "luci.tools.status" - local ver = require "luci.version" - - if luci.http.formvalue("status") == "1" then - - local sysinfo = luci.util.ubus("system", "info") or { } - - local meminfo = sysinfo.memory or { - total = 0, - free = 0, - buffered = 0, - shared = 0 - } - - local swapinfo = sysinfo.swap or { - total = 0, - free = 0 - } - - local has_dsl = fs.access("/etc/init.d/dsl_control") - - local ntm = require "luci.model.network".init() - local wan_nets = ntm:get_wan_networks() - local wan6_nets = ntm:get_wan6_networks() - - local conn_count = tonumber( - fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0 - - local conn_max = tonumber(luci.sys.exec( - "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max" - ):match("%d+")) or 4096 - - local rv = { - uptime = sysinfo.uptime or 0, - localtime = os.date(), - loadavg = sysinfo.load or { 0, 0, 0 }, - memory = meminfo, - swap = swapinfo, - connmax = conn_max, - conncount = conn_count, - wifinets = stat.wifi_networks() - } - - if #wan_nets > 0 then - local k, v - - rv.wan = { } - - for k, v in pairs(wan_nets) do - local dev = v:get_interface() - local link = dev and ipc.link(dev:name()) - - local wan_info = { - ipaddrs = v:ipaddrs(), - gwaddr = v:gwaddr(), - dns = v:dnsaddrs(), - expires = v:expires(), - uptime = v:uptime(), - proto = v:proto(), - i18n = v:get_i18n(), - ifname = v:ifname(), - link = v:adminlink(), - mac = dev and dev:mac(), - type = dev and dev:type(), - name = dev and dev:get_i18n(), - ether = link and link.type == 1 - } - - rv.wan[#rv.wan+1] = wan_info - end - end - - if #wan6_nets > 0 then - local k, v - - rv.wan6 = { } - - for k, v in pairs(wan6_nets) do - local dev = v:get_interface() - local link = dev and ipc.link(dev:name()) - local wan6_info = { - ip6addrs = v:ip6addrs(), - gw6addr = v:gw6addr(), - dns = v:dns6addrs(), - ip6prefix = v:ip6prefix(), - uptime = v:uptime(), - proto = v:proto(), - i18n = v:get_i18n(), - ifname = v:ifname(), - link = v:adminlink(), - mac = dev and dev:mac(), - type = dev and dev:type(), - name = dev and dev:get_i18n(), - ether = link and link.type == 1 - } - - rv.wan6[#rv.wan6+1] = wan6_info - end - end - - if has_dsl then - local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat") - local dsl_func = loadstring(dsl_stat) - if dsl_func then - rv.dsl = dsl_func() - end - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) - - return - end --%> - <%+header%>

<%:Status%>

+
+
<%:Loading view…%>
+
+ + + + - + <%+footer%> diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm deleted file mode 100644 index 994550ec2b..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm +++ /dev/null @@ -1,29 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% - local boardinfo = luci.util.ubus("system", "board") or { } - local unameinfo = nixio.uname() or { } - local ver = require "luci.version" -%> - -
-

<%:System%>

- -
-
<%:Hostname%>
<%=luci.sys.hostname() or "?"%>
-
<%:Model%>
<%=pcdata(boardinfo.model or "?")%>
-
<%:Architecture%>
<%=pcdata(boardinfo.system or "?")%>
-
<%:Firmware Version%>
- <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> / - <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>) -
-
<%:Kernel Version%>
<%=unameinfo.release or "?"%>
-
<%:Local Time%>
-
-
<%:Uptime%>
-
-
<%:Load Average%>
-
-
-
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm deleted file mode 100644 index 13774704fe..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm +++ /dev/null @@ -1,31 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% - local sysinfo = luci.util.ubus("system", "info") or { } - local has_swap = sysinfo.swap and sysinfo.swap.total > 0 or false -%> - -
-

<%:Memory%>

- -
-
<%:Total Available%>
-
<%:Free%>
-
<%:Buffered%>
-
-
- -<% if has_swap then %> -
-

<%:Swap%>

- -
-
<%:Total Available%>
-
<%:Free%>
-
-
-<% end %> diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm deleted file mode 100644 index 945a31b2e5..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm +++ /dev/null @@ -1,17 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -
-

<%:Network%>

- -
-

<%:Collecting data...%>

-
- -
-
<%:Active Connections%>
-
-
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm deleted file mode 100644 index aaf3661442..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm +++ /dev/null @@ -1,14 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% - local fs = require "nixio.fs" - local has_dhcp = fs.access("/etc/config/dhcp") - - if has_dhcp then - include("lease_status") - end -%> diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm deleted file mode 100644 index f37bf147a3..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm +++ /dev/null @@ -1,20 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% - local fs = require "nixio.fs" - local has_dsl = fs.access("/etc/init.d/dsl_control") -%> - -<% if has_dsl then %> -
-

<%:DSL%>

- -
-

<%:Collecting data...%>

-
-
-<% end %> diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm deleted file mode 100644 index 7338bc77f1..0000000000 --- a/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm +++ /dev/null @@ -1,26 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% - local fs = require "nixio.fs" - local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0) -%> - -<% if has_wifi then %> -
-

<%:Wireless%>

- -
-

<%:Collecting data...%>

-
-
- -
-

<%:Associated Stations%>

- - <%+wifi_assoclist%> -
-<% end %> -- cgit v1.2.3