summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-status/luasrc/view/admin_status/index.htm
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-10-31 16:38:31 +0100
committerJo-Philipp Wich <jo@mein.io>2019-11-01 12:03:33 +0100
commitc85af3d7618b55c499ce4bf58e3896068bd413ae (patch)
tree5a147a914a07ae6e3098bc7da6ff89fa2bdd35fd /modules/luci-mod-status/luasrc/view/admin_status/index.htm
parent5ce16764ad3212367547555dbbfe9c5f4f221118 (diff)
luci-mod-status: reimplement index status page as client side view
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-status/luasrc/view/admin_status/index.htm')
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index.htm169
1 files changed, 49 insertions, 120 deletions
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%>
<h2 name="content"><%:Status%></h2>
+<div id="view">
+ <div class="spinning"><%:Loading view…%></div>
+</div>
+
+<script type="text/javascript">//<![CDATA[
+function progressbar(query, value, max, byte)
+{
+ var pg = document.querySelector(query),
+ vn = parseInt(value) || 0,
+ mn = parseInt(max) || 100,
+ fv = byte ? String.format('%1024.2mB', value) : value,
+ fm = byte ? String.format('%1024.2mB', max) : max,
+ pc = Math.floor((100 / mn) * vn);
+
+ if (pg) {
+ pg.firstElementChild.style.width = pc + '%';
+ pg.setAttribute('title', '%s / %s (%d%%)'.format(fv, fm, pc));
+ }
+}
+
+function renderBox(title, active, childs) {
+ childs = childs || [];
+ childs.unshift(L.itemlist(E('span'), [].slice.call(arguments, 3)));
+
+ return E('div', { class: 'ifacebox' }, [
+ E('div', { class: 'ifacebox-head center ' + (active ? 'active' : '') },
+ E('strong', title)),
+ E('div', { class: 'ifacebox-body left' }, childs)
+ ]);
+}
+
+function renderBadge(icon, title) {
+ return E('span', { class: 'ifacebadge' }, [
+ E('img', { src: icon, title: title || '' }),
+ L.itemlist(E('span'), [].slice.call(arguments, 2))
+ ]);
+}
+
+//]]></script>
+
+<div class="includes" style="display:none">
<%-
+ local util = require "luci.util"
+ local fs = require "nixio.fs"
+
local incdir = util.libpath() .. "/view/admin_status/index/"
if fs.access(incdir) then
local _, inc
@@ -142,7 +67,11 @@
end
end
-%>
+</div>
-<script type="text/javascript" src="<%=resource%>/view/status/index.js"></script>
+<script type="text/javascript">L.require('view.status.index').catch(function(err) {
+ L.dom.content(document.querySelector('#view'), null);
+ L.error(err);
+});</script>
<%+footer%>