luci-base: implement JSON endpoint to fetch menu information
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
51186355ea
commit
e56e442d6a
2 changed files with 21 additions and 0 deletions
|
@ -182,3 +182,15 @@ function action_ubus()
|
|||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(response)
|
||||
end
|
||||
|
||||
function action_menu()
|
||||
local dsp = require "luci.dispatcher"
|
||||
local utl = require "luci.util"
|
||||
local http = require "luci.http"
|
||||
|
||||
local acls = utl.ubus("session", "access", { ubus_rpc_session = http.getcookie("sysauth") })
|
||||
local menu = dsp.menu_json(acls or {}) or {}
|
||||
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(menu)
|
||||
end
|
||||
|
|
|
@ -136,5 +136,14 @@
|
|||
"function": "action_confirm"
|
||||
},
|
||||
"auth": {}
|
||||
},
|
||||
|
||||
"admin/menu": {
|
||||
"action": {
|
||||
"type": "call",
|
||||
"module": "luci.controller.admin.index",
|
||||
"function": "action_menu"
|
||||
},
|
||||
"auth": {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue