luci-mod-system: convert menu controller to declarative JSON
authorJo-Philipp Wich <jo@mein.io>
Mon, 13 Apr 2020 16:42:32 +0000 (18:42 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 14 Apr 2020 15:05:29 +0000 (17:05 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-system/luasrc/controller/admin/system.lua [deleted file]
modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json [new file with mode: 0644]

diff --git a/modules/luci-mod-system/luasrc/controller/admin/system.lua b/modules/luci-mod-system/luasrc/controller/admin/system.lua
deleted file mode 100644 (file)
index 3563349..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
--- Licensed to the public under the Apache License 2.0.
-
-module("luci.controller.admin.system", package.seeall)
-
-function index()
-       entry({"admin", "system", "system"}, view("system/system"), _("System"), 1)
-
-       entry({"admin", "system", "admin"}, firstchild(), _("Administration"), 2)
-       entry({"admin", "system", "admin", "password"}, view("system/password"), _("Router Password"), 1)
-
-       entry({"admin", "system", "admin", "dropbear"}, view("system/dropbear"), _("SSH Access"), 2)
-               .uci_depends = { dropbear = true }
-
-       entry({"admin", "system", "admin", "sshkeys"}, view("system/sshkeys"), _("SSH-Keys"), 3)
-               .uci_depends = { dropbear = true }
-
-       entry({"admin", "system", "startup"}, view("system/startup"), _("Startup"), 45)
-       entry({"admin", "system", "crontab"}, view("system/crontab"), _("Scheduled Tasks"), 46)
-
-       entry({"admin", "system", "mounts"}, view("system/mounts"), _("Mount Points"), 50)
-               .file_depends = { "/sbin/block" }
-
-       entry({"admin", "system", "leds"}, view("system/leds"), _("LED Configuration"), 60)
-               .file_depends = { "/sys/class/leds" }
-
-       entry({"admin", "system", "flash"}, view("system/flash"), _("Backup / Flash Firmware"), 70)
-
-       entry({"admin", "system", "reboot"}, view("system/reboot"), _("Reboot"), 90)
-end
diff --git a/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json b/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json
new file mode 100644 (file)
index 0000000..4a65dec
--- /dev/null
@@ -0,0 +1,111 @@
+{
+       "admin/system/system": {
+               "title": "System",
+               "order": 1,
+               "action": {
+                       "type": "view",
+                       "path": "system/system"
+               }
+       },
+
+       "admin/system/admin": {
+               "title": "Administration",
+               "order": 2,
+               "action": {
+                       "type": "firstchild"
+               }
+       },
+
+       "admin/system/admin/password": {
+               "title": "Router Password",
+               "order": 1,
+               "action": {
+                       "type": "view",
+                       "path": "system/password"
+               }
+       },
+
+       "admin/system/admin/dropbear": {
+               "title": "SSH Access",
+               "order": 2,
+               "action": {
+                       "type": "view",
+                       "path": "system/dropbear"
+               },
+               "depends": {
+                       "uci": { "dropbear": true }
+               }
+       },
+
+       "admin/system/admin/sshkeys": {
+               "title": "SSH-Keys",
+               "order": 3,
+               "action": {
+                       "type": "view",
+                       "path": "system/sshkeys"
+               },
+               "depends": {
+                       "uci": { "dropbear": true }
+               }
+       },
+
+       "admin/system/startup": {
+               "title": "Startup",
+               "order": 45,
+               "action": {
+                       "type": "view",
+                       "path": "system/startup"
+               }
+       },
+
+       "admin/system/crontab": {
+               "title": "Scheduled Tasks",
+               "order": 46,
+               "action": {
+                       "type": "view",
+                       "path": "system/crontab"
+               }
+       },
+
+       "admin/system/mounts": {
+               "title": "Mount Points",
+               "order": 50,
+               "action": {
+                       "type": "view",
+                       "path": "system/mounts"
+               },
+               "depends": {
+                       "fs": { "/sbin/block": "executable" }
+               }
+       },
+
+       "admin/system/leds": {
+               "title": "LED Configuration",
+               "order": 60,
+               "action": {
+                       "type": "view",
+                       "path": "system/leds"
+               },
+               "depends": {
+                       "fs": { "/sys/class/leds": "directory" }
+               }
+       },
+
+       "admin/system/flash": {
+               "title": "Backup / Flash Firmware",
+               "order": 70,
+               "action": {
+                       "type": "view",
+                       "path": "system/flash"
+               }
+       },
+
+       "admin/system/reboot": {
+               "title": "Reboot",
+               "order": 90,
+               "action": {
+                       "type": "view",
+                       "path": "system/reboot"
+               }
+       }
+}