luci-base: convert menu nodes to JSON
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 16853bcd2e
)
This commit is contained in:
parent
ec50f8a784
commit
afad3ccf8f
3 changed files with 142 additions and 105 deletions
|
@ -3,85 +3,6 @@
|
|||
|
||||
module("luci.controller.admin.index", package.seeall)
|
||||
|
||||
function index()
|
||||
function toplevel_page(page, preflookup, preftarget)
|
||||
if preflookup and preftarget then
|
||||
if lookup(preflookup) then
|
||||
page.target = preftarget
|
||||
end
|
||||
end
|
||||
|
||||
if not page.target then
|
||||
page.target = firstchild()
|
||||
end
|
||||
end
|
||||
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
|
||||
local root = node()
|
||||
if not root.target then
|
||||
root.target = alias("admin")
|
||||
root.index = true
|
||||
end
|
||||
|
||||
local page = node("admin")
|
||||
|
||||
page.title = _("Administration")
|
||||
page.order = 10
|
||||
page.sysauth = "root"
|
||||
page.sysauth_authenticator = "htmlauth"
|
||||
page.ucidata = true
|
||||
page.index = true
|
||||
page.target = firstnode()
|
||||
|
||||
-- Empty menu tree to be populated by addons and modules
|
||||
|
||||
page = node("admin", "status")
|
||||
page.title = _("Status")
|
||||
page.order = 10
|
||||
page.index = true
|
||||
-- overview is from mod-admin-full
|
||||
toplevel_page(page, "admin/status/overview", alias("admin", "status", "overview"))
|
||||
|
||||
page = node("admin", "system")
|
||||
page.title = _("System")
|
||||
page.order = 20
|
||||
page.index = true
|
||||
-- system/system is from mod-admin-full
|
||||
toplevel_page(page, "admin/system/system", alias("admin", "system", "system"))
|
||||
|
||||
-- Only used if applications add items
|
||||
page = node("admin", "vpn")
|
||||
page.title = _("VPN")
|
||||
page.order = 30
|
||||
page.index = true
|
||||
toplevel_page(page, false, false)
|
||||
|
||||
-- Only used if applications add items
|
||||
page = node("admin", "services")
|
||||
page.title = _("Services")
|
||||
page.order = 40
|
||||
page.index = true
|
||||
toplevel_page(page, false, false)
|
||||
|
||||
-- Even for mod-admin-full network just uses first submenu item as landing
|
||||
page = node("admin", "network")
|
||||
page.title = _("Network")
|
||||
page.order = 50
|
||||
page.index = true
|
||||
toplevel_page(page, false, false)
|
||||
|
||||
page = entry({"admin", "translations"}, call("action_translations"), nil)
|
||||
page.leaf = true
|
||||
|
||||
page = entry({"admin", "ubus"}, call("action_ubus"), nil)
|
||||
page.sysauth = false
|
||||
page.leaf = true
|
||||
|
||||
-- Logout is last
|
||||
entry({"admin", "logout"}, call("action_logout"), _("Logout"), 999)
|
||||
end
|
||||
|
||||
function action_logout()
|
||||
local dsp = require "luci.dispatcher"
|
||||
local utl = require "luci.util"
|
||||
|
|
|
@ -4,32 +4,6 @@
|
|||
|
||||
module("luci.controller.admin.uci", package.seeall)
|
||||
|
||||
function index()
|
||||
local redir = luci.http.formvalue("redir", true)
|
||||
or table.concat(luci.dispatcher.context.request, "/")
|
||||
|
||||
entry({"admin", "uci"}, nil, _("Configuration"))
|
||||
entry({"admin", "uci", "revert"}, post("action_revert"), nil)
|
||||
|
||||
local node
|
||||
local authen = function(checkpass, allowed_users)
|
||||
return "root", luci.http.formvalue("sid")
|
||||
end
|
||||
|
||||
node = entry({"admin", "uci", "apply_rollback"}, post("action_apply_rollback"), nil)
|
||||
node.cors = true
|
||||
node.sysauth_authenticator = authen
|
||||
|
||||
node = entry({"admin", "uci", "apply_unchecked"}, post("action_apply_unchecked"), nil)
|
||||
node.cors = true
|
||||
node.sysauth_authenticator = authen
|
||||
|
||||
node = entry({"admin", "uci", "confirm"}, call("action_confirm"), nil)
|
||||
node.cors = true
|
||||
node.sysauth = false
|
||||
end
|
||||
|
||||
|
||||
local function ubus_state_to_http(errstr)
|
||||
local map = {
|
||||
["Invalid command"] = 400,
|
||||
|
|
142
modules/luci-base/root/usr/share/luci/menu.d/luci-base.json
Normal file
142
modules/luci-base/root/usr/share/luci/menu.d/luci-base.json
Normal file
|
@ -0,0 +1,142 @@
|
|||
{
|
||||
"admin": {
|
||||
"title": "Administration",
|
||||
"order": 10,
|
||||
"action": {
|
||||
"type": "firstchild",
|
||||
"recurse": true
|
||||
},
|
||||
"auth": {
|
||||
"methods": [ "cookie:sysauth" ],
|
||||
"login": true
|
||||
}
|
||||
},
|
||||
|
||||
"admin/status": {
|
||||
"title": "Status",
|
||||
"order": 10,
|
||||
"action": {
|
||||
"type": "firstchild",
|
||||
"preferred": "overview",
|
||||
"recurse": true
|
||||
}
|
||||
},
|
||||
|
||||
"admin/system": {
|
||||
"title": "System",
|
||||
"order": 20,
|
||||
"action": {
|
||||
"type": "firstchild",
|
||||
"preferred": "system",
|
||||
"recurse": true
|
||||
}
|
||||
},
|
||||
|
||||
"admin/vpn": {
|
||||
"title": "VPN",
|
||||
"order": 30,
|
||||
"action": {
|
||||
"type": "firstchild",
|
||||
"recurse": true
|
||||
}
|
||||
},
|
||||
|
||||
"admin/services": {
|
||||
"title": "Services",
|
||||
"order": 40,
|
||||
"action": {
|
||||
"type": "firstchild",
|
||||
"recurse": true
|
||||
}
|
||||
},
|
||||
|
||||
"admin/network": {
|
||||
"title": "Network",
|
||||
"order": 50,
|
||||
"action": {
|
||||
"type": "firstchild",
|
||||
"recurse": true
|
||||
}
|
||||
},
|
||||
|
||||
"admin/translations/*": {
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.index",
|
||||
"function": "action_translations"
|
||||
},
|
||||
"auth": {
|
||||
"methods": [ "cookie:sysauth" ]
|
||||
}
|
||||
},
|
||||
|
||||
"admin/ubus/*": {
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.index",
|
||||
"function": "action_ubus"
|
||||
},
|
||||
"auth": {}
|
||||
},
|
||||
|
||||
"admin/logout": {
|
||||
"title": "Logout",
|
||||
"order": 999,
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.index",
|
||||
"function": "action_logout"
|
||||
}
|
||||
},
|
||||
|
||||
"admin/uci": {
|
||||
"action": {
|
||||
"type": "firstchild"
|
||||
}
|
||||
},
|
||||
|
||||
"admin/uci/revert": {
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.uci",
|
||||
"function": "action_revert",
|
||||
"post": true
|
||||
}
|
||||
},
|
||||
|
||||
"admin/uci/apply_rollback": {
|
||||
"cors": true,
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.uci",
|
||||
"function": "action_apply_rollback",
|
||||
"post": true
|
||||
},
|
||||
"auth": {
|
||||
"methods": [ "cookie:sysauth" ]
|
||||
}
|
||||
},
|
||||
|
||||
"admin/uci/apply_unchecked": {
|
||||
"cors": true,
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.uci",
|
||||
"function": "action_apply_unchecked",
|
||||
"post": true
|
||||
},
|
||||
"auth": {
|
||||
"methods": [ "cookie:sysauth" ]
|
||||
}
|
||||
},
|
||||
|
||||
"admin/uci/confirm": {
|
||||
"cors": true,
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.uci",
|
||||
"function": "action_confirm"
|
||||
},
|
||||
"auth": {}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue