diff options
author | Josh Blum | 2013-03-26 22:14:15 -0500 |
---|---|---|
committer | Josh Blum | 2013-03-26 22:14:15 -0500 |
commit | 3868f8f0156e9e936c39908e43762273be2d4e51 (patch) | |
tree | e22552ea3a09abead0b7ab5c4a82a10b3e83b5ff /python/gras | |
parent | 66d14812e6deaedf151cdb619797f00b057a28c0 (diff) | |
download | sandhi-3868f8f0156e9e936c39908e43762273be2d4e51.tar.gz sandhi-3868f8f0156e9e936c39908e43762273be2d4e51.tar.bz2 sandhi-3868f8f0156e9e936c39908e43762273be2d4e51.zip |
gras: various tweaks to the gui elements
Diffstat (limited to 'python/gras')
-rw-r--r-- | python/gras/query/__init__.py | 18 | ||||
-rw-r--r-- | python/gras/query/chart_factory.js | 15 | ||||
-rw-r--r-- | python/gras/query/chart_overall_throughput.js | 3 | ||||
-rw-r--r-- | python/gras/query/main.html | 5 | ||||
-rw-r--r-- | python/gras/query/main.js | 25 |
5 files changed, 45 insertions, 21 deletions
diff --git a/python/gras/query/__init__.py b/python/gras/query/__init__.py index e25e22d..06c7b70 100644 --- a/python/gras/query/__init__.py +++ b/python/gras/query/__init__.py @@ -1,6 +1,6 @@ import time import BaseHTTPServer - +import json import os __path__ = os.path.abspath(os.path.dirname(__file__)) @@ -16,15 +16,21 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(s): """Respond to a GET request.""" args = server_registry[s.server] - if s.path.endswith('.json'): + path = s.path + if path.startswith('/'): path = path[1:] + if not path: path = 'main.html' + if path.endswith('.json'): s.send_response(200) s.send_header("Content-type", "application/json") s.end_headers() - s.wfile.write(args['top_block'].query(s.path)) + if path == 'args.json': + arg_strs = dict((str(k), str(v)) for k, v in args.iteritems()) + s.wfile.write(json.dumps(arg_strs)) + elif path == 'stats.json': + s.wfile.write(args['top_block'].query(s.path)) + else: + s.wfile.write(json.dumps({})) return - path = s.path - if path.startswith('/'): path = path[1:] - if not path: path = 'main.html' target = os.path.join(__path__, path) if os.path.exists(target): s.send_response(200) diff --git a/python/gras/query/chart_factory.js b/python/gras/query/chart_factory.js index 682a968..7c7888d 100644 --- a/python/gras/query/chart_factory.js +++ b/python/gras/query/chart_factory.js @@ -16,9 +16,10 @@ var gras_chart_get_registry = function() **********************************************************************/ function gras_chart_factory_setup(registry, point) { - var id = point.id; - registry.top_id = id; - $('#top_name').append(' - ' + id); + //gui init for factory controls + gras_chart_factory_init(registry); + + //block registry and checkboxes init $.each(point.blocks, function(id, block) { registry.block_ids.push(id); @@ -33,6 +34,9 @@ function gras_chart_factory_setup(registry, point) $(div).append(input); $(container).append(div); }); + + //try to load last settings + try{gras_chart_load(registry);}catch(e){} } /*********************************************************************** @@ -188,7 +192,10 @@ function gras_chart_factory_init(registry) }); //init overall config gui element for rate - var overall_rate = $('#chart_update_rate'); + var overall_rate = $('#chart_update_rate').attr({size:3}); + overall_rate.spinner({ + min: 1, max: 10, stop: function(event, ui){$(this).change();} + }); overall_rate.val(registry.overall_rate); overall_rate.change(function() { diff --git a/python/gras/query/chart_overall_throughput.js b/python/gras/query/chart_overall_throughput.js index 4947479..61361dc 100644 --- a/python/gras/query/chart_overall_throughput.js +++ b/python/gras/query/chart_overall_throughput.js @@ -13,7 +13,7 @@ function GrasChartOverallThroughput(args) //make new chart this.chart = new google.visualization.LineChart(args.panel); - this.title = "Overall Throughput vs Time"; + this.title = "Overall Throughput vs Time in MIps"; this.history = new Array(); } @@ -39,7 +39,6 @@ GrasChartOverallThroughput.prototype.update = function(point) var chart_data = google.visualization.arrayToDataTable(data_set); var options = { width:GRAS_CHARTS_STD_WIDTH*2, - chartArea:{left:0,top:0,right:0,bottom:0,width:"100%",height:"85%"}, legend: {'position': 'bottom'}, }; this.chart.draw(chart_data, options); diff --git a/python/gras/query/main.html b/python/gras/query/main.html index eeb221d..a3864a2 100644 --- a/python/gras/query/main.html +++ b/python/gras/query/main.html @@ -33,7 +33,10 @@ <tr> <td id="chart_designer_blocks" rowspan='2'></td> <td><select id="chart_type_selector" /></td> - <td><label>Updates/sec:</label><input id="chart_update_rate" type="number" name="rate" min="1" max="10" size="4" /></td> + <td> + <label for="spinner">Updates/sec:</label> + <input id="chart_update_rate" type="spinner" /> + </td> </tr> <tr> <td><input type="submit" value="Create New Chart" id="chart_factory_button" /></td> diff --git a/python/gras/query/main.js b/python/gras/query/main.js index 80791b9..5faf8fe 100644 --- a/python/gras/query/main.js +++ b/python/gras/query/main.js @@ -8,7 +8,6 @@ var GRAS_CHARTS_STD_WIDTH = 250; **********************************************************************/ var GrasStatsRegistry = function() { - this.init = false; this.overall_rate = 2.0; this.overall_active = true; this.block_ids = new Array(); @@ -33,12 +32,6 @@ var gras_query_stats = function(registry) gras_chart_factory_online(registry); if (registry.overall_active) { - if (!registry.init) - { - gras_chart_factory_setup(registry, response); - try{gras_chart_load(registry);}catch(e){} - registry.init = true; - } $.each(registry.active_charts, function(index, chart_info) { chart_info.chart.update(response); @@ -67,7 +60,23 @@ var gras_query_stats = function(registry) **********************************************************************/ var gras_stats_main = function() { + //create a new registry - storage for gui state var registry = new GrasStatsRegistry(); - gras_chart_factory_init(registry); + + //query various server args + $.getJSON('/args.json', function(data) + { + registry.top_id = data.name; + $('#top_name').append(' - ' + registry.top_id); + document.title += ' - ' + registry.top_id; + }); + + //query the stats for initial setup + $.getJSON('/stats.json', function(data) + { + gras_chart_factory_setup(registry, data); + }); + + //start the query loop in the background gras_query_stats(registry); } |