luci-0.9: only show wireless and switch config if hardware is present
This commit is contained in:
parent
bda9d81da7
commit
8644cf317b
1 changed files with 36 additions and 16 deletions
|
@ -17,6 +17,22 @@ function index()
|
||||||
require("luci.i18n")
|
require("luci.i18n")
|
||||||
local uci = require("luci.model.uci").cursor()
|
local uci = require("luci.model.uci").cursor()
|
||||||
local i18n = luci.i18n.translate
|
local i18n = luci.i18n.translate
|
||||||
|
local has_wifi = false
|
||||||
|
local has_switch = false
|
||||||
|
|
||||||
|
uci:foreach("wireless", "wifi-device",
|
||||||
|
function(s)
|
||||||
|
has_wifi = true
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
uci:foreach("network", "switch",
|
||||||
|
function(s)
|
||||||
|
has_switch = true
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
local page = node("admin", "network")
|
local page = node("admin", "network")
|
||||||
page.target = alias("admin", "network", "network")
|
page.target = alias("admin", "network", "network")
|
||||||
|
@ -24,24 +40,28 @@ function index()
|
||||||
page.order = 50
|
page.order = 50
|
||||||
page.index = true
|
page.index = true
|
||||||
|
|
||||||
local page = node("admin", "network", "vlan")
|
if has_switch then
|
||||||
page.target = cbi("admin_network/vlan")
|
local page = node("admin", "network", "vlan")
|
||||||
page.title = i18n("a_n_switch")
|
page.target = cbi("admin_network/vlan")
|
||||||
page.order = 20
|
page.title = i18n("a_n_switch")
|
||||||
|
page.order = 20
|
||||||
|
end
|
||||||
|
|
||||||
local page = entry({"admin", "network", "wireless"}, arcombine(cbi("admin_network/wireless"), cbi("admin_network/wifi")), i18n("wifi"), 15)
|
if has_wifi then
|
||||||
page.i18n = "wifi"
|
local page = entry({"admin", "network", "wireless"}, arcombine(cbi("admin_network/wireless"), cbi("admin_network/wifi")), i18n("wifi"), 15)
|
||||||
page.leaf = true
|
page.i18n = "wifi"
|
||||||
page.subindex = true
|
page.leaf = true
|
||||||
|
page.subindex = true
|
||||||
|
|
||||||
uci:foreach("wireless", "wifi-device",
|
uci:foreach("wireless", "wifi-device",
|
||||||
function (section)
|
function (section)
|
||||||
local ifc = section[".name"]
|
local ifc = section[".name"]
|
||||||
entry({"admin", "network", "wireless", ifc},
|
entry({"admin", "network", "wireless", ifc},
|
||||||
true,
|
true,
|
||||||
ifc:upper()).i18n = "wifi"
|
ifc:upper()).i18n = "wifi"
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
local page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), i18n("interfaces", "Schnittstellen"), 10)
|
local page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), i18n("interfaces", "Schnittstellen"), 10)
|
||||||
page.leaf = true
|
page.leaf = true
|
||||||
|
|
Loading…
Reference in a new issue