Bug 909368 - Display status and text from callback error data. r=mcote
authorsarvesh.onlyme@gmail.com
Wed, 29 Jan 2014 11:33:38 -0500
changeset 222 368d1befd741361d39824ec0df80bf7dc268661a
parent 221 1deab2f0b812b73ad28bfa018576a49a5f2852ad
child 223 fc708b60a23d1d249a7f807245c2eb703e1f979b
push id208
push usermcote@mozilla.com
push dateWed, 29 Jan 2014 16:33:43 +0000
reviewersmcote
bugs909368
Bug 909368 - Display status and text from callback error data. r=mcote
html/index.html
html/scripts/woo.bugs.js
html/scripts/woo.main.js
html/scripts/woo.utils.js
--- a/html/index.html
+++ b/html/index.html
@@ -172,18 +172,18 @@ occurs 100% of the time that bug B occur
               <p>You can use the top N filters in QuickSearch mode in both the include and exclude filters.  For example,
               to see what the Orange Factor would look like if the top 10 bugs were fixed, select "QuickSearch" from
               the exclude filter dropdown, then select top 10 bugs and apply.  You will now see the graph with the
               top 10 bugs removed beside the real Orange Factor graph.</p>
 
               <p>If necessary, you can get more complicated: if you choose to include the top 10 bugs and exclude the
               top 15, you will get information on the 16th to 25th highest-ranking bugs, inclusive.</p>
 	    </div>
-      <div id="dlgErrorHandler500">
-        <b>500: Internal Server Error</b>
+      <div id="dlgErrorHandler">
+        <span></span>
       </div>
     </div>
 
     <script src="scripts/jquery.min.js"></script>
     <script src="scripts/jquery-ui-1.8.4.custom.min.js"></script>
     <script src="scripts/jquery.flot.min.js"></script>
     <script src="scripts/jquery.flot.tickrotor.js"></script>
     <script src="scripts/jquery.flot.axislabels.js"></script>
--- a/html/scripts/woo.bugs.js
+++ b/html/scripts/woo.bugs.js
@@ -60,17 +60,17 @@ function BugDetailsStore() {
       var self = this;
       $.ajax({
         url: es_server + "/bugdetails?bugid=" + unknownBugIds.join(","),
         dataType: 'json',
         success: function(data) {
           self.doneRequest(data);
         },
         error: function(data) {
-          $('#dlgErrorHandler500').dialog('open');
+          errorCall(data.status, data.statusText);
         }
       });
     } else {
       this.doneRequest({ bugs: {} });
     }
   };
 }
 
