From patchwork Thu Jun 13 08:33:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stevan Radakovic X-Patchwork-Id: 17867 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 696F625DF1 for ; Thu, 13 Jun 2013 08:33:20 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id 1sf11139025qee.6 for ; Thu, 13 Jun 2013 01:33:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state:x-original-sender :x-original-authentication-results:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=vRfqB6cepdG9BO5Qg06UpRnWa6UdCIUMHK94DVFYuN8=; b=LSwyvEhPUN0/hLrz5l6TuYMa5Bnn6KM/q/WEdXoZWVyUMI5+4JnVjoG9aR4XHYVtFg R4n2Z9YSn5M8SxaVvo3/V/d8Q8xYpTQmOEj8XBZIS1z51J1W7OPIqznQBlkNObP62vdX /ng+ybrT5HsY2zfc5kxj2VLBfNslBmjxbL8xxATHel5cXN0p1f2DB9ToRHhOqewDBEqf hkqviOPRU7p+6WAHeep+D56Uw0GFqAUL+HykE5pc3YO1GNlkxGahztX6CvE68C2wTO7E kCrinb6a1qQSzwfRJi3BPM345aeKTJuE2/2lsYQR37mOwVmfgim3JyWYZhsVBKXhydGl QbNA== X-Received: by 10.236.198.168 with SMTP id v28mr12850985yhn.10.1371112399901; Thu, 13 Jun 2013 01:33:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.36.40 with SMTP id n8ls1773159qej.79.gmail; Thu, 13 Jun 2013 01:33:19 -0700 (PDT) X-Received: by 10.58.240.6 with SMTP id vw6mr143128vec.16.1371112399730; Thu, 13 Jun 2013 01:33:19 -0700 (PDT) Received: from mail-vb0-x234.google.com (mail-vb0-x234.google.com [2607:f8b0:400c:c02::234]) by mx.google.com with ESMTPS id sz6si10050299vdc.88.2013.06.13.01.33.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Jun 2013 01:33:19 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::234; Received: by mail-vb0-f52.google.com with SMTP id f12so5882658vbg.25 for ; Thu, 13 Jun 2013 01:33:19 -0700 (PDT) X-Received: by 10.220.185.136 with SMTP id co8mr11055679vcb.25.1371112399609; Thu, 13 Jun 2013 01:33:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.191.99 with SMTP id gx3csp12531vec; Thu, 13 Jun 2013 01:33:18 -0700 (PDT) X-Received: by 10.14.4.130 with SMTP id 2mr14597159eej.96.1371112398285; Thu, 13 Jun 2013 01:33:18 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id h48si17692845eev.145.2013.06.13.01.33.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Jun 2013 01:33:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Un2y5-0000El-FX for ; Thu, 13 Jun 2013 08:33:17 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 4BBF6E027F for ; Thu, 13 Jun 2013 08:33:17 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dashboard X-Launchpad-Branch: ~linaro-validation/lava-dashboard/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 406 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dashboard/trunk] Rev 406: Fix new image reports page bugs. Reviewed by terceiro. Message-Id: <20130613083317.30146.4736.launchpad@ackee.canonical.com> Date: Thu, 13 Jun 2013 08:33:17 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16667"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 79f6c3e7ee7d698c3d56b42457ecdb391f955cf1 X-Gm-Message-State: ALoCoQmmC4Wli3av7rbvi1BdGWmm+MMjNtx70ezTzEh14vrAIiBcmm85XQHj8M3YSlj9FM43a6ZZ X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Merge authors: Stevan Radaković (stevanr) Related merge proposals: https://code.launchpad.net/~stevanr/lava-dashboard/image-reports-revamp-fix/+merge/168951 proposed by: Stevan Radaković (stevanr) review: Approve - Antonio Terceiro (terceiro) ------------------------------------------------------------ revno: 406 [merge] committer: Stevan Radakovic branch nick: trunk timestamp: Thu 2013-06-13 10:32:25 +0200 message: Fix new image reports page bugs. Reviewed by terceiro. modified: dashboard_app/static/dashboard_app/js/image-report.js --- 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 === modified file 'dashboard_app/static/dashboard_app/js/image-report.js' --- dashboard_app/static/dashboard_app/js/image-report.js 2013-06-10 15:33:53 +0000 +++ dashboard_app/static/dashboard_app/js/image-report.js 2013-06-13 08:26:40 +0000 @@ -60,7 +60,16 @@ return false; } - if ($("#build_number_start").val() > $("#build_number_end").val()) { + build_number_start = $("#build_number_start").val(); + if (isNumeric(build_number_start)) { + build_number_start = parseInt(build_number_start); + } + build_number_end = $("#build_number_end").val(); + if (isNumeric(build_number_end)) { + build_number_end = parseInt(build_number_end); + } + + if (build_number_start > build_number_end) { alert("End build number must be greater then the start build number."); return false; } @@ -83,8 +92,11 @@ for (iter in column_data) { build_number = column_data[iter]["number"].split('.')[0]; - if (build_number <= $("#build_number_end").val() && build_number >= $("#build_number_start").val()) { - link = '' + build_number.split(' ')[0] + ''; + if (test_build_number(column_data, iter)) { + if (!isNumeric(build_number)) { + build_number = format_date(build_number.split(' ')[0]); + } + link = '' + build_number + ''; result_table_head += "" + link + ""; } } @@ -94,11 +106,10 @@ // Create table body result_table_body = ""; for (iter in column_data) { - build_number = column_data[iter]["number"].split('.')[0]; build_date = column_data[iter]["date"].split('.')[0]; - if (build_number <= $("#build_number_end").val() && build_number >= $("#build_number_start").val()) { - result_table_body += "" + build_date.split(' ')[0] + ""; + if (test_build_number(column_data, iter)) { + result_table_body += "" + format_date(build_date.split(' ')[0]) + ""; } } @@ -111,8 +122,8 @@ row = table_data[test]; for (iter in row) { - build_number = column_data[iter]["number"].split('.')[0]; - if (build_number <= $("#build_number_end").val() && build_number >= $("#build_number_start").val()) { + + if (test_build_number(column_data, iter)) { result_table_body += ''; if (row[iter]["uuid"]) { result_table_body += '' + row[iter]["passes"] + '/' + row[iter]["total"] + ''; @@ -141,6 +152,7 @@ store_filters(); update_plot(column_data, table_data, test_run_names); update_tooltips(); + add_bug_links(); } function update_tooltips() { @@ -159,30 +171,34 @@ function store_filters() { // Use jStorage to save filter values to the browser. - $.jStorage.set("target_goal", $("#target_goal").val()); - $.jStorage.set("build_number_start", $("#build_number_start").val()); - $.jStorage.set("build_number_end", $("#build_number_end").val()); - $.jStorage.set("test_select", $("#test_select").val()); - $.jStorage.set("graph_type", $('input:radio[name=graph_type]:checked').val()); + prefix = window.location.pathname.split('/').pop(); + + $.jStorage.set(prefix + "_target_goal", $("#target_goal").val()); + $.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 + "_graph_type", $('input:radio[name=graph_type]:checked').val()); } function load_filters() { // Use jStorage to load the filter values from browser. - if ($.jStorage.get("target_goal")) { - $("#target_goal").val($.jStorage.get("target_goal")); - } - if ($.jStorage.get("build_number_start")) { - $("#build_number_start").val($.jStorage.get("build_number_start")); - } - if ($.jStorage.get("build_number_end")) { - $("#build_number_end").val($.jStorage.get("build_number_end")); - } - if ($.jStorage.get("test_select")) { - $("#test_select").val($.jStorage.get("test_select")); - } - if ($.jStorage.get("graph_type")) { - if ($.jStorage.get("graph_type") == "number") { + prefix = window.location.pathname.split('/').pop(); + + if ($.jStorage.get(prefix + "_target_goal")) { + $("#target_goal").val($.jStorage.get(prefix + "_target_goal")); + } + if ($.jStorage.get(prefix + "_build_number_start")) { + $("#build_number_start").val($.jStorage.get(prefix + "_build_number_start")); + } + if ($.jStorage.get(prefix + "_build_number_end")) { + $("#build_number_end").val($.jStorage.get(prefix + "_build_number_end")); + } + if ($.jStorage.get(prefix + "_test_select")) { + $("#test_select").val($.jStorage.get(prefix + "_test_select")); + } + if ($.jStorage.get(prefix + "_graph_type")) { + if ($.jStorage.get(prefix + "_graph_type") == "number") { $('input:radio[name=graph_type][value="number"]').attr("checked", true); } else { $('input:radio[name=graph_type][value="percentage"]').attr("checked", true); @@ -239,7 +255,11 @@ for (test in table_data) { row = table_data[test]; for (iter in row) { - build_numbers.push(column_data[iter]["number"].split(' ')[0]); + build_number = column_data[iter]["number"].split(' ')[0]; + if (!isNumeric(build_number)) { + build_number = format_date(build_number); + } + build_numbers.push(build_number); } // Each test has the same number of build numbers. break; @@ -255,6 +275,12 @@ position: "ne", margin: 3, container: "#legend-container", + labelFormatter: function(label, series) { + if (label.length > 20) { + return label.substring(0,20) + "..."; + } + return label; + }, }, xaxis: { tickDecimals: 0, @@ -276,122 +302,161 @@ $.plot($("#outer-container #inner-container"), data, options); } +function test_build_number(column_data, iter) { + // Test if the build number/date is between specified number/date boundaries. + + build_number = column_data[iter]["number"].split('.')[0]; + if (isNumeric(build_number)) { + build_number = parseInt(build_number); + } + + build_number_start = $("#build_number_start").val(); + if (isNumeric(build_number_start)) { + build_number_start = parseInt(build_number_start); + } + build_number_end = $("#build_number_end").val(); + if (isNumeric(build_number_end)) { + build_number_end = parseInt(build_number_end); + } + + if (build_number <= $("#build_number_end").val() && build_number >= $("#build_number_start").val()) { + return true; + } + + return false; +} + +function isNumeric(n) { + return !isNaN(parseFloat(n)) && isFinite(n); +} + +function format_date(date_string) { + date = $.datepicker.parseDate("yy-mm-dd", date_string); + date_string = $.datepicker.formatDate("M d, yy", date); + return date_string; +} + +function add_bug_links() { + + function _submit() { + $(this).submit(); + } + var add_bug_dialog = $('#add-bug-dialog').dialog( + { + autoOpen: false, + buttons: {'Cancel': function () {$(this).dialog('close');}, 'OK': _submit }, + modal: true, + title: "Link bug to XXX" + }); + var go_to_bug_dialog = $("#go-to-bug-dialog").dialog( + { + autoOpen: false, + buttons: {'Cancel': function () {$(this).dialog('close');}, 'Remove link': _submit}, + modal: true, + title: "Link bug to XXX" + }); + + function get_testrun_and_buildnumber (element) { + var cell = element.closest('td'); + var row = cell.closest('tr'); + var testrun = $($("#test-run-names > tbody > tr")[row.index()]).text(); + var header_cells = element.closest('table').find('thead > tr > th'); + var buildnumber = $(header_cells[cell.index()]).text(); + return {testrun: $.trim(testrun), buildnumber: $.trim(buildnumber)}; + } + + function find_previous_bugs (element) { + var td = $(element).closest('td'); + var bugs = []; + var start = td; + while ((td = td.prev()) && td.size()) { + td.find(".bug-link").each( + function (index, link) { + var bug_id = $(link).data('bug-id'); + if (bugs.indexOf(bug_id) < 0) bugs.push(bug_id); + }); + } + var already_linked = []; + start.find(".bug-link").each( + function (index, link) { + var bug_id = $(link).data('bug-id'); + if (bugs.indexOf(bug_id) >= 0) { + bugs.splice(bugs.indexOf(bug_id), 1); + already_linked.push(bug_id); + } + }); + return {bugs:bugs, already_linked:already_linked}; + } + + $('a.add-bug-link').click( + function (e) { + e.preventDefault(); + + var previous = find_previous_bugs($(this)); + var prev_div = add_bug_dialog.find('div.prev'); + var names = get_testrun_and_buildnumber($(this)); + + if (previous.bugs.length) { + var html = ''; + prev_div.show(); + html = '

