From 8644cf317b54f24de19ca3449a5e41c7168d6bd7 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 7 Mar 2010 16:40:50 +0000 Subject: [PATCH] luci-0.9: only show wireless and switch config if hardware is present --- .../luasrc/controller/admin/network.lua | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua index 08a5dd0ef..8ce44e74e 100644 --- a/modules/admin-full/luasrc/controller/admin/network.lua +++ b/modules/admin-full/luasrc/controller/admin/network.lua @@ -17,6 +17,22 @@ function index() require("luci.i18n") local uci = require("luci.model.uci").cursor() 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") page.target = alias("admin", "network", "network") @@ -24,24 +40,28 @@ function index() page.order = 50 page.index = true - local page = node("admin", "network", "vlan") - page.target = cbi("admin_network/vlan") - page.title = i18n("a_n_switch") - page.order = 20 - - local page = entry({"admin", "network", "wireless"}, arcombine(cbi("admin_network/wireless"), cbi("admin_network/wifi")), i18n("wifi"), 15) - page.i18n = "wifi" - page.leaf = true - page.subindex = true - - uci:foreach("wireless", "wifi-device", - function (section) - local ifc = section[".name"] - entry({"admin", "network", "wireless", ifc}, - true, - ifc:upper()).i18n = "wifi" - end - ) + if has_switch then + local page = node("admin", "network", "vlan") + page.target = cbi("admin_network/vlan") + page.title = i18n("a_n_switch") + page.order = 20 + end + + if has_wifi then + local page = entry({"admin", "network", "wireless"}, arcombine(cbi("admin_network/wireless"), cbi("admin_network/wifi")), i18n("wifi"), 15) + page.i18n = "wifi" + page.leaf = true + page.subindex = true + + uci:foreach("wireless", "wifi-device", + function (section) + local ifc = section[".name"] + entry({"admin", "network", "wireless", ifc}, + true, + ifc:upper()).i18n = "wifi" + end + ) + end local page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), i18n("interfaces", "Schnittstellen"), 10) page.leaf = true -- 2.25.1