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)
|
nw.init(m.uci)
|
||||||
fw.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 = m:section(NamedSection, arg[1], "interface", translate("Common Configuration"))
|
||||||
s.addremove = false
|
s.addremove = false
|
||||||
|
|
||||||
|
@ -107,7 +112,15 @@ function ifname_single.write(self, s, val)
|
||||||
for _, i in ipairs(n:get_interfaces()) do
|
for _, i in ipairs(n:get_interfaces()) do
|
||||||
n:del_interface(i)
|
n:del_interface(i)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ $Id$
|
||||||
|
|
||||||
local wa = require "luci.tools.webadmin"
|
local wa = require "luci.tools.webadmin"
|
||||||
local nw = require "luci.model.network"
|
local nw = require "luci.model.network"
|
||||||
local ww = require "luci.model.wireless"
|
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
|
||||||
arg[1] = arg[1] or ""
|
arg[1] = arg[1] or ""
|
||||||
|
@ -31,19 +30,15 @@ m:chain("network")
|
||||||
local ifsection
|
local ifsection
|
||||||
|
|
||||||
function m.on_commit(map)
|
function m.on_commit(map)
|
||||||
nw.init(map.uci)
|
local wnet = nw:get_wifinet(arg[2])
|
||||||
ww.init(map.uci)
|
|
||||||
|
|
||||||
local wnet = ww:get_network(arg[2])
|
|
||||||
if ifsection and wnet then
|
if ifsection and wnet then
|
||||||
ifsection.section = wnet.sid
|
ifsection.section = wnet.sid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nw.init(m.uci)
|
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)
|
-- redirect to overview page if network does not exist anymore (e.g. after a revert)
|
||||||
if not wnet then
|
if not wnet then
|
||||||
|
@ -51,7 +46,7 @@ if not wnet then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
m.title = ww:get_i18n(wnet)
|
m.title = wnet:get_i18n()
|
||||||
|
|
||||||
|
|
||||||
local iw = luci.sys.wifi.getiwinfo(arg[1])
|
local iw = luci.sys.wifi.getiwinfo(arg[1])
|
||||||
|
@ -276,9 +271,6 @@ end
|
||||||
|
|
||||||
----------------------- Interface -----------------------
|
----------------------- Interface -----------------------
|
||||||
|
|
||||||
local wnet = ww:get_network(arg[2])
|
|
||||||
|
|
||||||
if wnet then
|
|
||||||
s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
|
s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
|
||||||
ifsection = s
|
ifsection = s
|
||||||
s.addremove = false
|
s.addremove = false
|
||||||
|
@ -601,7 +593,8 @@ if wnet then
|
||||||
port.rmempty = true
|
port.rmempty = true
|
||||||
|
|
||||||
key = s:taboption("encryption", Value, "key", translate("Key"))
|
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", "psk")
|
||||||
key:depends("encryption", "psk2")
|
key:depends("encryption", "psk2")
|
||||||
key:depends("encryption", "psk+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="wpa2"})
|
||||||
password:depends({mode="sta", eap_type="ttls", encryption="wpa"})
|
password:depends({mode="sta", eap_type="ttls", encryption="wpa"})
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
|
@ -14,7 +14,6 @@ $Id$
|
||||||
|
|
||||||
local nw = require "luci.model.network"
|
local nw = require "luci.model.network"
|
||||||
local fw = require "luci.model.firewall"
|
local fw = require "luci.model.firewall"
|
||||||
local wl = require "luci.model.wireless"
|
|
||||||
local uci = require "luci.model.uci".cursor()
|
local uci = require "luci.model.uci".cursor()
|
||||||
local http = require "luci.http"
|
local http = require "luci.http"
|
||||||
|
|
||||||
|
@ -34,7 +33,6 @@ end
|
||||||
|
|
||||||
nw.init(uci)
|
nw.init(uci)
|
||||||
fw.init(uci)
|
fw.init(uci)
|
||||||
wl.init(uci)
|
|
||||||
|
|
||||||
m.hidden = {
|
m.hidden = {
|
||||||
device = http.formvalue("device"),
|
device = http.formvalue("device"),
|
||||||
|
@ -145,14 +143,15 @@ function attachnet.parse(self, section)
|
||||||
if not net then
|
if not net then
|
||||||
self.error = { [section] = "missing" }
|
self.error = { [section] = "missing" }
|
||||||
else
|
else
|
||||||
local wdev = wl:get_device(m.hidden.device)
|
local wdev = nw:get_wifidev(m.hidden.device)
|
||||||
wdev:disabled(false)
|
|
||||||
wdev:channel(m.hidden.channel)
|
wdev:set("disabled", false)
|
||||||
|
wdev:set("channel", m.hidden.channel)
|
||||||
|
|
||||||
if replace:formvalue(section) then
|
if replace:formvalue(section) then
|
||||||
local n
|
local n
|
||||||
for _, n in ipairs(wdev:get_networks()) do
|
for _, n in ipairs(wdev:get_wifinets()) do
|
||||||
wl:del_network(n:name())
|
wdev:del_wifinet(n)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -177,8 +176,7 @@ function attachnet.parse(self, section)
|
||||||
wconf.bssid = m.hidden.bssid
|
wconf.bssid = m.hidden.bssid
|
||||||
end
|
end
|
||||||
|
|
||||||
local wnet = wl:add_network(wconf)
|
local wnet = wdev:add_wifinet(wconf)
|
||||||
|
|
||||||
if wnet then
|
if wnet then
|
||||||
if zone then
|
if zone then
|
||||||
fw:del_network(net:name())
|
fw:del_network(net:name())
|
||||||
|
|
Loading…
Reference in a new issue