diff options
author | Robert Adams | 2013-01-24 10:44:57 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-24 10:44:57 -0800 |
commit | 427ab219b8ecf7f039d03ed3067e183db1434fb2 (patch) | |
tree | 520cdf2f0afb00fe8dbb28801d4fbf98902788dd /OpenSim/Region/UserStatistics/WebStatsModule.cs | |
parent | * Added in the manifold point dept on collision desc. In BulletSim engine Bul... (diff) | |
download | opensim-SC-427ab219b8ecf7f039d03ed3067e183db1434fb2.zip opensim-SC-427ab219b8ecf7f039d03ed3067e183db1434fb2.tar.gz opensim-SC-427ab219b8ecf7f039d03ed3067e183db1434fb2.tar.bz2 opensim-SC-427ab219b8ecf7f039d03ed3067e183db1434fb2.tar.xz |
Add JSONification of WebStats module. Adds a '?json' query parameter
to the fetch URL to return the data in JSON format. Also adds a simple
'sim.html' that uses JavaScript to display the JSON data. Not pretty
but an example.
Diffstat (limited to 'OpenSim/Region/UserStatistics/WebStatsModule.cs')
-rw-r--r-- | OpenSim/Region/UserStatistics/WebStatsModule.cs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index 64cb577..438ef48 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -121,6 +121,10 @@ namespace OpenSim.Region.UserStatistics | |||
121 | reports.Add("clients.report", clientReport); | 121 | reports.Add("clients.report", clientReport); |
122 | reports.Add("sessions.report", sessionsReport); | 122 | reports.Add("sessions.report", sessionsReport); |
123 | 123 | ||
124 | reports.Add("sim.css", new Prototype_distributor("sim.css")); | ||
125 | reports.Add("sim.html", new Prototype_distributor("sim.html")); | ||
126 | reports.Add("jquery.js", new Prototype_distributor("jquery.js")); | ||
127 | |||
124 | //// | 128 | //// |
125 | // Add Your own Reports here (Do Not Modify Lines here Devs!) | 129 | // Add Your own Reports here (Do Not Modify Lines here Devs!) |
126 | //// | 130 | //// |
@@ -255,9 +259,12 @@ namespace OpenSim.Region.UserStatistics | |||
255 | string regpath = request["uri"].ToString(); | 259 | string regpath = request["uri"].ToString(); |
256 | int response_code = 404; | 260 | int response_code = 404; |
257 | string contenttype = "text/html"; | 261 | string contenttype = "text/html"; |
262 | bool jsonFormatOutput = false; | ||
258 | 263 | ||
259 | string strOut = string.Empty; | 264 | string strOut = string.Empty; |
260 | 265 | ||
266 | // The request patch should be "/SStats/reportName" where 'reportName' | ||
267 | // is one of the names added to the 'reports' hashmap. | ||
261 | regpath = regpath.Remove(0, 8); | 268 | regpath = regpath.Remove(0, 8); |
262 | if (regpath.Length == 0) regpath = "default.report"; | 269 | if (regpath.Length == 0) regpath = "default.report"; |
263 | if (reports.ContainsKey(regpath)) | 270 | if (reports.ContainsKey(regpath)) |
@@ -265,6 +272,9 @@ namespace OpenSim.Region.UserStatistics | |||
265 | IStatsController rep = reports[regpath]; | 272 | IStatsController rep = reports[regpath]; |
266 | Hashtable repParams = new Hashtable(); | 273 | Hashtable repParams = new Hashtable(); |
267 | 274 | ||
275 | if (request.ContainsKey("json")) | ||
276 | jsonFormatOutput = true; | ||
277 | |||
268 | if (request.ContainsKey("requestvars")) | 278 | if (request.ContainsKey("requestvars")) |
269 | repParams["RequestVars"] = request["requestvars"]; | 279 | repParams["RequestVars"] = request["requestvars"]; |
270 | else | 280 | else |
@@ -284,13 +294,26 @@ namespace OpenSim.Region.UserStatistics | |||
284 | 294 | ||
285 | concurrencyCounter++; | 295 | concurrencyCounter++; |
286 | 296 | ||
287 | strOut = rep.RenderView(rep.ProcessModel(repParams)); | 297 | if (jsonFormatOutput) |
298 | { | ||
299 | strOut = rep.RenderJson(rep.ProcessModel(repParams)); | ||
300 | contenttype = "text/json"; | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | strOut = rep.RenderView(rep.ProcessModel(repParams)); | ||
305 | } | ||
288 | 306 | ||
289 | if (regpath.EndsWith("js")) | 307 | if (regpath.EndsWith("js")) |
290 | { | 308 | { |
291 | contenttype = "text/javascript"; | 309 | contenttype = "text/javascript"; |
292 | } | 310 | } |
293 | 311 | ||
312 | if (regpath.EndsWith("css")) | ||
313 | { | ||
314 | contenttype = "text/css"; | ||
315 | } | ||
316 | |||
294 | concurrencyCounter--; | 317 | concurrencyCounter--; |
295 | 318 | ||
296 | response_code = 200; | 319 | response_code = 200; |