luci-mod-network: convert menu nodes to JSON

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2019-12-06 22:59:33 +01:00
parent 566a99591b
commit 5448a10e30
2 changed files with 130 additions and 57 deletions

View file

@ -4,63 +4,6 @@
module("luci.controller.admin.network", package.seeall)
function index()
local page
-- if page.inreq then
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", "remote_addr"}, call("remote_addr"), nil)
page.leaf = true
page = entry({"admin", "network", "network"}, view("network/interfaces"), _("Interfaces"), 10)
page.leaf = true
page.subindex = true
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")
page.title = _("Static Routes")
page.order = 50
page = node("admin", "network", "diagnostics")
page.target = template("admin_network/diagnostics")
page.title = _("Diagnostics")
page.order = 60
page = entry({"admin", "network", "diag_ping"}, post("diag_ping"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_nslookup"}, post("diag_nslookup"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_traceroute"}, post("diag_traceroute"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_ping6"}, post("diag_ping6"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_traceroute6"}, post("diag_traceroute6"), nil)
page.leaf = true
-- end
end
local function addr2dev(addr, src)
local ip = require "luci.ip"
local route = ip.route(addr, src)

View file

@ -0,0 +1,130 @@
{
"admin/network/switch": {
"title": "Switch",
"order": 20,
"action": {
"type": "view",
"path": "network/switch"
},
"depends": {
"fs": { "/sbin/swconfig": "executable" },
"uci": { "network": { "@switch": true } }
}
},
"admin/network/wireless": {
"title": "Wireless",
"order": 15,
"action": {
"type": "view",
"path": "network/wireless"
},
"depends": {
"uci": { "wireless": { "@wifi-device": true } }
}
},
"admin/network/remote_addr/*": {
"action": {
"type": "call",
"module": "luci.controller.admin.network",
"function": "remote_addr"
}
},
"admin/network/network": {
"title": "Interfaces",
"order": 10,
"action": {
"type": "view",
"path": "network/interfaces"
}
},
"admin/network/dhcp": {
"title": "DHCP and DNS",
"order": 30,
"action": {
"type": "view",
"path": "network/dhcp"
},
"depends": {
"uci": { "dhcp": true }
}
},
"admin/network/hosts": {
"title": "Hostnames",
"order": 40,
"action": {
"type": "view",
"path": "network/hosts"
},
"depends": {
"uci": { "dhcp": true }
}
},
"admin/network/routes": {
"title": "Static Routes",
"order": 50,
"action": {
"type": "view",
"path": "network/routes"
}
},
"admin/network/diagnostics": {
"title": "Diagnostics",
"order": 60,
"action": {
"type": "template",
"path": "admin_network/diagnostics"
}
},
"admin/network/diag_ping/*": {
"action": {
"post": true,
"type": "call",
"module": "luci.controller.admin.network",
"function": "diag_ping"
}
},
"admin/network/diag_nslookup/*": {
"action": {
"post": true,
"type": "call",
"module": "luci.controller.admin.network",
"function": "diag_nslookup"
}
},
"admin/network/diag_traceroute/*": {
"action": {
"post": true,
"type": "call",
"module": "luci.controller.admin.network",
"function": "diag_traceroute"
}
},
"admin/network/diag_ping6/*": {
"action": {
"post": true,
"type": "call",
"module": "luci.controller.admin.network",
"function": "diag_ping6"
}
},
"admin/network/diag_traceroute6/*": {
"action": {
"post": true,
"type": "call",
"module": "luci.controller.admin.network",
"function": "diag_traceroute6"
}
}
}