modules/admin-mini: Several tweaks, initial status page
[project/luci.git] / modules / admin-mini / luasrc / model / cbi / mini / dhcp.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15 require("luci.model.uci")
16 require("luci.sys")
17
18 m = Map("dhcp", "DHCP")
19
20 s = m:section(TypedSection, "dhcp", "DHCP-Server")
21 s.anonymous = true
22 s:depends("interface", "lan")
23
24 enable = s:option(ListValue, "ignore", "", "")
25 enable:value(0, translate("enable"))
26 enable:value(1, translate("disable"))
27
28 start = s:option(Value, "start", translate("m_n_d_firstaddress"))
29 start.rmempty = true
30 start:depends("ignore", "0")
31
32
33 limit = s:option(Value, "limit", translate("m_n_d_numleases"), "")
34 limit:depends("ignore", "0")
35
36 function limit.cfgvalue(self, section)
37         local value = Value.cfgvalue(self, section)
38         
39         if value then
40                 return tonumber(value) + 1
41         end 
42 end
43
44 function limit.write(self, section, value)
45         value = tonumber(value) - 1
46         return Value.write(self, section, value) 
47 end
48
49 limit.rmempty = true
50
51 time = s:option(Value, "leasetime")
52 time:depends("ignore", "0")
53 time.rmempty = true
54
55 m2 = Map("luci_ethers", translate("luci_ethers"))
56
57 s = m2:section(TypedSection, "static_lease", "")
58 s.addremove = true
59 s.anonymous = true
60 s.template = "cbi/tblsection"
61
62 s:option(Value, "macaddr", translate("macaddress"))
63 s:option(Value, "ipaddr", translate("ipaddress"))
64
65 return m, m2