NIU:
Redesign dashboard Level 1 Network / System status on dashboard Rework "LAN IP has changed" warning Fix Routing table not hiding when requested
This commit is contained in:
parent
b882bdeb04
commit
730a9b6f69
12 changed files with 227 additions and 69 deletions
BIN
modules/niu/htdocs/luci-static/resources/icons32/folder.png
Normal file
BIN
modules/niu/htdocs/luci-static/resources/icons32/folder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 645 B |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
26
modules/niu/htdocs/luci-static/resources/niu.css
Normal file
26
modules/niu/htdocs/luci-static/resources/niu.css
Normal file
|
@ -0,0 +1,26 @@
|
|||
fieldset.dbbox {
|
||||
float: left;
|
||||
margin: 1em;
|
||||
padding: 0.5em;
|
||||
background: #eeeeee;
|
||||
border: 1px solid #cccccc;
|
||||
border-radius: 5px;
|
||||
-khtml-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-o-border-radius: 5px;
|
||||
}
|
||||
|
||||
fieldset.dbbox h2 {
|
||||
background: url(icons32/folder.png) no-repeat right;
|
||||
min-height: 24px;
|
||||
}
|
||||
|
||||
table.dbstattbl {
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.dbstattbl th {
|
||||
margin-right: 0.5em;
|
||||
}
|
|
@ -26,7 +26,8 @@ function index()
|
|||
end
|
||||
|
||||
entry({"niu"}, alias("niu", "dashboard"), "NIU", 10)
|
||||
entry({"niu", "dashboard"}, call("dashboard"), "Dashboard", 1)
|
||||
entry({"niu", "dashboard"}, call("dashboard"), "Dashboard", 1).css =
|
||||
"niu.css"
|
||||
end
|
||||
|
||||
local require = req
|
||||
|
|
|
@ -16,23 +16,28 @@ local require = require
|
|||
module "luci.controller.niu.network"
|
||||
|
||||
function index()
|
||||
entry({"niu", "network"}, nil, "Network", 10).dbtemplate = "niu/network"
|
||||
local toniu = {on_success_to={"niu"}}
|
||||
|
||||
local e = entry({"niu", "network"}, alias("niu"), "Network", 10)
|
||||
e.niu_dbtemplate = "niu/network"
|
||||
e.niu_dbtasks = true
|
||||
e.niu_dbicon = "icons32/network-workgroup.png"
|
||||
|
||||
entry({"niu", "network", "wan"},
|
||||
cbi("niu/network/wan", {on_success_to={"niu"}}), "Configure Internet Connection", 10)
|
||||
cbi("niu/network/wan", toniu), "Configure Internet Connection", 1)
|
||||
|
||||
entry({"niu", "network", "lan"},
|
||||
cbi("niu/network/lan", {on_success_to={"niu"}}), "Configure Local Network", 20)
|
||||
cbi("niu/network/lan", toniu), "Configure Local Network", 2)
|
||||
|
||||
uci.inst_state:foreach("dhcp", "dhcp", function(s)
|
||||
if s.interface == "lan" and s.ignore ~= "1" then
|
||||
entry({"niu", "network", "assign"}, cbi("niu/network/assign",
|
||||
{on_success_to={"niu"}}), "Display and Customize Address Assignment", 30)
|
||||
toniu), "Display and Customize Address Assignment", 30)
|
||||
end
|
||||
end)
|
||||
|
||||
entry({"niu", "network", "routes"}, cbi("niu/network/routes",
|
||||
{on_success_to={"niu"}}), "Display and Customize Routing", 40)
|
||||
toniu), "Display and Customize Routing", 40)
|
||||
|
||||
entry({"niu", "network", "conntrack"}, call("cnntrck"),
|
||||
"Display Local Network Activity", 50)
|
||||
|
|
|
@ -16,13 +16,18 @@ local require, pairs, unpack, tonumber = require, pairs, unpack, tonumber
|
|||
module "luci.controller.niu.system"
|
||||
|
||||
function index()
|
||||
entry({"niu", "system"}, nil, "System", 20).dbtemplate = "niu/system"
|
||||
local toniu = {on_success_to={"niu"}}
|
||||
|
||||
local e = entry({"niu", "system"}, alias("niu"), "System", 20)
|
||||
e.niu_dbtemplate = "niu/system"
|
||||
e.niu_dbtasks = true
|
||||
e.niu_dbicon = "icons32/preferences-system.png"
|
||||
|
||||
entry({"niu", "system", "general"},
|
||||
cbi("niu/system/general", {on_success_to={"niu"}}), "Configure Device", 10)
|
||||
cbi("niu/system/general", toniu), "Configure Device", 1)
|
||||
|
||||
entry({"niu", "system", "backup"}, call("backup"), "Backup or Restore Settings", 20)
|
||||
entry({"niu", "system", "upgrade"}, call("upgrade"), "Upgrade Firmware", 40)
|
||||
entry({"niu", "system", "backup"}, call("backup"), "Backup or Restore Settings", 2)
|
||||
entry({"niu", "system", "upgrade"}, call("upgrade"), "Upgrade Firmware", 30)
|
||||
end
|
||||
|
||||
function backup()
|
||||
|
|
|
@ -1,17 +1,34 @@
|
|||
<%+header%>
|
||||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
local utl = require "luci.util"
|
||||
|
||||
<%
|
||||
include("header")
|
||||
|
||||
local function cmp(a, b)
|
||||
return (a.order or 100) < (b.order or 100)
|
||||
return (nodes[a].order or 100) < (nodes[b].order or 100)
|
||||
end
|
||||
for k, v in utl.spairs(nodes, cmp) do
|
||||
if v.dbtemplate then
|
||||
if v.niu_dbtemplate or v.niu_dbtasks then
|
||||
%>
|
||||
<fieldset style="float: left; margin: 1em; padding: 0.5em">
|
||||
<legend><%=v.title%></legend>
|
||||
<%
|
||||
tpl.render(v.dbtemplate)
|
||||
%>
|
||||
<fieldset class="dbbox">
|
||||
<h2<% if v.niu_dbicon then %> style="background-image: url(<%=resource%>/<%=v.niu_dbicon%>)"<% end %>><%=v.title%></h2>
|
||||
<% if v.niu_dbtemplate then tpl.render(v.niu_dbtemplate) end %>
|
||||
<% if v.niu_dbtasks then %>
|
||||
<h4>Tasks:</h4>
|
||||
<ul>
|
||||
<%
|
||||
local nodes = dsp.node("niu", k).nodes
|
||||
local function cmp(a, b)
|
||||
return (nodes[a].order or 100) < (nodes[b].order or 100)
|
||||
end
|
||||
for k2, v2 in utl.spairs(nodes, cmp) do
|
||||
%>
|
||||
<li><a href="<%=dsp.build_url("niu", k, k2)%>"><%=v2.title%></a></li>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</ul>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<%
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
local utl = require "luci.util"
|
||||
local uci = require "luci.model.uci"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local nws = {}
|
||||
uci.inst_state:foreach("network", "interface", function(s)
|
||||
|
@ -12,27 +11,85 @@ if uci.inst_state:get("network", "lan", "_ipchanged") and
|
|||
uci.inst_state:revert("network", "lan", "_ipchanged") then
|
||||
include("niu/network/warn_ip_change")
|
||||
end
|
||||
|
||||
local wanon = uci.inst_state:get("network", "wan", "proto")
|
||||
local wanup = uci.inst_state:get("network", "wan", "up")
|
||||
local wanip = uci.inst_state:get("network", "wan", "ipaddr")
|
||||
local wanif = uci.inst_state:get("network", "wan", "ifname")
|
||||
local wanul, wandl
|
||||
|
||||
if wanif then
|
||||
local devstats = fs.readfile("/proc/net/dev")
|
||||
local rx, tx = devstats:match("%s*"..wanif..
|
||||
":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+"..
|
||||
"[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)")
|
||||
wanul = tx and (tonumber(tx) / 1000000000)
|
||||
wandl = rx and (tonumber(rx) / 1000000000)
|
||||
end
|
||||
|
||||
local leasefn
|
||||
uci.inst:foreach("dhcp", "dnsmasq",
|
||||
function(section)
|
||||
leasefn = section.leasefile
|
||||
end
|
||||
)
|
||||
|
||||
if leasefn then
|
||||
local ln = io.lines(leasefn)
|
||||
leasefn = 0
|
||||
while ln and ln() do
|
||||
leasefn = leasefn + 1
|
||||
end
|
||||
end
|
||||
|
||||
local arps
|
||||
if fs.access("/proc/net/arp", "r") then
|
||||
local ln = io.lines("/proc/net/arp")
|
||||
arps = -1
|
||||
while ln and ln() do
|
||||
arps = arps + 1
|
||||
end
|
||||
arps = arps >= 0 and arps
|
||||
end
|
||||
%>
|
||||
|
||||
<div>Status:</div>
|
||||
<table>
|
||||
<%
|
||||
for _, v in ipairs(nws) do if v[".name"] ~= "loopback" then
|
||||
%>
|
||||
<tr><td><%=v[".name"]%></td><td><%=v.ipaddr%></td></tr>
|
||||
<% end end %>
|
||||
<table class="dbstattbl">
|
||||
<% if wanon and wanon ~= "none" then %>
|
||||
<tr>
|
||||
<% if wanup then %>
|
||||
<th>Uplink Address</th>
|
||||
<td><span style="color: darkgreen"><%=wanip%></span>
|
||||
</td>
|
||||
<% else %>
|
||||
<th>Uplink</th>
|
||||
<td><span style="color: darkred"><em>offline</em></span>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if wanul and wandl then %>
|
||||
<tr>
|
||||
<th>Uplink Traffic</th><td>
|
||||
<%=("%.2f"):format(wandl)%> GB⇓ <%=("%.2f"):format(wanul)%> GB⇑
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<th>Local Address</th><td>
|
||||
<%=uci.inst_state:get("network", "lan", "ipaddr")%>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% if arps then %>
|
||||
<tr>
|
||||
<th>Active IP-Devices</th><td><%=arps%><% if leasefn then %>
|
||||
(<%=leasefn%> assigned)
|
||||
<% end %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
</table>
|
||||
<br />
|
||||
<ul>
|
||||
<%
|
||||
local nodes = dsp.node("niu", "network").nodes
|
||||
local function cmp(a, b)
|
||||
return (nodes[a].order or 100) < (nodes[b].order or 100)
|
||||
end
|
||||
for k, v in utl.spairs(nodes, cmp) do
|
||||
%>
|
||||
<li><a href="<%=dsp.build_url("niu", "network", k)%>"><%=v.title%></a></li>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</ul>
|
||||
<br />
|
|
@ -42,6 +42,7 @@ $Id$
|
|||
cursor:set("network", "lan", "_showrtable", rt == "1" and "0" or "1")
|
||||
cursor:save("network")
|
||||
cursor:unload("network")
|
||||
inst:unload("network")
|
||||
end
|
||||
-%>
|
||||
|
||||
|
|
|
@ -1,2 +1,11 @@
|
|||
<strong>Warning!<br />
|
||||
Device IP has changed.</strong>
|
||||
<%
|
||||
local http = require "luci.http"
|
||||
local dsp = require "luci.dispatcher"
|
||||
local ip = require "luci.model.uci".inst:get("network", "lan", "ipaddr")
|
||||
local url = (http.getenv("HTTPS") and "https" or "http") .. "://" .. ip ..
|
||||
dsp.build_url("niu")
|
||||
%>
|
||||
|
||||
<div style="color: red">Warning! The device IP-address has been changed.<br />
|
||||
The router will be available in a few seconds at <a href="<%=url%>"><%=url%></a></div>
|
||||
<br />
|
|
@ -1,35 +1,72 @@
|
|||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
local utl = require "luci.util"
|
||||
local nxo = require "nixio"
|
||||
local fs = require "nixio.fs"
|
||||
local sinfo = nxo.sysinfo()
|
||||
local load1 = nxo.bit.div(sinfo.loads[1] * 100, 1)
|
||||
local days = nxo.bit.div(sinfo.uptime, 86400)
|
||||
local hour = nxo.bit.div(sinfo.uptime, 3600) % 24
|
||||
local mins = nxo.bit.div(sinfo.uptime, 60) % 60
|
||||
local load15 = nxo.bit.div(sinfo.loads[3] * 100, 1)
|
||||
|
||||
local meminfo = fs.readfile("/proc/meminfo")
|
||||
local totalram = nxo.bit.div(sinfo.totalram, 1024)
|
||||
local freeram = nxo.bit.div(sinfo.freeram, 1024)
|
||||
local buffers = nxo.bit.div(sinfo.bufferram, 1024)
|
||||
local cached = tonumber(meminfo:match("Cached:%s+([0-9]+)%s+"))
|
||||
local memused = nxo.bit.div(totalram - freeram - cached - buffers, 1024)
|
||||
totalram = nxo.bit.div(totalram, 1024)
|
||||
|
||||
local totalswap = nxo.bit.div(sinfo.totalswap, 1048576)
|
||||
local usedswap = totalswap - nxo.bit.div(sinfo.freeswap, 1048576)
|
||||
|
||||
|
||||
local function date_format(secs)
|
||||
local suff = {"min", "h", "d"}
|
||||
local mins = 0
|
||||
local hour = 0
|
||||
local days = 0
|
||||
|
||||
secs = nxo.bit.div(secs, 1)
|
||||
if secs > 60 then
|
||||
mins = nxo.bit.div(secs, 60)
|
||||
secs = secs % 60
|
||||
end
|
||||
|
||||
if mins > 60 then
|
||||
hour = nxo.bit.div(mins, 60)
|
||||
mins = mins % 60
|
||||
end
|
||||
|
||||
if hour > 24 then
|
||||
days = nxo.bit.div(hour, 24)
|
||||
hour = hour % 24
|
||||
end
|
||||
|
||||
if days > 0 then
|
||||
return string.format("%.0fd %02.0fh %02.0fmin", days, hour, mins)
|
||||
else
|
||||
return string.format("%02.0fh %02.0fmin", hour, mins)
|
||||
end
|
||||
end
|
||||
%>
|
||||
<div>Status:</div>
|
||||
<table>
|
||||
<table class="dbstattbl">
|
||||
<tr>
|
||||
<th>System Load</th>
|
||||
<td><%=load1%> %</td>
|
||||
<th>Load:</th>
|
||||
<td><%=load1%>% / <%=load15%>%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Uptime</th>
|
||||
<td><%=days%>d, <%=hour%>:<%=mins%></td>
|
||||
<th>Memory:</th>
|
||||
<td><%=memused%> MiB / <%=totalram%> MiB</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<% if totalswap > 0 then %>
|
||||
<tr>
|
||||
<th>Swap:</th>
|
||||
<td><%=usedswap%> MiB / <%=totalswap%> MiB</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<th>Uptime:</th>
|
||||
<td><%=date_format(sinfo.uptime)%></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<ul>
|
||||
<%
|
||||
local nodes = dsp.node("niu", "system").nodes
|
||||
local function cmp(a, b)
|
||||
return (nodes[a].order or 100) < (nodes[b].order or 100)
|
||||
end
|
||||
for k, v in utl.spairs(nodes, cmp) do
|
||||
%>
|
||||
<li><a href="<%=dsp.build_url("niu", "system", k)%>"><%=v.title%></a></li>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</ul>
|
||||
<br />
|
Loading…
Reference in a new issue