summaryrefslogtreecommitdiff
path: root/python/gras/stats/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'python/gras/stats/main.js')
-rw-r--r--python/gras/stats/main.js81
1 files changed, 42 insertions, 39 deletions
diff --git a/python/gras/stats/main.js b/python/gras/stats/main.js
index dc04e73..a27c0b7 100644
--- a/python/gras/stats/main.js
+++ b/python/gras/stats/main.js
@@ -1,4 +1,23 @@
/***********************************************************************
+ * Some constants
+ **********************************************************************/
+var GRAS_CHARTS_STD_WIDTH = 250;
+
+/***********************************************************************
+ * Stats registry data structure
+ **********************************************************************/
+var GrasStatsRegistry = function()
+{
+ this.init = false;
+ this.overall_rate = 2.0;
+ this.overall_active = true;
+ this.block_ids = new Array();
+ this.top_id = 'top';
+ this.online = true;
+ this.offline_count = 0;
+}
+
+/***********************************************************************
* Query stats
**********************************************************************/
var gras_query_stats = function(registry)
@@ -10,14 +29,22 @@ var gras_query_stats = function(registry)
dataType: "xml",
success: function(xml)
{
+ registry.online = true;
+ gras_chart_factory_online(registry);
if (registry.overall_active)
{
if ($(xml, "gras_stats") !== undefined)
{
- registry.appendPoint(xml);
- gras_update_throughput_chart(registry);
- gras_update_time_compare_chart(registry);
- gras_update_per_block_charts(registry);
+ if (!registry.init)
+ {
+ gras_chart_factory_setup(registry, xml);
+ try{gras_chart_load(registry);}catch(e){}
+ registry.init = true;
+ }
+ $.each(registry.active_charts, function(index, chart_info)
+ {
+ chart_info.chart.update(xml);
+ });
}
registry.timeout_handle = window.setTimeout(function()
@@ -25,7 +52,16 @@ var gras_query_stats = function(registry)
gras_query_stats(registry);
}, Math.round(1000/registry.overall_rate));
}
- }
+ },
+ error: function()
+ {
+ registry.online = false;
+ gras_chart_factory_online(registry);
+ registry.timeout_handle = window.setTimeout(function()
+ {
+ gras_query_stats(registry);
+ }, 1000);
+ },
});
}
@@ -35,39 +71,6 @@ var gras_query_stats = function(registry)
var gras_stats_main = function()
{
var registry = new GrasStatsRegistry();
- var overall_config = $('#overall_config').get(0);
-
- gras_setup_overall_chart(registry);
- gras_setup_overall_chart_pie(registry);
-
- //init overall config gui element for rate
- var overall_rate = $('input[name="rate"]', overall_config);
- overall_rate.val(registry.overall_rate);
- overall_rate.change(function()
- {
- registry.overall_rate = overall_rate.val();
- });
-
- //init overall config gui element for activity
- registry.overall_active = true;
- var overall_active = $('input[name="active"]', overall_config);
- overall_active.attr('checked', registry.overall_active);
- overall_active.change(function()
- {
- registry.overall_active = overall_active.is(':checked');
- if (registry.overall_active) gras_query_stats(registry);
- else window.clearInterval(registry.timeout_handle);
- });
-
- //init overall config gui element for showing
- var overall_show = $('input[name="show"]', overall_config);
- overall_show.attr('checked', false);
- overall_show.change(function()
- {
- var chart = $('#overall_chart');
- gras_animate_show_hide(chart, overall_show.is(':checked'));
- });
- overall_show.change();
-
+ gras_chart_factory_init(registry);
gras_query_stats(registry);
}