modules/admin-full: convert cbi maps to new network model
This commit is contained in:
parent
ba84656d6e
commit
185eacba4b
3 changed files with 397 additions and 394 deletions
|
@ -34,6 +34,11 @@ m:chain("wireless")
|
|||
nw.init(m.uci)
|
||||
fw.init(m.uci)
|
||||
|
||||
--function m.on_commit(map)
|
||||
-- nw.init(map.uci)
|
||||
-- fw.init(map.uci)
|
||||
--end
|
||||
|
||||
s = m:section(NamedSection, arg[1], "interface", translate("Common Configuration"))
|
||||
s.addremove = false
|
||||
|
||||
|
@ -107,7 +112,15 @@ function ifname_single.write(self, s, val)
|
|||
for _, i in ipairs(n:get_interfaces()) do
|
||||
n:del_interface(i)
|
||||
end
|
||||
n:add_interface(val)
|
||||
|
||||
for i in val:gmatch("%S+") do
|
||||
n:add_interface(i)
|
||||
|
||||
-- if this is not a bridge, only assign first interface
|
||||
if self.option == "ifname_single" then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ $Id$
|
|||
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local nw = require "luci.model.network"
|
||||
local ww = require "luci.model.wireless"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
arg[1] = arg[1] or ""
|
||||
|
@ -31,19 +30,15 @@ m:chain("network")
|
|||
local ifsection
|
||||
|
||||
function m.on_commit(map)
|
||||
nw.init(map.uci)
|
||||
ww.init(map.uci)
|
||||
|
||||
local wnet = ww:get_network(arg[2])
|
||||
local wnet = nw:get_wifinet(arg[2])
|
||||
if ifsection and wnet then
|
||||
ifsection.section = wnet.sid
|
||||
end
|
||||
end
|
||||
|
||||
nw.init(m.uci)
|
||||
ww.init(m.uci)
|
||||
|
||||
local wnet = ww:get_network(arg[2])
|
||||
local wnet = nw:get_wifinet(arg[2])
|
||||
|
||||
-- redirect to overview page if network does not exist anymore (e.g. after a revert)
|
||||
if not wnet then
|
||||
|
@ -51,7 +46,7 @@ if not wnet then
|
|||
return
|
||||
end
|
||||
|
||||
m.title = ww:get_i18n(wnet)
|
||||
m.title = wnet:get_i18n()
|
||||
|
||||
|
||||
local iw = luci.sys.wifi.getiwinfo(arg[1])
|
||||
|
@ -276,9 +271,6 @@ end
|
|||
|
||||
----------------------- Interface -----------------------
|
||||
|
||||
local wnet = ww:get_network(arg[2])
|
||||
|
||||
if wnet then
|
||||
s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
|
||||
ifsection = s
|
||||
s.addremove = false
|
||||
|
@ -601,7 +593,8 @@ if wnet then
|
|||
port.rmempty = true
|
||||
|
||||
key = s:taboption("encryption", Value, "key", translate("Key"))
|
||||
key:depends("encryption", "wep")
|
||||
key:depends("encryption", "wep-open")
|
||||
key:depends("encryption", "wep-shared")
|
||||
key:depends("encryption", "psk")
|
||||
key:depends("encryption", "psk2")
|
||||
key:depends("encryption", "psk+psk2")
|
||||
|
@ -664,6 +657,5 @@ if wnet then
|
|||
password:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
|
||||
password:depends({mode="sta", eap_type="ttls", encryption="wpa"})
|
||||
end
|
||||
end
|
||||
|
||||
return m
|
||||
|
|
|
@ -14,7 +14,6 @@ $Id$
|
|||
|
||||
local nw = require "luci.model.network"
|
||||
local fw = require "luci.model.firewall"
|
||||
local wl = require "luci.model.wireless"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local http = require "luci.http"
|
||||
|
||||
|
@ -34,7 +33,6 @@ end
|
|||
|
||||
nw.init(uci)
|
||||
fw.init(uci)
|
||||
wl.init(uci)
|
||||
|
||||
m.hidden = {
|
||||
device = http.formvalue("device"),
|
||||
|
@ -145,14 +143,15 @@ function attachnet.parse(self, section)
|
|||
if not net then
|
||||
self.error = { [section] = "missing" }
|
||||
else
|
||||
local wdev = wl:get_device(m.hidden.device)
|
||||
wdev:disabled(false)
|
||||
wdev:channel(m.hidden.channel)
|
||||
local wdev = nw:get_wifidev(m.hidden.device)
|
||||
|
||||
wdev:set("disabled", false)
|
||||
wdev:set("channel", m.hidden.channel)
|
||||
|
||||
if replace:formvalue(section) then
|
||||
local n
|
||||
for _, n in ipairs(wdev:get_networks()) do
|
||||
wl:del_network(n:name())
|
||||
for _, n in ipairs(wdev:get_wifinets()) do
|
||||
wdev:del_wifinet(n)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -177,8 +176,7 @@ function attachnet.parse(self, section)
|
|||
wconf.bssid = m.hidden.bssid
|
||||
end
|
||||
|
||||
local wnet = wl:add_network(wconf)
|
||||
|
||||
local wnet = wdev:add_wifinet(wconf)
|
||||
if wnet then
|
||||
if zone then
|
||||
fw:del_network(net:name())
|
||||
|
|
Loading…
Reference in a new issue