Use a bug previously linked to ' + names.testrun + ':

    '; + for (var i = 0; i < previous.already_linked.length; i++) { + html += '
  • ' + previous.already_linked[i] + ' (already linked)
  • '; + } + for (var i = 0; i < previous.bugs.length; i++) { + html += '
  • ' + + previous.bugs[i] + '
  • '; + } + html += '
'; + html += "

Or enter another bug number:

"; + prev_div.html(html); + prev_div.find('a').click( + function (e) { + e.preventDefault(); + add_bug_dialog.find('input[name=bug]').val($(this).data('bug-id')); + add_bug_dialog.submit(); + }); + } else { + prev_div.hide(); + } + + var title = "Link a bug to the '" + names.testrun + + "' run of build " + names.buildnumber; + add_bug_dialog.find('input[name=uuid]').val($(this).closest('td').data('uuid')); + add_bug_dialog.dialog('option', 'title', title); + add_bug_dialog.dialog('open'); + }); + + $("a.bug-link").click( + function (e) { + e.preventDefault(); + var names = get_testrun_and_buildnumber($(this)); + var title = "Bug linked to the '" + names.testrun + + "' run of build " + names.buildnumber; + go_to_bug_dialog.find('input[name=uuid]').val($(this).closest('td').data('uuid')); + go_to_bug_dialog.find('input[name=bug]').val($(this).data('bug-id')); + go_to_bug_dialog.find('a').attr('href', $(this).attr('href')); + go_to_bug_dialog.find('a').text('View bug ' + $(this).data('bug-id')); + go_to_bug_dialog.dialog('option', 'title', title); + go_to_bug_dialog.dialog('open'); + }); +} + $(window).ready( function () { + update_filters(columns, test_names); + update_table(columns, chart_data, test_names); // Hook up the event and run resize ASAP (looks jumpy in FF if you // don't run it here). $(window).resize(_resize); - $("#scroller").scrollLeft(100000); _resize(); _fixRowHeights(); - function _submit() { - $(this).submit(); - } - var add_bug_dialog = $('#add-bug-dialog').dialog( - { - autoOpen: false, - buttons: {'Cancel': function () {$(this).dialog('close');}, 'OK': _submit }, - modal: true, - title: "Link bug to XXX" - }); - var go_to_bug_dialog = $("#go-to-bug-dialog").dialog( - { - autoOpen: false, - buttons: {'Cancel': function () {$(this).dialog('close');}, 'Remove link': _submit}, - modal: true, - title: "Link bug to XXX" - }); - - function get_testrun_and_buildnumber (element) { - var cell = element.closest('td'); - var row = cell.closest('tr'); - var testrun = $($("#test-run-names > tbody > tr")[row.index()]).text(); - var header_cells = element.closest('table').find('thead > tr > th'); - var buildnumber = $(header_cells[cell.index()]).text(); - return {testrun: $.trim(testrun), buildnumber: $.trim(buildnumber)}; - } - - function find_previous_bugs (element) { - var td = $(element).closest('td'); - var bugs = []; - var start = td; - while ((td = td.prev()) && td.size()) { - td.find(".bug-link").each( - function (index, link) { - var bug_id = $(link).data('bug-id'); - if (bugs.indexOf(bug_id) < 0) bugs.push(bug_id); - }); - } - var already_linked = []; - start.find(".bug-link").each( - function (index, link) { - var bug_id = $(link).data('bug-id'); - if (bugs.indexOf(bug_id) >= 0) { - bugs.splice(bugs.indexOf(bug_id), 1); - already_linked.push(bug_id); - } - }); - return {bugs:bugs, already_linked:already_linked}; - } - - $('a.add-bug-link').click( - function (e) { - e.preventDefault(); - - var previous = find_previous_bugs($(this)); - var prev_div = add_bug_dialog.find('div.prev'); - var names = get_testrun_and_buildnumber($(this)); - - if (previous.bugs.length) { - var html = ''; - prev_div.show(); - html = '

