From: Jo-Philipp Wich Date: Thu, 8 Oct 2009 10:31:31 +0000 (+0000) Subject: modules/admin-full: use interface picker in iface config page X-Git-Tag: 0.10.0~1103 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=9ebb038a94f3d1ac6eb3737353e9a60744375e9e modules/admin-full: use interface picker in iface config page --- diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua index 3a6538c7b..6a56435ce 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua @@ -14,6 +14,7 @@ $Id$ ]]-- local fs = require "nixio.fs" +local nw = require "luci.model.network" local fw = require "luci.model.firewall" arg[1] = arg[1] or "" @@ -28,6 +29,7 @@ local has_ipv6 = fs.access("/proc/net/ipv6_route") m = Map("network", translate("interfaces"), translate("a_n_ifaces1")) m:chain("firewall") +nw.init(m.uci) fw.init(m.uci) s = m:section(NamedSection, arg[1], "interface") @@ -69,6 +71,9 @@ stp:depends("type", "1") stp.rmempty = true ifname_single = s:taboption("physical", Value, "ifname_single", translate("interface")) +ifname_single.template = "cbi/network_ifacelist" +ifname_single.widget = "radio" +ifname_single.nobridges = true ifname_single.rmempty = true ifname_single:depends("type", "") @@ -77,20 +82,23 @@ function ifname_single.cfgvalue(self, s) end function ifname_single.write(self, s, val) - self.map.uci:set("network", s, "ifname", val) + local n = nw:get_network(s) + if n then n:ifname(val) end end ifname_multi = s:taboption("physical", MultiValue, "ifname_multi", translate("interface")) +ifname_multi.template = "cbi/network_ifacelist" +ifname_multi.nobridges = true ifname_multi.widget = "checkbox" ifname_multi:depends("type", "1") ifname_multi.cfgvalue = ifname_single.cfgvalue ifname_multi.write = ifname_single.write -for i,d in ipairs(luci.sys.net.devices()) do - if d ~= "lo" then - ifname_single:value(d) - ifname_multi:value(d) +for _, d in ipairs(nw:get_interfaces()) do + if not d:is_bridge() then + ifname_single:value(d:name()) + ifname_multi:value(d:name()) end end