summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-12-25 02:31:28 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-12-25 02:31:28 +0000
commit5a23297f9d6c3053fc4d0eec648c2341a2c6bc57 (patch)
tree86e1604bbdebbdc2d63a575756c5e5fac08f76cd /applications
parent33fba71fc94b84c33b1e600da9b195eac49b2e31 (diff)
applications/luci-statistics: render graph menus in alphabetic order
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua22
1 files changed, 12 insertions, 10 deletions
diff --git a/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua b/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
index 869384c0a..d69b68e17 100644
--- a/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
+++ b/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
@@ -2,6 +2,7 @@
Luci statistics - statistics controller module
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
+(c) 2012 Jo-Philipp Wich <xm@subsignal.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -9,8 +10,6 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
-$Id$
-
]]--
module("luci.controller.luci_statistics.luci_statistics", package.seeall)
@@ -69,9 +68,9 @@ function index()
-- create toplevel menu nodes
local st = entry({"admin", "statistics"}, template("admin_statistics/index"), _("Statistics"), 80)
st.index = true
-
+
entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), _("Collectd"), 10).subindex = true
-
+
-- populate collectd plugin menu
local index = 1
@@ -106,7 +105,8 @@ function index()
-- get rrd data tree
local tree = luci.statistics.datatree.Instance(host)
- for i, plugin in luci.util.vspairs( tree:plugins() ) do
+ local _, plugin, idx
+ for _, plugin, idx in luci.util.vspairs( tree:plugins() ) do
-- get plugin instances
local instances = tree:plugin_instances( plugin )
@@ -114,16 +114,17 @@ function index()
-- plugin menu entry
entry(
{ "admin", "statistics", "graph", plugin },
- call("statistics_render"), labels[plugin], i
+ call("statistics_render"), labels[plugin], idx
).query = { timespan = span , host = host }
-- if more then one instance is found then generate submenu
if #instances > 1 then
- for j, inst in luci.util.vspairs(instances) do
+ local _, inst, idx2
+ for _, inst, idx2 in luci.util.vspairs(instances) do
-- instance menu entry
entry(
{ "admin", "statistics", "graph", plugin, inst },
- call("statistics_render"), inst, j
+ call("statistics_render"), inst, idx2
).query = { timespan = span , host = host }
end
end
@@ -148,6 +149,7 @@ function statistics_render()
local hosts = graph.tree:host_instances()
local is_index = false
+ local i, p, inst, idx
-- deliver image
if vars.img then
@@ -186,8 +188,8 @@ function statistics_render()
-- render graphs
- for i, inst in ipairs( instances ) do
- for i, img in ipairs( graph:render( plugin, inst, is_index ) ) do
+ for i, inst in luci.util.vspairs( instances ) do
+ for i, img in luci.util.vspairs( graph:render( plugin, inst, is_index ) ) do
table.insert( images, graph:strippngpath( img ) )
images[images[#images]] = inst
end