@@ -339,25 +339,25 @@ function displayBug(id, titleid, args) {
                     details += ' [no&nbsp;log&nbsp;found]';
                   } else {
                     details += ' <a href="' + data[testrun][0]['logurl'] + '">[full&nbsp;log]</a>';
                   }
                   $("#" + spanId + " .detailslinks").html(details);
                 }
               },
               error: function(data){
-                $('#dlgErrorHandler500').dialog('open');
+                errorCall(data.status, data.statusText);
               }
             });
           }
         }
       });
     },
     error: function(data) {
-      $('#dlgErrorHandler500').dialog('open');
+      errorCall(data.status, data.statusText);
     }
   });
 }
 
 function buildTopBugsFilters(args, bugCountId, dayCountId) {
   function attributes(count) {
     var attrs = args.dayCount == count ? ' selected' : '';
     if (count != 'All' && (getDate(args.endday) - getDate(args.startday)) / (1000*60*60*24) < count) {
@@ -584,17 +584,17 @@ function showTopBugs(id, titleid, args, 
         return false;
       };
 
       // load the new page if enter is hit on the bug count (form submits)
       // or if day-count dropdown changes.
       $('#' + dayCountId).change(onChange);
     },
     error: function(data){
-      $('#dlgErrorHandler500').dialog('open');
+      errorCall(data.status, data.statusText);
     }
   });
 }
 
 /**
  * Tallies oranges for each unique combination of different types within
  * the given categories (platform, testrun, buildtype, and/or branch).
  * For example, if baseCategories is ['platform', 'buildtypes'], the function
@@ -785,17 +785,17 @@ function showBugCount(id, titleid, args,
       }
       showBarGraphDay(graphdata, cols, startday, endday);
 
       simpleBugDetailsTable(args, oranges);
       barGraphDetails(cols, graphdata);
       machineDetailsTable(es_args, oranges);
     },
     error: function (data) {
-      $('#dlgErrorHandler500').dialog('open');
+      errorCall(data.status, data.statusText);
     }
   });
 }
 
 function displayCorrelations(id, titleid, args) {
   normDateArgs(args);
   clearPage();
   displayRangeControlTitle(titleid, args, 'Bug correlations, ',
@@ -889,17 +889,17 @@ function displayCorrelations(id, titleid
           bFilter: false,
           bInfo: false
         });
         // minimum table size is neither necessary nor desirable here
         $(bugCorrelations.find('.dataTables_wrapper')).removeClass('dataTables_wrapper');
       }
     },
     error: function(data) {
-      $('#dlgErrorHandler500').dialog('open');
+      errorCall(data.status, data.statusText);
     }
   });
 }
 
 var BugPopup = function() {
   var currentPopup = null;
   var currentPopupBugId = 0;
   var currentId = null;
--- a/html/scripts/woo.main.js
+++ b/html/scripts/woo.main.js
@@ -34,17 +34,17 @@ function displayMetric(id, displayName, 
                    title + metric.orangeFactor);
       dateRangeControls.show($("#datepickstartspan"),
                              $("#datepickendspan"));
       if (callback !== undefined) {
         callback(metric);
       }
     },
     error: function(data) {
-      $('#dlgErrorHandler500').dialog('open');
+      errorCall(data.status, data.statusText);
     }
   });
 }
 
 function displayRangeControlTitle(id, args, titlePrefix, displayName) {
   var title = titlePrefix + args.startday + ' to ' + args.endday;
   var header = titlePrefix + args.startday + '<span id="datepickstartspan"></span> to ' + args.endday + '<span id="datepickendspan"></span>';
   displayTitle(id, header, title);
@@ -205,17 +205,17 @@ function showOrangeFactor(id, titleid, a
                               getDate(args.endday).getTime(),
                               ["orange count per test run",
                                "orange, test run count"]);
       }
       simpleBugDetailsTable(args, filteredOranges);
       machineDetailsTable(es_args, filteredOranges);
     },
     error: function( data ){
-      $('#dlgErrorHandler500').dialog('open');
+      errorCall(data.status, data.statusText);
     }
   });
 }
 
 function displayOverview() {
   clearPage();
   loadSearchQuery("#display", "#overall");
 }
--- a/html/scripts/woo.utils.js
+++ b/html/scripts/woo.utils.js
@@ -416,17 +416,17 @@ function apiArgs(args) {
 function machineDetailsTable(es_args, dates) {
   $.ajax({
     url: es_server + "/testsbymachine" + es_args,
     dataType: 'json',
     success: function(data) {
       drawMachineDetailsTable(dates, data);
     },
     error: function(data){
-      $('#dlgErrorHandler500').dialog('open');
+      errorCall(data.status, data.statusText);
     }
   });
 }
 
 function drawMachineDetailsTable(dates, testruns) {
   var machineCount = {};
   var machineName, bug, test;
   var date, i;
@@ -1043,17 +1043,17 @@ var Filters = function() {
         for (var key in keys) {
           filterSettings[filterId].filterDetails.resolvedIds.push(keys[key]);
         }
         if (--awaitingQuicksearchResponse == 0) {
           initCallback(filterSettings);
         }
       },
       error: function( data ){
-        $('#dlgErrorHandler500').dialog('open');
+        errorCall(data.status, data.statusText);
       }
     });
   };
 
   var showFilterControls = function() {
     $("#display").show();
   };
 
@@ -1232,8 +1232,13 @@ var DataTables = function() {
 
     return $(newDiv.find("table"));
   }
 
   return {
     addTable: addTable
   };
 }();
+
+function errorCall(status, statusText) {
+  $('#dlgErrorHandler span').text(status + ": " + statusText);
+  $('#dlgErrorHandler').dialog('open');
+}
\ No newline at end of file