diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-10-31 18:46:51 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-11-01 12:03:33 +0100 |
commit | 1ca168c2e9fba09e30b6800b4f0f9e537616d09f (patch) | |
tree | e9b1ed58bda7b9c835f764f52f05848ac42113ed /modules/luci-mod-network/luasrc | |
parent | 790005cdfa34cd1d0a730361e546d2c50616053f (diff) |
luci-mod-network: use declarative dependencies in controller
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-network/luasrc')
-rw-r--r-- | modules/luci-mod-network/luasrc/controller/admin/network.lua | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/modules/luci-mod-network/luasrc/controller/admin/network.lua b/modules/luci-mod-network/luasrc/controller/admin/network.lua index a2ff215480..9f6a568b07 100644 --- a/modules/luci-mod-network/luasrc/controller/admin/network.lua +++ b/modules/luci-mod-network/luasrc/controller/admin/network.lua @@ -5,36 +5,15 @@ module("luci.controller.admin.network", package.seeall) function index() - local uci = require("luci.model.uci").cursor() local page -- if page.inreq then - local has_switch = false - - uci:foreach("network", "switch", - function(s) - has_switch = true - return false - end) - - if has_switch then - entry({"admin", "network", "switch"}, view("network/switch"), _("Switch"), 20) - end - - - local has_wifi = false - - uci:foreach("wireless", "wifi-device", - function(s) - has_wifi = true - return false - end) - - if has_wifi then - page = entry({"admin", "network", "wireless"}, view("network/wireless"), _('Wireless'), 15) - page.leaf = true - end + page = entry({"admin", "network", "switch"}, view("network/switch"), _("Switch"), 20) + page.uci_depends = { network = { ["@switch[0]"] = "switch" } } + page = entry({"admin", "network", "wireless"}, view("network/wireless"), _('Wireless'), 15) + page.uci_depends = { wireless = { ["@wifi-device[0]"] = "wifi-device" } } + page.leaf = true page = entry({"admin", "network", "iface_down"}, post("iface_down"), nil) page.leaf = true @@ -43,18 +22,17 @@ function index() page.leaf = true page.subindex = true - - if nixio.fs.access("/etc/config/dhcp") then - page = node("admin", "network", "dhcp") - page.target = view("network/dhcp") - page.title = _("DHCP and DNS") - page.order = 30 - - page = node("admin", "network", "hosts") - page.target = view("network/hosts") - page.title = _("Hostnames") - page.order = 40 - end + page = node("admin", "network", "dhcp") + page.uci_depends = { dhcp = true } + page.target = view("network/dhcp") + page.title = _("DHCP and DNS") + page.order = 30 + + page = node("admin", "network", "hosts") + page.uci_depends = { dhcp = true } + page.target = view("network/hosts") + page.title = _("Hostnames") + page.order = 40 page = node("admin", "network", "routes") page.target = view("network/routes") |