diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-10-08 10:25:52 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-10-08 10:25:52 +0000 |
commit | a037d9438357a30e443b5b6ee84abe936d5255f1 (patch) | |
tree | 5ae0b5c7957d4cfad37d2d25f1a317aa103534b1 /libs/core/luasrc | |
parent | 740bb20850378d5f3c3abd4cbe35720174d2c5e5 (diff) |
libs/core: luci.model.network: implement contains_inteface(), fix bugs
Diffstat (limited to 'libs/core/luasrc')
-rw-r--r-- | libs/core/luasrc/model/network.lua | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/libs/core/luasrc/model/network.lua b/libs/core/luasrc/model/network.lua index 4e669f307f..3a7e38a03d 100644 --- a/libs/core/luasrc/model/network.lua +++ b/libs/core/luasrc/model/network.lua @@ -17,7 +17,8 @@ limitations under the License. ]]-- -local type, pairs, ipairs, table = type, pairs, ipairs, table +local type, pairs, ipairs, table, i18n + = type, pairs, ipairs, table, luci.i18n local lmo = require "lmo" local nxo = require "nixio" @@ -206,7 +207,7 @@ end function network.add_interface(self, ifname) if type(ifname) ~= "string" then - ifname = ifname:ifname() + ifname = ifname:name() end if ifs[ifname] then self:ifname(ub:list((self:ifname() or ''), ifname)) @@ -215,7 +216,7 @@ end function network.del_interface(self, ifname) if type(ifname) ~= "string" then - ifname = ifname:ifname() + ifname = ifname:name() end self:ifname(ub:list((self:ifname() or ''), nil, ifname)) end @@ -234,14 +235,14 @@ function network.get_interfaces(self) return ifaces end -function contains_interface(self, iface) +function network.contains_interface(self, iface) local i local ifaces = ub:list( (self:ifname() or '') .. ' ' .. (self:device() or '') ) if type(iface) ~= "string" then - iface = iface:ifname() + iface = iface:name() end for _, i in ipairs(ifaces) do @@ -279,6 +280,19 @@ function interface.type(self) end end +function interface.get_type_i18n(self) + local x = self:type() + if x == "wifi" then + return i18n.translate("a_s_if_wifidev", "Wireless Adapter") + elseif x == "bridge" then + return i18n.translate("a_s_if_bridge", "Bridge") + elseif x == "switch" then + return i18n.translate("a_s_if_ethswitch", "Ethernet Switch") + else + return i18n.translate("a_s_if_ethdev", "Ethernet Adapter") + end +end + function interface.ports(self) if self.br then local iface |