[llvm-commits] [LNT] r161847 - in /lnt/trunk/lnt/server/ui: static/v4_global_status.js templates/v4_global_status.html views.py
Daniel Dunbar
daniel at zuster.org
Thu Aug 16 10:38:20 PDT 2012
Hey Michael,
On Mon, Aug 13, 2012 at 9:21 PM, Michael Gottesman <mgottesman at apple.com> wrote:
> Author: mgottesman
> Date: Mon Aug 13 23:21:28 2012
> New Revision: 161847
>
> URL: http://llvm.org/viewvc/llvm-project?rev=161847&view=rev
> Log:
> [LNT] v4_global_status: Added right click context menu for looking up graphs.
>
> Modified:
> lnt/trunk/lnt/server/ui/static/v4_global_status.js
> lnt/trunk/lnt/server/ui/templates/v4_global_status.html
> lnt/trunk/lnt/server/ui/views.py
>
> Modified: lnt/trunk/lnt/server/ui/static/v4_global_status.js
> URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/v4_global_status.js?rev=161847&r1=161846&r2=161847&view=diff
> ==============================================================================
> --- lnt/trunk/lnt/server/ui/static/v4_global_status.js (original)
> +++ lnt/trunk/lnt/server/ui/static/v4_global_status.js Mon Aug 13 23:21:28 2012
> @@ -50,10 +50,50 @@
> sortrevind.id = "sorttable_sortrevind";
> sortrevind.innerHTML = ' ▾';
> initial_sort_header.appendChild(sortrevind);
> +
> + $('.data-cell').contextMenu('contextmenu-datacell', {
> + bindings: {
> + 'contextMenu-runpage' : function(elt) {
> + var new_base = elt.getAttribute('run_id') + '/graph?test.';
> +
> + field = getQueryParameterByName('field');
> + if (field == "")
> + field = 2; // compile time.
> +
> + new_base += elt.getAttribute('test_id') + '=' + field.toString();
> + window.location = url_replace_basename(window.location.toString(),
> + new_base);
> + }
> + }
> + });
> });
>
> /* Helper Functions */
>
> + function url_replace_basename(url, new_basename) {
> + // Remove query string.
> + var last_question_index = url.lastIndexOf('?');
> + if (last_question_index != -1)
> + url = url.substring(0, last_question_index);
> + if (url.charAt(url.length-1) == '/') {
> + url = url.substring(0, url.length-1);
> + }
> +
> + var without_base = url.substring(0, url.lastIndexOf('/') + 1);
> + return without_base + new_basename;
> + }
> +
> + function getQueryParameterByName(name) {
> + name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
> + var regexS = "[\\?&]" + name + "=([^&#]*)";
> + var regex = new RegExp(regexS);
> + var results = regex.exec(window.location.search);
> + if(results == null)
> + return "";
> + else
> + return decodeURIComponent(results[1].replace(/\+/g, " "));
> + }
This code is really gross (no offense). And uncommented, *cough*. :)
The simpler/cleaner way to handle this is to pass the necessary information
(e.g., the query parameters and the base URL) as JSON via the originating
template. Take a look at v4_summary_report_ui.js and the matching template for
an example.
IMHO, this code should look like the following. Inside the template:
--
// Pass the url to the database root page, to derive links.
//
// FIXME: This is still suboptimal in that we end up hard-coding parts of the
// URL schema in the UI code.
g.v4_base_url = {{ v4_url_for('v4_overview')|tojson|safe }}
// Pass the index for the selected field we are generating status for.
g.selected_field_index = {{ selected_field.index|tojson|safe }}
--
--
$('.data-cell').contextMenu('contextmenu-datacell', {
bindings: {
'contextMenu-runpage' : function(elt) {
// Derive the URL for the selected graph.
var run_id = elt.getAttribute('run_id')
var test_id = elt.getAttribute('test_id')
var graph_url = g.v4_base_url + run_id.toString() + "/graph"
window.location = graph_url + "?" + $.param({
'test_id' : g.selected_field_index.toString() })
}});
--
which seems much cleaner to me.
> /* Exported Functions */
>
> })(v4_global_status);
>
> Modified: lnt/trunk/lnt/server/ui/templates/v4_global_status.html
> URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/v4_global_status.html?rev=161847&r1=161846&r2=161847&view=diff
> ==============================================================================
> --- lnt/trunk/lnt/server/ui/templates/v4_global_status.html (original)
> +++ lnt/trunk/lnt/server/ui/templates/v4_global_status.html Mon Aug 13 23:21:28 2012
> @@ -54,6 +54,16 @@
> {% endblock %}
>
> {% block body %}
> +{#
> + This div is hidden on load and is there after controlled by the jquery
> + context menu script.
> +#}
> +<div class="contextMenu" id="contextmenu-datacell">
> + <ul>
> + <li id="contextMenu-runpage">View Graph</li>
> + </ul>
> +</div>
> +
> <div id="emperor-control">
> <div id="right-king-control" class="control-panel">
> <h3>Current Settings</h3>
> @@ -134,13 +144,16 @@
> {% endfor %}
> </tr>
> {% for row in tests %}
> + {% set outer_index = loop.index0 %}
> <tr>
> <td class="row-head">
> - {{ row[0] }}
> + {{ row[0][1] }}
> </td>
> {{ row[1]|aspctcell("data-cell worst-time")|safe }}
> - {% for cr in row[2:] %}
> - {{ cr.pct_delta|aspctcell("data-cell " + machines[loop.index0].get_css_name() + " " + machine_groups_map[machines[loop.index0]])|safe }}
> + {% for cr, run_id in row[2:] %}
> + {{ cr.pct_delta|aspctcell("data-cell " + machines[loop.index0].get_css_name() + " " + machine_groups_map[machines[loop.index0]],
> + attributes={'test_id': row[0][0], 'run_id': run_id})
Embedding the test_id and run_id this way is really inefficient. I'm
not sure offhand but can't you quickly get the row and column index
from a cell? If so, then it would be much simpler (and faster, and
smaller) to just encode the test_id array and the machine run_id array
as JSON data that you can index into.
> + |safe }}
> {% endfor %}
> </tr>
> {% endfor %}
>
> Modified: lnt/trunk/lnt/server/ui/views.py
> URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=161847&r1=161846&r2=161847&view=diff
> ==============================================================================
> --- lnt/trunk/lnt/server/ui/views.py (original)
> +++ lnt/trunk/lnt/server/ui/views.py Mon Aug 13 23:21:28 2012
> @@ -707,6 +707,8 @@
> # Add in inverse groups.
> groups.extend("not-" + x for x in grouping_set.difference(groups))
>
> + # Join together all groups so we can just add it to a base css
> + # class string.
> machine_groups_map[machine] = ' '.join(groups)
>
> # Get the set all tests reported in the recent runs.
> @@ -723,17 +725,17 @@
> test_table = []
> for i,(test_id,test_name) in enumerate(reported_tests):
> # Create the row, starting with the test name and worst entry.
> - row = [test_name, None]
> + row = [(test_id, test_name), None]
>
> # Compute comparison results for each machine.
> - row.extend(runinfo.get_run_comparison_result(run, baseline, test_id,
> - field)
> + row.extend((runinfo.get_run_comparison_result(run, baseline, test_id,
> + field), run.id)
Even if you don't make the previous change, there is no reason to
duplicate the run id into every cell, just pass along machine_run_info
and index into that. At that point it might make sense to coalesce the
recent_machines and machine_run_info arrays into one, which might make
the code more obvious.
- Daniel
> for baseline,run in machine_run_info)
>
> # Compute the worst cell value.
> row[1] = max(cr.pct_delta
> - for cr in row[2:])
> -
> + for cr,_ in row[2:])
> +
> test_table.append(row)
>
> # Order the table by worst regression.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list