diff mbox

[Branch,~linaro-validation/lava-dashboard/trunk] Rev 408: * Table cell width when there are bugs linked

Message ID 20130618140316.25554.72767.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Stevan Radakovic June 18, 2013, 2:03 p.m. UTC
Merge authors:
  Stevan Radaković (stevanr)
Related merge proposals:
  https://code.launchpad.net/~stevanr/lava-dashboard/image-reports-feedback/+merge/170074
  proposed by: Stevan Radaković (stevanr)
  review: Approve - Antonio Terceiro (terceiro)
------------------------------------------------------------
revno: 408 [merge]
committer: Stevan Radakovic <stevan.radakovic@linaro.org>
branch nick: trunk
timestamp: Tue 2013-06-18 16:02:31 +0200
message:
  * Table cell width when there are bugs linked
  * Switch graph on/off checkbox(on by default)
  * Be able to share a link to the images, timeline, etc..
modified:
  dashboard_app/static/dashboard_app/css/image-report.css
  dashboard_app/static/dashboard_app/js/image-report.js
  dashboard_app/templates/dashboard_app/image-report.html


--
lp:lava-dashboard
https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk

You are subscribed to branch lp:lava-dashboard.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'dashboard_app/static/dashboard_app/css/image-report.css'
--- dashboard_app/static/dashboard_app/css/image-report.css	2013-06-10 15:33:53 +0000
+++ dashboard_app/static/dashboard_app/css/image-report.css	2013-06-18 13:12:18 +0000
@@ -9,7 +9,7 @@ 
     text-align: left;
 }
 .inner-table td, .inner-table th {
-    min-width: 90px;
+    min-width: 105px;
     padding: 3px 4px;
     border: thin solid black;
 }
@@ -60,6 +60,9 @@ 
 #outer-container {
     overflow: auto;
 }
+#toggle-graph-container {
+    margin-top: 5px;
+}
 #filters {
     border: 1px solid #000000;
     clear: both;
@@ -73,6 +76,10 @@ 
     font-size: 16px;
     margin: 5px 0 0 10px;
 }
+#filter_headline a {
+    font-weight: normal;
+    font-size: 12px;
+}
 #test_headline, #build_number_headline, #graph_type_headline, #target_goal_headline {
     width: 120px;
     float: left;

=== modified file 'dashboard_app/static/dashboard_app/js/image-report.js'
--- dashboard_app/static/dashboard_app/js/image-report.js	2013-06-14 09:11:32 +0000
+++ dashboard_app/static/dashboard_app/js/image-report.js	2013-06-18 13:50:02 +0000
@@ -23,6 +23,13 @@ 
     }
 }
 
