Title: [145447] trunk/Tools
Revision
145447
Author
jpar...@chromium.org
Date
2013-03-11 18:07:10 -0700 (Mon, 11 Mar 2013)

Log Message

Dashboard cleanup: Create ui.Errors
https://bugs.webkit.org/show_bug.cgi?id=111785

Reviewed by Ojan Vafai.

Create ui.Errors for handling errors the dashboards
encounter. Loader now has a Error object that it can add to,
and individual dashboards can show errors when desired.
Currently, only flakiness_db shows errors, but this is
generic and there is no reason why other dbs wouldn't want to
show errors.

* TestResultServer/static-dashboards/dashboard_base.js:
(resourceLoadingComplete):
* TestResultServer/static-dashboards/flakiness_dashboard.js:
(generatePage):
* TestResultServer/static-dashboards/loader.js:
(.):
* TestResultServer/static-dashboards/ui.js:
(.):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (145446 => 145447)


--- trunk/Tools/ChangeLog	2013-03-12 01:05:41 UTC (rev 145446)
+++ trunk/Tools/ChangeLog	2013-03-12 01:07:10 UTC (rev 145447)
@@ -1,3 +1,26 @@
+2013-03-11  Julie Parent  <jpar...@chromium.org>
+
+        Dashboard cleanup: Create ui.Errors
+        https://bugs.webkit.org/show_bug.cgi?id=111785
+
+        Reviewed by Ojan Vafai.
+        
+        Create ui.Errors for handling errors the dashboards
+        encounter. Loader now has a Error object that it can add to,
+        and individual dashboards can show errors when desired.
+        Currently, only flakiness_db shows errors, but this is 
+        generic and there is no reason why other dbs wouldn't want to
+        show errors.
+
+        * TestResultServer/static-dashboards/dashboard_base.js:
+        (resourceLoadingComplete):
+        * TestResultServer/static-dashboards/flakiness_dashboard.js:
+        (generatePage):
+        * TestResultServer/static-dashboards/loader.js:
+        (.):
+        * TestResultServer/static-dashboards/ui.js:
+        (.):
+
 2013-03-08  Geoffrey Garen  <gga...@apple.com>
 
         Some StringHasher tests are broken because of missing null termination

Modified: trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js (145446 => 145447)


--- trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js	2013-03-12 01:05:41 UTC (rev 145446)
+++ trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js	2013-03-12 01:07:10 UTC (rev 145447)
@@ -440,43 +440,8 @@
     return string.endsWith(window.location.pathname, 'flakiness_dashboard.html');
 }
 
-// String of error messages to display to the user.
-var g_errorMessages = '';
-
-// Record a new error message.
-// @param {string} errorMsg The message to show to the user.
-function addError(errorMsg)
+function resourceLoadingComplete()
 {
-    g_errorMessages += errorMsg + '<br>';
-}
-
-
-// If there are errors, show big and red UI for errors so as to be noticed.
-function showErrors()
-{
-    var errors = $('errors');
-
-    if (!g_errorMessages) {
-        if (errors)
-            errors.parentNode.removeChild(errors);
-        return;
-    }
-
-    if (!errors) {
-        errors = document.createElement('H2');
-        errors.style.color = 'red';
-        errors.id = 'errors';
-        document.body.appendChild(errors);
-    }
-
-    errors.innerHTML = g_errorMessages;
-}
-
-function resourceLoadingComplete(errorMsgs)
-{
-    if (errorMsgs)
-        addError(errorMsgs)
-
     handleLocationChange();
 }
 

Modified: trunk/Tools/TestResultServer/static-dashboards/flakiness_dashboard.js (145446 => 145447)


--- trunk/Tools/TestResultServer/static-dashboards/flakiness_dashboard.js	2013-03-12 01:05:41 UTC (rev 145446)
+++ trunk/Tools/TestResultServer/static-dashboards/flakiness_dashboard.js	2013-03-12 01:07:10 UTC (rev 145447)
@@ -143,7 +143,7 @@
         return;
 
     document.body.innerHTML = '<div id="loading-ui">LOADING...</div>';
-    showErrors();
+    g_resourceLoader.showErrors();
 
     // tests expands to all tests that match the CSV list.
     // result expands to all tests that ever have the given result
@@ -1153,7 +1153,7 @@
     return '<a href="" + url + '" target="_blank">' + text + '</a>';
 }
 
