NIU: Fixes, System

This commit is contained in:
Steven Barth 2009-10-31 17:27:07 +00:00
parent bd43ccc886
commit b2671410bf
5 changed files with 121 additions and 2 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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>