diff options
-rw-r--r-- | modules/niu/luasrc/controller/niu/network.lua | 3 | ||||
-rw-r--r-- | modules/niu/luasrc/controller/niu/system.lua | 23 | ||||
-rw-r--r-- | modules/niu/luasrc/model/cbi/niu/system/general.lua | 17 | ||||
-rw-r--r-- | modules/niu/luasrc/model/cbi/niu/system/general1.lua | 45 | ||||
-rw-r--r-- | modules/niu/luasrc/view/niu/system.htm | 35 |
5 files changed, 121 insertions, 2 deletions
diff --git a/modules/niu/luasrc/controller/niu/network.lua b/modules/niu/luasrc/controller/niu/network.lua index 41da30a37..cafed2567 100644 --- a/modules/niu/luasrc/controller/niu/network.lua +++ b/modules/niu/luasrc/controller/niu/network.lua @@ -16,8 +16,7 @@ local req = require module "luci.controller.niu.network" function index() - entry({"niu", "network"}, alias("admin", "network"), "Network") - .dbtemplate = "niu/network" + entry({"niu", "network"}, nil, "Network").dbtemplate = "niu/network" entry({"niu", "network", "lan"}, cbi("niu/network/lan", {on_success_to={"niu"}}), "Configure LAN", 10) diff --git a/modules/niu/luasrc/controller/niu/system.lua b/modules/niu/luasrc/controller/niu/system.lua new file mode 100644 index 000000000..bb78edf08 --- /dev/null +++ b/modules/niu/luasrc/controller/niu/system.lua @@ -0,0 +1,23 @@ +--[[ +LuCI - Lua Development Framework + +Copyright 2009 Steven Barth <steven@midlink.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +local req = require +module "luci.controller.niu.system" + +function index() + entry({"niu", "system"}, nil, "System").dbtemplate = "niu/system" + + entry({"niu", "system", "general"}, + cbi("niu/system/general", {on_success_to={"niu"}}), "General", 10) +end diff --git a/modules/niu/luasrc/model/cbi/niu/system/general.lua b/modules/niu/luasrc/model/cbi/niu/system/general.lua new file mode 100644 index 000000000..df438e8b5 --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/system/general.lua @@ -0,0 +1,17 @@ +local cursor = require "luci.model.uci".cursor() +local d = Delegator() +d.allow_finish = true +d.allow_back = true +d.allow_cancel = true + +d:add("general1", load("niu/system/general1")) + +function d.on_cancel() + cursor:revert("system") +end + +function d.on_done() + cursor:commit("system") +end + +return d
\ No newline at end of file diff --git a/modules/niu/luasrc/model/cbi/niu/system/general1.lua b/modules/niu/luasrc/model/cbi/niu/system/general1.lua new file mode 100644 index 000000000..532583828 --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/system/general1.lua @@ -0,0 +1,45 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth <steven@midlink.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +local fs = require "nixio.fs" +local i18n = require "luci.i18n" +local util = require "luci.util" +local config = require "luci.config" + +m = Map("system", translate("System")) + +s = m:section(TypedSection, "system", "") +s.anonymous = true +s.addremove = false + +hn = s:option(Value, "hostname", translate("Hostname")) + + + +m2 = Map("luci", translate("Web <abbr title=\"User Interface\">UI</abbr>")) + + +c = m2:section(NamedSection, "main", "core") + +l = c:option(ListValue, "lang", translate("Language")) +l:value("auto") + +local i18ndir = i18n.i18ndir .. "default." +for k, v in util.kspairs(config.languages) do + local file = i18ndir .. k:gsub("_", "-") + if k:sub(1, 1) ~= "." and fs.access(file .. ".lmo") then + l:value(k, v) + end +end +return m, m2 diff --git a/modules/niu/luasrc/view/niu/system.htm b/modules/niu/luasrc/view/niu/system.htm new file mode 100644 index 000000000..0f955d7bb --- /dev/null +++ b/modules/niu/luasrc/view/niu/system.htm @@ -0,0 +1,35 @@ +<% +local dsp = require "luci.dispatcher" +local utl = require "luci.util" +local nxo = require "nixio" +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 +%> +<div>Status:</div> +<table> +<tr> +<th>System Load</th> +<td><%=load1%> %</td> +</tr> +<tr> +<th>Uptime</th> +<td><%=days%>d, <%=hour%>:<%=mins%></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>
\ No newline at end of file |