-// FIXME: replaced with ui.chromiumRevisionLink/ui.webKitRevisionLink
+// FIXME: replaced with ui.html.chromiumRevisionLink/ui.html.webKitRevisionLink
 function createBlameListHTML(revisions, index, urlBase, separator, repo)
 {
     var thisRevision = revisions[index];

Modified: trunk/Tools/TestResultServer/static-dashboards/loader.js (145446 => 145447)


--- trunk/Tools/TestResultServer/static-dashboards/loader.js	2013-03-12 01:05:41 UTC (rev 145446)
+++ trunk/Tools/TestResultServer/static-dashboards/loader.js	2013-03-12 01:07:10 UTC (rev 145447)
@@ -68,6 +68,8 @@
     this._buildersThatFailedToLoad = [];
     this._staleBuilders = [];
     this._loadingComplete = false;
+    this._errors = new ui.Errors();
+
 }
 
 loader.Loader.prototype = {
@@ -79,15 +81,20 @@
     {
         return this._loadingComplete;
     },
+    showErrors: function() 
+    {
+        this._errors.show();
+    },
     _loadNext: function()
     {
         var loadingStep = this._loadingSteps.shift();
         if (!loadingStep) {
             this._loadingComplete = true;
+            this._addErrors();
             // FIXME(jparent): Loader should not know about global
             // functions, should use a callback or dispatch load
             // event instead.
-            resourceLoadingComplete(this._getLoadingErrorMessages());
+            resourceLoadingComplete();
             return;
         }
         loadingStep.apply(this);
@@ -229,16 +236,13 @@
                         console.error('Could not load expectations file for ' + platformName);
                     }, platformWithExpectations));
     },
-    _getLoadingErrorMessages: function()
+    _addErrors: function()
     {
-        var errorMsgs = '';
         if (this._buildersThatFailedToLoad.length)
-            errorMsgs += 'ERROR: Failed to get data from ' + this._buildersThatFailedToLoad.toString() + '.<br>';
+            this._errors.addError('ERROR: Failed to get data from ' + this._buildersThatFailedToLoad.toString() +'.');
 
         if (this._staleBuilders.length)
-            errorMsgs +='ERROR: Data from ' + this._staleBuilders.toString() + ' is more than 1 day stale.<br>';
-
-        return errorMsgs;
+            this._errors.addError('ERROR: Data from ' + this._staleBuilders.toString() + ' is more than 1 day stale.');
     }
 }
 

Modified: trunk/Tools/TestResultServer/static-dashboards/loader_unittests.js (145446 => 145447)


--- trunk/Tools/TestResultServer/static-dashboards/loader_unittests.js	2013-03-12 01:05:41 UTC (rev 145446)
+++ trunk/Tools/TestResultServer/static-dashboards/loader_unittests.js	2013-03-12 01:07:10 UTC (rev 145447)
@@ -152,7 +152,8 @@
     var resourceLoader = new loader.Loader();
     resourceLoader._buildersThatFailedToLoad = ['builder1', 'builder2'];
     resourceLoader._staleBuilders = ['staleBuilder1'];
-    equal(resourceLoader._getLoadingErrorMessages(), 'ERROR: Failed to get data from builder1,builder2.<br>ERROR: Data from staleBuilder1 is more than 1 day stale.<br>');
+    resourceLoader._addErrors();
+    equal(resourceLoader._errors._messages, 'ERROR: Failed to get data from builder1,builder2.<br>ERROR: Data from staleBuilder1 is more than 1 day stale.<br>');
 });
 
 test('Loaded state set', 2, function() {

Modified: trunk/Tools/TestResultServer/static-dashboards/ui.js (145446 => 145447)


--- trunk/Tools/TestResultServer/static-dashboards/ui.js	2013-03-12 01:05:41 UTC (rev 145446)
+++ trunk/Tools/TestResultServer/static-dashboards/ui.js	2013-03-12 01:07:10 UTC (rev 145447)
@@ -196,4 +196,30 @@
         'http://trac.webkit.org/log/trunk/?rev=<rev1>&stop_rev=<rev2>&limit=100&verbose=on');
 }
 
+
+ui.Errors = function() {
+    this._messages = '';
+    // Element to display the errors within.
+    this._containerElement = null;
+}
+
+ui.Errors.prototype = {
+    show: function()
+    {
+        if (!this._containerElement) {
+            this._containerElement = document.createElement('H2');
+            this._containerElement.style.color = 'red';
+            this._containerElement.id = 'errors';
+            document.body.appendChild(this._containerElement);
+        }
+
+        this._containerElement.innerHTML = this._messages;
+    },
+    // Record a new error message.
+    addError: function(message)
+    {
+        this._messages += message + '<br>';
+    }
+}
+
 })();
\ No newline at end of file
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to