diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-03-27 22:19:16 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-03-27 22:19:16 +0000 |
commit | 4fa474cf2b8c0ec99366c76625e4c78c389d6cb1 (patch) | |
tree | 5996ae65d7620c002da164559c02003fcc7acef2 /applications/luci-statistics | |
parent | 8016c9649fe8cf313300bcc87076e2ca54402354 (diff) |
applications/luci-statistics: make it work under uhttpd
Diffstat (limited to 'applications/luci-statistics')
-rw-r--r-- | applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua | 22 | ||||
-rw-r--r-- | applications/luci-statistics/luasrc/view/public_statistics/graph.htm | 2 |
2 files changed, 18 insertions, 6 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 b40603dbe..817622c43 100644 --- a/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua +++ b/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua @@ -161,16 +161,28 @@ function statistics_render() 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 ) ) + -- deliver image + if vars.img then + local l12 = require "luci.ltn12" + local png = io.open(graph.opts.imgpath .. "/" .. vars.img:gsub("%.+", "."), "r") + if png then + luci.http.prepare_content("image/png") + l12.pump.all(l12.source.file(png), luci.http.write) + png:close() + end + return + end + local plugin, instances local images = { } -- find requested plugin and instance - 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 + 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 -- no instance requested, find all instances if #instances == 0 then diff --git a/applications/luci-statistics/luasrc/view/public_statistics/graph.htm b/applications/luci-statistics/luasrc/view/public_statistics/graph.htm index 71be2aa2f..fcc452f5a 100644 --- a/applications/luci-statistics/luasrc/view/public_statistics/graph.htm +++ b/applications/luci-statistics/luasrc/view/public_statistics/graph.htm @@ -31,7 +31,7 @@ $Id$ <div style="text-align: center"> <% for i, img in ipairs(images) do %> - <img src="/rrdimg/<%=img%>" /> + <img src="<%=REQUEST_URI%>?img=<%=img%>" /> <br /> <% end %> </div> |