feb213c6e59cecef219c074c334fb8871fce28dc
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / network / lan.lua
1 local uci = require "luci.model.uci"
2 local cursor = uci.cursor()
3 local d = Delegator()
4 d.allow_finish = true
5 d.allow_back = true
6 d.allow_cancel = true
7
8 d:add("lan1", "niu/network/lan1")
9
10 function d.on_cancel()
11         cursor:revert("network")
12         cursor:revert("dhcp")
13 end
14
15 function d.on_done()
16         if uci.inst_state:get("network", "lan", "ipaddr") ~= cursor:get("network", "lan", "ipaddr") then
17                 local cs = uci.cursor_state()
18                 cs:set("network", "lan", "_ipchanged", "1")
19                 cs:save("network")
20         end
21
22         cursor:set("network", "lan", "type", "bridge")
23         cursor:commit("network")
24         cursor:commit("dhcp")
25 end
26
27 return d