From 77014af67edbced3d7ccf5b6650d56c3c6b39cbb Mon Sep 17 00:00:00 2001 From: Anton Kikin Date: Mon, 10 Dec 2018 19:56:42 +0300 Subject: [PATCH] luci-mod-status: split status page into a series of partials Split status page into a series of partials as discussed in PR #2359. Signed-off-by: Anton Kikin --- .../luasrc/view/admin_status/index.htm | 122 +++--------------- .../view/admin_status/index/10-system.htm | 29 +++++ .../view/admin_status/index/20-memory.htm | 31 +++++ .../view/admin_status/index/30-network.htm | 17 +++ .../admin_status/index/40-dhcp-leases.htm | 14 ++ .../luasrc/view/admin_status/index/50-dsl.htm | 20 +++ .../view/admin_status/index/60-wifi.htm | 26 ++++ 7 files changed, 156 insertions(+), 103 deletions(-) create mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm create mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm create mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm create mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm create mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm create mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm 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 b11956a8a..465226fe0 100644 --- a/modules/luci-mod-status/luasrc/view/admin_status/index.htm +++ b/modules/luci-mod-status/luasrc/view/admin_status/index.htm @@ -11,29 +11,24 @@ local stat = require "luci.tools.status" local ver = require "luci.version" - local has_ipv6 = fs.access("/proc/net/ipv6_route") - local has_dhcp = fs.access("/etc/config/dhcp") - local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0) + if luci.http.formvalue("status") == "1" then - local sysinfo = luci.util.ubus("system", "info") or { } - local boardinfo = luci.util.ubus("system", "board") or { } - local unameinfo = nixio.uname() or { } + local sysinfo = luci.util.ubus("system", "info") or { } - local meminfo = sysinfo.memory or { - total = 0, - free = 0, - buffered = 0, - shared = 0 - } + local meminfo = sysinfo.memory or { + total = 0, + free = 0, + buffered = 0, + shared = 0 + } - local swapinfo = sysinfo.swap or { - total = 0, - free = 0 - } + local swapinfo = sysinfo.swap or { + total = 0, + free = 0 + } - local has_dsl = fs.access("/etc/init.d/dsl_control") + local has_dsl = fs.access("/etc/init.d/dsl_control") - if luci.http.formvalue("status") == "1" then local ntm = require "luci.model.network".init() local wan_nets = ntm:get_wan_networks() local wan6_nets = ntm:get_wan6_networks() @@ -133,98 +128,19 @@

<%:Status%>

-
-

<%: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%>
-
-
-
- -
-

<%:Memory%>

- -
-
<%:Total Available%>
-
<%:Free%>
-
<%:Buffered%>
-
-
- -<% if swapinfo.total > 0 then %> -
-

<%:Swap%>

- -
-
<%:Total Available%>
-
<%:Free%>
-
-
-<% end %> - -
-

<%:Network%>

- -
-

<%:Collecting data...%>

-
- -
-
<%:Active Connections%>
-
-
- -<% - if has_dhcp then - include("lease_status") - end -%> - -<% if has_dsl then %> -
-

<%:DSL%>

- -
-

<%:Collecting data...%>

-
-
-<% end %> - -<% if has_wifi then %> -
-

<%:Wireless%>

- -
-

<%:Collecting data...%>

-
-
- -
-

<%:Associated Stations%>

- - <%+wifi_assoclist%> -
-<% end %> - <%- local incdir = util.libpath() .. "/view/admin_status/index/" if fs.access(incdir) then - local inc + local _, inc + local includes = {} for inc in fs.dir(incdir) do if inc:match("%.htm$") then - include("admin_status/index/" .. inc:gsub("%.htm$", "")) + includes[#includes + 1] = inc:gsub("%.htm$", "") end end + for _, inc in luci.util.vspairs(includes) do + include("admin_status/index/" .. inc) + end end -%> 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 new file mode 100644 index 000000000..994550ec2 --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm @@ -0,0 +1,29 @@ +<%# + 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 new file mode 100644 index 000000000..13774704f --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm @@ -0,0 +1,31 @@ +<%# + 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 new file mode 100644 index 000000000..945a31b2e --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm @@ -0,0 +1,17 @@ +<%# + 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 new file mode 100644 index 000000000..aaf366144 --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm @@ -0,0 +1,14 @@ +<%# + 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 new file mode 100644 index 000000000..f37bf147a --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm @@ -0,0 +1,20 @@ +<%# + 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 new file mode 100644 index 000000000..7338bc77f --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm @@ -0,0 +1,26 @@ +<%# + 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 %> -- 2.25.1