From: Steven Barth Date: Sat, 14 Nov 2009 13:41:37 +0000 (+0000) Subject: NIU: X-Git-Tag: 0.10.0~958 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=730a9b6f69ecd1ce26b0e1c9bcd51ccf42f56f31;p=oweals%2Fluci.git NIU: Redesign dashboard Level 1 Network / System status on dashboard Rework "LAN IP has changed" warning Fix Routing table not hiding when requested --- diff --git a/modules/niu/htdocs/luci-static/resources/icons32/folder.png b/modules/niu/htdocs/luci-static/resources/icons32/folder.png new file mode 100644 index 000000000..6919f984f Binary files /dev/null and b/modules/niu/htdocs/luci-static/resources/icons32/folder.png differ diff --git a/modules/niu/htdocs/luci-static/resources/icons32/network-workgroup.png b/modules/niu/htdocs/luci-static/resources/icons32/network-workgroup.png new file mode 100644 index 000000000..860ffb95e Binary files /dev/null and b/modules/niu/htdocs/luci-static/resources/icons32/network-workgroup.png differ diff --git a/modules/niu/htdocs/luci-static/resources/icons32/preferences-system.png b/modules/niu/htdocs/luci-static/resources/icons32/preferences-system.png new file mode 100644 index 000000000..2afbd23cc Binary files /dev/null and b/modules/niu/htdocs/luci-static/resources/icons32/preferences-system.png differ diff --git a/modules/niu/htdocs/luci-static/resources/niu.css b/modules/niu/htdocs/luci-static/resources/niu.css new file mode 100644 index 000000000..6f895c957 --- /dev/null +++ b/modules/niu/htdocs/luci-static/resources/niu.css @@ -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; +} \ No newline at end of file diff --git a/modules/niu/luasrc/controller/niu/dashboard.lua b/modules/niu/luasrc/controller/niu/dashboard.lua index f6c893980..bd4875cb9 100644 --- a/modules/niu/luasrc/controller/niu/dashboard.lua +++ b/modules/niu/luasrc/controller/niu/dashboard.lua @@ -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 diff --git a/modules/niu/luasrc/controller/niu/network.lua b/modules/niu/luasrc/controller/niu/network.lua index c90662b6e..9301e2502 100644 --- a/modules/niu/luasrc/controller/niu/network.lua +++ b/modules/niu/luasrc/controller/niu/network.lua @@ -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) diff --git a/modules/niu/luasrc/controller/niu/system.lua b/modules/niu/luasrc/controller/niu/system.lua index 5ffed306b..2adf1d762 100644 --- a/modules/niu/luasrc/controller/niu/system.lua +++ b/modules/niu/luasrc/controller/niu/system.lua @@ -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() diff --git a/modules/niu/luasrc/view/niu/dashboard.htm b/modules/niu/luasrc/view/niu/dashboard.htm index cdd65663f..7c387edd2 100644 --- a/modules/niu/luasrc/view/niu/dashboard.htm +++ b/modules/niu/luasrc/view/niu/dashboard.htm @@ -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 %> -
- <%=v.title%> - <% - tpl.render(v.dbtemplate) - %> +
+ style="background-image: url(<%=resource%>/<%=v.niu_dbicon%>)"<% end %>><%=v.title%> + <% if v.niu_dbtemplate then tpl.render(v.niu_dbtemplate) end %> + <% if v.niu_dbtasks then %> +

Tasks:

+
    + <% + 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 + %> +
  • "><%=v2.title%>
  • + <% + end + %> +
+ <% end %>
<% end diff --git a/modules/niu/luasrc/view/niu/network.htm b/modules/niu/luasrc/view/niu/network.htm index 864471231..0e057f199 100644 --- a/modules/niu/luasrc/view/niu/network.htm +++ b/modules/niu/luasrc/view/niu/network.htm @@ -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 -%> -
Status:
- -<% -for _, v in ipairs(nws) do if v[".name"] ~= "loopback" then -%> - -<% end end %> -
<%=v[".name"]%><%=v.ipaddr%>
-
- \ No newline at end of file + + +<% if wanon and wanon ~= "none" then %> + +<% if wanup then %> + + +<% else %> + + +<% end %> + + +<% end %> + +<% if wanul and wandl then %> + + + +<% end %> + + + + + +<% if arps then %> + + + +<% end %> + +
Uplink Address<%=wanip%> +Uplinkoffline +
Uplink Traffic +<%=("%.2f"):format(wandl)%> GB⇓ <%=("%.2f"):format(wanul)%> GB⇑ +
Local Address +<%=uci.inst_state:get("network", "lan", "ipaddr")%> +
Active IP-Devices<%=arps%><% if leasefn then %> +(<%=leasefn%> assigned) +<% end %>
+
\ No newline at end of file diff --git a/modules/niu/luasrc/view/niu/network/rtable.htm b/modules/niu/luasrc/view/niu/network/rtable.htm index 4452a87db..412baa166 100644 --- a/modules/niu/luasrc/view/niu/network/rtable.htm +++ b/modules/niu/luasrc/view/niu/network/rtable.htm @@ -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 -%> diff --git a/modules/niu/luasrc/view/niu/network/warn_ip_change.htm b/modules/niu/luasrc/view/niu/network/warn_ip_change.htm index b5ebdd73c..9b41372bf 100644 --- a/modules/niu/luasrc/view/niu/network/warn_ip_change.htm +++ b/modules/niu/luasrc/view/niu/network/warn_ip_change.htm @@ -1,2 +1,11 @@ -Warning!
-Device IP has changed.
\ No newline at end of file +<% +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") +%> + +
Warning! The device IP-address has been changed.
+The router will be available in a few seconds at <%=url%>
+
\ No newline at end of file diff --git a/modules/niu/luasrc/view/niu/system.htm b/modules/niu/luasrc/view/niu/system.htm index 0f955d7bb..c702214e1 100644 --- a/modules/niu/luasrc/view/niu/system.htm +++ b/modules/niu/luasrc/view/niu/system.htm @@ -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 %> -
Status:
- +
+ + + + - - + + + + +<% if totalswap > 0 then %> - - + + + +<% end %> + + + +
Load:<%=load1%>% / <%=load15%>%
System Load<%=load1%> %Memory:<%=memused%> MiB / <%=totalram%> MiB
Uptime<%=days%>d, <%=hour%>:<%=mins%>Swap:<%=usedswap%> MiB / <%=totalswap%> MiB
Uptime:<%=date_format(sinfo.uptime)%>
-
- \ No newline at end of file +
\ No newline at end of file