summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2019-03-07 15:09:47 +0100
committerFlorian Eckert <fe@dev.tdt.de>2019-03-07 15:16:38 +0100
commit82c2a97314e5a569042056233475d1f97c1278ad (patch)
tree3f3e94347666741007f6c062ee11b6d7e213e57c /applications
parent42a060a85255ac7e4ee33f5c16d3434c12a8f8fb (diff)
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>
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
index a89f9f4f8..eb7769b85 100644
--- a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
+++ b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
@@ -115,11 +115,15 @@ function index()
-- get plugin instances
local instances = tree:plugin_instances( plugin )
- -- plugin menu entry
- entry(
- { "admin", "statistics", "graph", plugin },
- call("statistics_render"), labels[plugin], idx
- ).query = { timespan = span , host = host }
+ -- load plugin menu entry from the description
+ local plugin_name = "luci.statistics.rrdtool.definitions." .. plugin
+ local stat, def = pcall( require, plugin_name )
+ if stat and def and type(def.item) == "function" then
+ 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 #instances > 1 then