luci-app-statistics: load graph menu entry name from the definitions

This change defines the menu entry for the LuCI and the rrd definition in
one place. This also has advantage when plugins are written with
exec/python/perl or lua. The controller does not have to be touched for
the menu entry change.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2019-03-07 15:09:47 +01:00
parent 42a060a852
commit 82c2a97314

View file

@ -115,11 +115,15 @@ function index()
-- get plugin instances -- get plugin instances
local instances = tree:plugin_instances( plugin ) local instances = tree:plugin_instances( plugin )
-- plugin menu entry -- load plugin menu entry from the description
entry( local plugin_name = "luci.statistics.rrdtool.definitions." .. plugin
{ "admin", "statistics", "graph", plugin }, local stat, def = pcall( require, plugin_name )
call("statistics_render"), labels[plugin], idx if stat and def and type(def.item) == "function" then
).query = { timespan = span , host = host } entry(
{ "admin", "statistics", "graph", plugin },
call("statistics_render"), def.item(), idx
).query = { timespan = span , host = host }
end
-- if more then one instance is found then generate submenu -- if more then one instance is found then generate submenu
if #instances > 1 then if #instances > 1 then