Use a bug previously linked to ' + names.testrun + ':

    '; - for (var i = 0; i < previous.already_linked.length; i++) { - html += '
  • ' + previous.already_linked[i] + ' (already linked)
  • '; - } - for (var i = 0; i < previous.bugs.length; i++) { - html += '
  • ' + - previous.bugs[i] + '
  • '; - } - html += '
'; - html += "

Or enter another bug number:

"; - prev_div.html(html); - prev_div.find('a').click( - function (e) { - e.preventDefault(); - add_bug_dialog.find('input[name=bug]').val($(this).data('bug-id')); - add_bug_dialog.submit(); - }); - } else { - prev_div.hide(); - } - - var title = "Link a bug to the '" + names.testrun + - "' run of build " + names.buildnumber; - add_bug_dialog.find('input[name=uuid]').val($(this).closest('td').data('uuid')); - add_bug_dialog.dialog('option', 'title', title); - add_bug_dialog.dialog('open'); - }); - - $("a.bug-link").click( - function (e) { - e.preventDefault(); - var names = get_testrun_and_buildnumber($(this)); - var title = "Bug linked to the '" + names.testrun + - "' run of build " + names.buildnumber; - go_to_bug_dialog.find('input[name=uuid]').val($(this).closest('td').data('uuid')); - go_to_bug_dialog.find('input[name=bug]').val($(this).data('bug-id')); - go_to_bug_dialog.find('a').attr('href', $(this).attr('href')); - go_to_bug_dialog.find('a').text('View bug ' + $(this).data('bug-id')); - go_to_bug_dialog.dialog('option', 'title', title); - go_to_bug_dialog.dialog('open'); - }); + add_bug_links(); + }); // Because what resize does depends on the final sizes of elements, // run it again after everything is loaded (things end up wrong in // chromium if you don't do this). $(window).load(_resize); $(window).load(_fixRowHeights); -$(window).load(function() {update_filters(columns, test_names);}); -$(window).load(function() {update_table(columns, chart_data, test_names);});