summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-mini/luasrc
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-17 00:29:13 +0000
committerSteven Barth <steven@midlink.org>2008-08-17 00:29:13 +0000
commit746fa9df8f3d3443d82cd26d6717e7b5cf3dc8c1 (patch)
treef4790fa01e38bf72451faa722d349b8541820108 /modules/admin-mini/luasrc
parent7d08bec3ae84c79c17718cf794427fef7af37085 (diff)
modules/admin-mini: General UI improvements
Diffstat (limited to 'modules/admin-mini/luasrc')
-rw-r--r--modules/admin-mini/luasrc/controller/mini/system.lua18
-rw-r--r--modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua38
-rw-r--r--modules/admin-mini/luasrc/model/cbi/mini/passwd.lua43
-rw-r--r--modules/admin-mini/luasrc/view/mini/passwd.htm49
4 files changed, 79 insertions, 69 deletions
diff --git a/modules/admin-mini/luasrc/controller/mini/system.lua b/modules/admin-mini/luasrc/controller/mini/system.lua
index 255e26f65..be6cdb6b5 100644
--- a/modules/admin-mini/luasrc/controller/mini/system.lua
+++ b/modules/admin-mini/luasrc/controller/mini/system.lua
@@ -21,7 +21,7 @@ function index()
entry({"mini", "system"}, alias("mini", "system", "index"), i18n("system"), 40)
entry({"mini", "system", "index"}, cbi("mini/system"), i18n("general"), 1)
- entry({"mini", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 10)
+ entry({"mini", "system", "passwd"}, form("mini/passwd"), i18n("a_s_changepw"), 10)
entry({"mini", "system", "backup"}, call("action_backup"), i18n("a_s_backup"), 80)
entry({"mini", "system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 90)
entry({"mini", "system", "reboot"}, call("action_reboot"), i18n("reboot"), 100)
@@ -111,22 +111,6 @@ function action_upgrade()
luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail})
end
-function action_passwd()
- local p1 = luci.http.formvalue("pwd1")
- local p2 = luci.http.formvalue("pwd2")
- local stat = nil
-
- if p1 or p2 then
- if p1 == p2 then
- stat = luci.sys.user.setpasswd("root", p1)
- else
- stat = 10
- end
- end
-
- luci.template.render("mini/passwd", {stat=stat})
-end
-
function _keep_pattern()
local kpattern = ""
local files = luci.model.uci.get_all("luci", "flash_keep")
diff --git a/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua b/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua
index 3d26d6a9d..85b2c86aa 100644
--- a/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua
+++ b/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua
@@ -14,6 +14,7 @@ $Id$
]]--
require("luci.model.uci")
require("luci.sys")
+require("luci.tools.webadmin")
m = Map("dhcp", "DHCP")
@@ -21,7 +22,7 @@ s = m:section(TypedSection, "dhcp", "DHCP-Server")
s.anonymous = true
s:depends("interface", "lan")
-enable = s:option(ListValue, "ignore", "", "")
+enable = s:option(ListValue, "ignore", translate("enable"), "")
enable:value(0, translate("enable"))
enable:value(1, translate("disable"))
@@ -52,9 +53,40 @@ time = s:option(Value, "leasetime")
time:depends("ignore", "0")
time.rmempty = true
-m2 = Map("luci_ethers", translate("luci_ethers"))
-s = m2:section(TypedSection, "static_lease", "")
+
+m2 = Map("luci_ethers", translate("dhcp_leases"))
+
+local leasefn, leasefp, leases
+luci.model.uci.foreach("dhcp", "dnsmasq",
+ function(section)
+ leasefn = section.leasefile
+ end
+)
+local leasefp = leasefn and luci.fs.access(leasefn) and io.lines(leasefn)
+if leasefp then
+ leases = {}
+ for lease in leasefp do
+ table.insert(leases, luci.util.split(lease, " "))
+ end
+end
+
+if leases then
+ v = m2:section(Table, leases, translate("dhcp_leases_active"))
+ ip = v:option(DummyValue, 3, translate("ipaddress"))
+
+ mac = v:option(DummyValue, 2, translate("macaddress"))
+
+ ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
+ function ltime.cfgvalue(self, ...)
+ local value = DummyValue.cfgvalue(self, ...)
+ return luci.tools.webadmin.date_format(
+ os.difftime(tonumber(value), os.time())
+ )
+ end
+end
+
+s = m2:section(TypedSection, "static_lease", translate("luci_ethers"))
s.addremove = true
s.anonymous = true
s.template = "cbi/tblsection"
diff --git a/modules/admin-mini/luasrc/model/cbi/mini/passwd.lua b/modules/admin-mini/luasrc/model/cbi/mini/passwd.lua
new file mode 100644
index 000000000..8ff18cb5c
--- /dev/null
+++ b/modules/admin-mini/luasrc/model/cbi/mini/passwd.lua
@@ -0,0 +1,43 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+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$
+]]--
+f = SimpleForm("password", translate("a_s_changepw"), translate("a_s_changepw1"))
+
+pw1 = f:field(Value, "pw1", translate("password"))
+pw1.password = true
+
+pw2 = f:field(Value, "pw2", translate("confirmation"))
+pw2.password = true
+
+function pw2.validate(self, value, section)
+ return pw1:formvalue(section) == value and value
+end
+
+function f.handle(self, state, data)
+ if state == FORM_VALID then
+ local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
+
+ if stat then
+ f.message = translate("a_s_changepw_changed")
+ else
+ f.errmessage = translate("unknownerror")
+ end
+
+ data.pw1 = nil
+ data.pw2 = nil
+ end
+ return true
+end
+
+return f \ No newline at end of file
diff --git a/modules/admin-mini/luasrc/view/mini/passwd.htm b/modules/admin-mini/luasrc/view/mini/passwd.htm
deleted file mode 100644
index ece9a5947..000000000
--- a/modules/admin-mini/luasrc/view/mini/passwd.htm
+++ /dev/null
@@ -1,49 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-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$
-
--%>
-<%+header%>
-<h1><%:system%></h1>
-<h2><%:a_s_changepw%></h2>
-<p><%:a_s_changepw1%></p>
-<div><br />
-<% if stat then %>
- <% if stat == 0 then %>
- <code><%:a_s_changepw_changed%>!</code>
- <% elseif stat == 10 then %>
- <code class="error"><%:a_s_changepw_nomatch%>!</code>
- <% else %>
- <code class="error"><%:unknownerror%>!</code>
- <% end %>
-<% end %>
-<% if not stat or stat == 10 then %>
- <form method="post" action="<%=REQUEST_URI%>">
- <div class="cbi-section-node">
- <div class="cbi-value">
- <div class="cbi-value-title"><%:password%></div>
- <div class="cbi-value-field"><input type="password" name="pwd1" /></div>
- </div>
- <div class="cbi-value">
- <div class="cbi-value-title"><%:confirmation%></div>
- <div class="cbi-value-field"><input type="password" name="pwd2" /></div>
- </div>
- <br />
- <div>
- <input type="submit" value="<%:save%>" />
- <input type="reset" value="<%:reset%>" />
- </div>
- </div>
- </form>
-<% end %>
-</div>
-<%+footer%> \ No newline at end of file