summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-statistics/luasrc/controller
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-statistics/luasrc/controller')
-rw-r--r--applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua15
1 files changed, 8 insertions, 7 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 4c5db17d83..529cc2335a 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
@@ -9,6 +9,7 @@ function index()
require("nixio.fs")
require("luci.util")
require("luci.statistics.datatree")
+ require("luci.jsonc")
-- override entry(): check for existence <plugin>.so where <plugin> is derived from the called path
function _entry( path, ... )
@@ -31,14 +32,14 @@ function index()
network = { }
}
- local plugin_dir = "/usr/lib/lua/luci/statistics/plugins/"
+ local plugin_dir = "/usr/share/luci/statistics/plugins/"
for filename in nixio.fs.dir(plugin_dir) do
- local plugin_fun = loadfile(plugin_dir .. filename)
- setfenv(plugin_fun, { _ = luci.i18n.translate })
- local plugin = plugin_fun()
- local name = filename:gsub("%.lua", "")
- table.insert(collectd_menu[plugin.category], name)
- labels[name] = plugin.label
+ local plugin_def = luci.jsonc.parse(nixio.fs.readfile(plugin_dir .. filename))
+ if type(plugin_def) == "table" then
+ local name = filename:gsub("%.json", "")
+ table.insert(collectd_menu[plugin_def.category], name)
+ labels[name] = plugin_def.title
+ end
end
-- create toplevel menu nodes