+function toggle_graph () {
+    $("#outer-container").toggle();
+    $(".tickLabels").toggle();
+    update_plot(columns, chart_data, test_names);
+    store_filters();
+}
+
 function update_filters(column_data, test_run_names) {
     for (iter in column_data) {
 	build_number = column_data[iter]["number"].split('.')[0];
@@ -74,6 +81,12 @@ 
 	return false;
     }
 
+    if (!isNumeric($("#target_goal").val())) {
+	alert("Target goal must be a numeric value.");
+	return false;
+    }
+
+
     // Create row headlines.
     test_name_rows = "<tr><td>Date</td></tr>";
     for (iter in test_run_names) {
@@ -152,7 +165,20 @@ 
     store_filters();
     update_plot(column_data, table_data, test_run_names);
     update_tooltips();
+    update_filter_link();
     add_bug_links();
+    _fixRowHeights();
+}
+
+function update_filter_link() {
+    filter_link = window.location.href.split('?')[0] + '?';
+    filter_link += "build_number_start=" + $("#build_number_start").val();
+    filter_link += "&build_number_end=" + $("#build_number_end").val();
+    filter_link += "&test_select=" + $("#test_select").val();
+    filter_link += "&target_goal=" + $("#target_goal").val().trim();
+    filter_link += "&graph_type=" + $('input:radio[name=graph_type]:checked').val();
+
+    $("#filter_link").attr("href", filter_link);
 }
 
 function update_tooltips() {
@@ -173,16 +199,23 @@ 
 
     prefix = window.location.pathname.split('/').pop();
 
-    $.jStorage.set(prefix + "_target_goal", $("#target_goal").val());
+    $.jStorage.set(prefix + "_target_goal", $("#target_goal").val().trim());
     $.jStorage.set(prefix + "_build_number_start", $("#build_number_start").val());
     $.jStorage.set(prefix + "_build_number_end", $("#build_number_end").val());
     $.jStorage.set(prefix + "_test_select", $("#test_select").val());
+    $.jStorage.set(prefix + "_toggle_graph", $("#toggle_graph").attr("checked"));
     $.jStorage.set(prefix + "_graph_type", $('input:radio[name=graph_type]:checked').val());
 }
 
 function load_filters() {
     // Use jStorage to load the filter values from browser.
 
+    // If get parameters are present they are used because of higher priority.
+    if (location.search != "") {
+	populate_filters_from_get();
+	return;
+    }
+
     prefix = window.location.pathname.split('/').pop();
 
     if ($.jStorage.get(prefix + "_target_goal")) {
@@ -197,6 +230,9 @@ 
     if ($.jStorage.get(prefix + "_test_select")) {
 	$("#test_select").val($.jStorage.get(prefix + "_test_select"));
     }
+    if ($.jStorage.get(prefix + "_toggle_graph") != null) {
+	$("#toggle_graph").attr("checked", $.jStorage.get(prefix + "_toggle_graph"));
+    }
     if ($.jStorage.get(prefix + "_graph_type")) {
 	if ($.jStorage.get(prefix + "_graph_type") == "number") {
 	    $('input:radio[name=graph_type][value="number"]').attr("checked", true);
@@ -206,6 +242,39 @@ 
     }
 }
 
+function populate_filters_from_get() {
+    // Populate filter fields from get request parameters.
+    var parameters = get_parameters_from_request();
+    for (iter in parameters) {
+	if (parameters[iter][0] == "build_number_start" && parameters[iter][1] != "") {
+	    $("#build_number_start").val(unescape(parameters[iter][1]));
+	}
+	if (parameters[iter][0] == "build_number_end" && parameters[iter][1] != "") {
+	    $("#build_number_end").val(unescape(parameters[iter][1]));
+	}
+	if (parameters[iter][0] == "test_select" && parameters[iter][1] != "") {
+	    $("#test_select").val(parameters[iter][1].split(','));
+	}
+	if (parameters[iter][0] == "target_goal" && parameters[iter][1] != "") {
+	    $("#target_goal").val(unescape(parameters[iter][1]));
+	}
+	if (parameters[iter][0] == "graph_type" && parameters[iter][1] != "") {
+	    if (parameters[iter][1] == "number") {
+		$('input:radio[name=graph_type][value="number"]').attr("checked", true);
+	    } else {
+		$('input:radio[name=graph_type][value="percentage"]').attr("checked", true);
+	    }
+	}
+    }
+}
+
+function get_parameters_from_request() {
+    var params = location.search.replace('?', '').split('&').map(function(val) {	
+	return val.split('=');
+    });
+    return params;
+}
+
 function update_plot(column_data, table_data, test_run_names) {
 
     // Get the plot data.
@@ -452,7 +521,9 @@ 
         _fixRowHeights();
 
 	add_bug_links();
-
+	if (!$("#toggle_graph").attr("checked")) {
+	    $("#outer-container").toggle();
+	}
     });
 // Because what resize does depends on the final sizes of elements,
 // run it again after everything is loaded (things end up wrong in

=== modified file 'dashboard_app/templates/dashboard_app/image-report.html'
--- dashboard_app/templates/dashboard_app/image-report.html	2013-06-10 15:33:53 +0000
+++ dashboard_app/templates/dashboard_app/image-report.html	2013-06-18 13:12:18 +0000
@@ -9,6 +9,12 @@ 
 <script src="{{ STATIC_URL }}dashboard_app/js/jquery.flot.dashes.min.js"></script>
 <script src="{{ STATIC_URL }}dashboard_app/js/jstorage.min.js"></script>
 <script src="{{ STATIC_URL }}dashboard_app/js/jquery.tooltip.min.js"></script>
+
+<script language="javascript">
+  chart_data = $.parseJSON($('<div/>').html("{{chart_data}}").text());
+  test_names = $.parseJSON($('<div/>').html("{{test_names}}").text());
+  columns = $.parseJSON($('<div/>').html("{{columns}}").text());
+</script>
 {% endblock %}
 
 {% block content %}
@@ -22,16 +28,13 @@ 
 </div>
 </div>
 
-
-
-<script language="javascript">
-  chart_data = $.parseJSON($('<div/>').html("{{chart_data}}").text());
-  test_names = $.parseJSON($('<div/>').html("{{test_names}}").text());
-  columns = $.parseJSON($('<div/>').html("{{columns}}").text());
-</script>
+<div id="toggle-graph-container">
+  <input type="checkbox" id="toggle_graph" onchange="toggle_graph()" checked="checked" />
+  <label for="toggle_graph">Toggle graph</label>
+</div>
 
 <div id="filters">
-  <div id="filter_headline">Filters</div>
+  <div id="filter_headline">Filters <a id="filter_link" href="#">Link to this filter set</a></div>
   <div id="build_numbers_filter">
     <div id="build_number_headline">
       Start build number: