OXYGEN #1: Added index-marks
[project/luci.git] / applications / luci-statistics / luasrc / controller / luci_statistics / luci_statistics.lua
index aeee636..0aa6636 100644 (file)
@@ -22,7 +22,8 @@ function index()
        require("luci.i18n")
        require("luci.statistics.datatree")
 
-       -- load language file
+       -- load language files
+       luci.i18n.loadc("rrdtool")
        luci.i18n.loadc("statistics")
 
        -- get rrd data tree
@@ -49,8 +50,12 @@ function index()
        }
 
        -- create toplevel menu nodes
-       entry({"admin", "statistics"},             call("statistics_index"),        _i18n("statistics"), 80).i18n = "statistics"
-       entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), _i18n("collectd"),   10)
+       local st = entry({"admin", "statistics"},             call("statistics_index"),        _i18n("statistics"), 80)
+       st.i18n = "statistics"
+       st.index = true
+       
+       entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), _i18n("collectd"),   10).subindex = true
+       
 
        -- populate collectd plugin menu
        local index = 1
@@ -60,7 +65,7 @@ function index()
                        call( "statistics_" .. section .. "plugins" ),
                        _i18n( section .. "plugins" ),
                        index * 10
-               )
+               ).index = true
 
                for j, plugin in luci.util.vspairs( plugins ) do
                        _entry(
@@ -80,7 +85,7 @@ function index()
              page.setuser  = "nobody"
              page.setgroup = "nogroup"
 
-       local vars = luci.http.getvalue()
+       local vars = luci.http.formvalue(nil, true)
        local span = vars.timespan or nil
 
        for i, plugin in luci.util.vspairs( tree:plugins() ) do
@@ -148,22 +153,22 @@ function statistics_render()
        require("luci.template")
        require("luci.model.uci")
 
-       local vars  = luci.http.getvalue()
+       local vars  = luci.http.formvalue()
        local req   = luci.dispatcher.context.request
-       local path  = luci.dispatcher.context.dispatched.path
-       local uci   = luci.model.uci
-       local spans = luci.util.split( uci.get( "luci_statistics", "collectd_rrdtool", "RRATimespans" ), "%s+", nil, true )
-       local span  = vars.timespan or uci.get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1]
+       local path  = luci.dispatcher.context.path
+       local uci   = luci.model.uci.cursor()
+       local spans = luci.util.split( uci:get( "luci_statistics", "collectd_rrdtool", "RRATimespans" ), "%s+", nil, true )
+       local span  = vars.timespan or uci:get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1]
        local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ) )
 
        local plugin, instances
        local images = { }
 
        -- find requested plugin and instance
-        for i, p in ipairs( luci.dispatcher.context.dispatched.path ) do
-                if luci.dispatcher.context.dispatched.path[i] == "graph" then
-                        plugin    = luci.dispatcher.context.dispatched.path[i+1]
-                        instances = { luci.dispatcher.context.dispatched.path[i+2] }
+        for i, p in ipairs( luci.dispatcher.context.path ) do
+                if luci.dispatcher.context.path[i] == "graph" then
+                        plugin    = luci.dispatcher.context.path[i+1]
+                        instances = { luci.dispatcher.context.path[i+2] }
                 end
         end