luci-mod-status: convert menu nodes to JSON
authorJo-Philipp Wich <jo@mein.io>
Tue, 10 Dec 2019 07:49:24 +0000 (08:49 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 16 Dec 2019 17:07:18 +0000 (18:07 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-status/luasrc/controller/admin/status.lua
modules/luci-mod-status/root/usr/share/luci/menu.d/luci-mod-status.json [new file with mode: 0644]

index 6f84149223652a858fbf067f160a54e81dd80455..2684bdf715ac50e2583ae92f7c08db9dba36cf63 100644 (file)
@@ -4,30 +4,6 @@
 
 module("luci.controller.admin.status", package.seeall)
 
-function index()
-       local page
-
-       entry({"admin", "status", "overview"}, template("admin_status/index"), _("Overview"), 1)
-
-       entry({"admin", "status", "iptables"}, template("admin_status/iptables"), _("Firewall"), 2).leaf = true
-       entry({"admin", "status", "iptables_dump"}, call("dump_iptables")).leaf = true
-       entry({"admin", "status", "iptables_action"}, post("action_iptables")).leaf = true
-
-       entry({"admin", "status", "routes"}, template("admin_status/routes"), _("Routes"), 3)
-       entry({"admin", "status", "syslog"}, call("action_syslog"), _("System Log"), 4)
-       entry({"admin", "status", "dmesg"}, call("action_dmesg"), _("Kernel Log"), 5)
-       entry({"admin", "status", "processes"}, view("status/processes"), _("Processes"), 6)
-
-       entry({"admin", "status", "realtime"}, alias("admin", "status", "realtime", "load"), _("Realtime Graphs"), 7)
-
-       entry({"admin", "status", "realtime", "load"}, view("status/load"), _("Load"), 1)
-       entry({"admin", "status", "realtime", "bandwidth"}, view("status/bandwidth"), _("Traffic"), 2)
-       entry({"admin", "status", "realtime", "wireless"}, view("status/wireless"), _("Wireless"), 3).uci_depends = { wireless = true }
-       entry({"admin", "status", "realtime", "connections"}, view("status/connections"), _("Connections"), 4)
-
-       entry({"admin", "status", "nameinfo"}, call("action_nameinfo")).leaf = true
-end
-
 function action_syslog()
        local syslog = luci.sys.syslog()
        luci.template.render("admin_status/syslog", {syslog=syslog})
diff --git a/modules/luci-mod-status/root/usr/share/luci/menu.d/luci-mod-status.json b/modules/luci-mod-status/root/usr/share/luci/menu.d/luci-mod-status.json
new file mode 100644 (file)
index 0000000..03f7dce
--- /dev/null
@@ -0,0 +1,129 @@
+{
+       "admin/status/overview": {
+               "title": "Overview",
+               "order": 1,
+               "action": {
+                       "type": "template",
+                       "path": "admin_status/index"
+               }
+       },
+
+       "admin/status/iptables/*": {
+               "title": "Firewall",
+               "order": 2,
+               "action": {
+                       "type": "template",
+                       "path": "admin_status/iptables"
+               }
+       },
+
+       "admin/status/iptables_dump/*": {
+               "action": {
+                       "type": "call",
+                       "module": "luci.controller.admin.status",
+                       "function": "dump_iptables"
+               }
+       },
+
+       "admin/status/iptables_action/*": {
+               "action": {
+                       "type": "call",
+                       "module": "luci.controller.admin.status",
+                       "function": "action_iptables"
+               }
+       },
+
+       "admin/status/routes": {
+               "title": "Routes",
+               "order": 3,
+               "action": {
+                       "type": "template",
+                       "path": "admin_status/routes"
+               }
+       },
+
+       "admin/status/syslog": {
+               "title": "System Log",
+               "order": 4,
+               "action": {
+                       "type": "call",
+                       "module": "luci.controller.admin.status",
+                       "function": "action_syslog"
+               }
+       },
+
+       "admin/status/dmesg": {
+               "title": "Kernel Log",
+               "order": 5,
+               "action": {
+                       "type": "call",
+                       "module": "luci.controller.admin.status",
+                       "function": "action_dmesg"
+               }
+       },
+
+       "admin/status/processes": {
+               "title": "Processes",
+               "order": 6,
+               "action": {
+                       "type": "view",
+                       "path": "status/processes"
+               }
+       },
+
+       "admin/status/realtime": {
+               "title": "Realtime Graphs",
+               "order": 7,
+               "action": {
+                       "type": "alias",
+                       "path": "admin/status/realtime/load"
+               }
+       },
+
+       "admin/status/realtime/load": {
+               "title": "Load",
+               "order": 1,
+               "action": {
+                       "type": "view",
+                       "path": "status/load"
+               }
+       },
+
+       "admin/status/realtime/bandwidth": {
+               "title": "Traffic",
+               "order": 2,
+               "action": {
+                       "type": "view",
+                       "path": "status/bandwidth"
+               }
+       },
+
+       "admin/status/realtime/wireless": {
+               "title": "Wireless",
+               "order": 3,
+               "action": {
+                       "type": "view",
+                       "path": "status/wireless"
+               },
+               "depends": {
+                       "uci": { "wireless": { "@wifi-device": true } }
+               }
+       },
+
+       "admin/status/realtime/connections": {
+               "title": "Connections",
+               "order": 4,
+               "action": {
+                       "type": "view",
+                       "path": "status/connections"
+               }
+       },
+
+       "admin/status/nameinfo/*": {
+               "action": {
+                       "type": "call",
+                       "module": "luci.controller.admin.status",
+                       "function": "action_nameinfo"
+               }
+       }
+}