[ARVADOS] updated: ab9955f1ab1aef27b3eecf5d739bf0934d29cdfd

git at public.curoverse.com git at public.curoverse.com
Thu Mar 19 18:16:14 EDT 2015


Summary of changes:
 .../app/assets/javascripts/job_log_graph.js        | 33 ++++++++++++----------
 1 file changed, 18 insertions(+), 15 deletions(-)

  discards  ea344b06c94a386355ad040edd9bd3e4726ac964 (commit)
       via  ab9955f1ab1aef27b3eecf5d739bf0934d29cdfd (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (ea344b06c94a386355ad040edd9bd3e4726ac964)
            \
             N -- N -- N (ab9955f1ab1aef27b3eecf5d739bf0934d29cdfd)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit ab9955f1ab1aef27b3eecf5d739bf0934d29cdfd
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Mar 19 18:12:21 2015 -0400

    5276: Reveal and update the log graph as soon as the first data point
    arrives, rather than waiting for the redraw timer.
    
    Return an empty hover tooltip for the placeholder data point. (The
    placeholder series is only added when the graph is empty and hideHover
    is true, but it doesn't get deleted later when hideHover goes false.)
    
    Render the graph in a show() callback to ensure the div is visible
    when Morris creates its SVG element: otherwise the SVG can end up
    being created with height=1px. This addresses bugs like "graph doesn't
    show up sometimes" and "data point hover tooltips show up, but there's
    no graph".

diff --git a/apps/workbench/app/assets/javascripts/job_log_graph.js b/apps/workbench/app/assets/javascripts/job_log_graph.js
index 9daabe1..a2d3b04 100644
--- a/apps/workbench/app/assets/javascripts/job_log_graph.js
+++ b/apps/workbench/app/assets/javascripts/job_log_graph.js
@@ -200,10 +200,8 @@ function createJobGraph(elementName) {
         hideHover: 'auto',
         parseTime: true,
         hoverCallback: function(index, options, content) {
-            var s = "<div class='morris-hover-row-label'>";
-            s += options.data[index][options.xkey];
-            s += "</div> ";
-            for( i = 0; i < jobGraphSortedSeries.length; i++ ) {
+            var s = '';
+            for (var i=0; i < jobGraphSortedSeries.length; i++) {
                 var sortedIndex = jobGraphSortedSeries[i];
                 var series = options.ykeys[sortedIndex];
                 var datum = options.data[index][series];
@@ -237,7 +235,15 @@ function createJobGraph(elementName) {
                 point += "</div> ";
                 s += point;
             }
-            return s;
+            if (s === '') {
+                // No Y coordinates? This isn't a real data point,
+                // it's just the placeholder we use to make sure the
+                // graph can render when empty. Don't show a tooltip.
+                return '';
+            }
+            return ("<div class='morris-hover-row-label'>" +
+                    options.data[index][options.xkey] +
+                    "</div> " + s);
         }
     }
     if( emptyGraph ) {
@@ -245,6 +251,7 @@ function createJobGraph(elementName) {
         graphteristics['parseTime'] = false;
         graphteristics['hideHover'] = 'always';
     }
+    $('#' + elementName).html('');
     window.jobGraph = Morris.Line( graphteristics );
     if( emptyGraph ) {
         jobGraphData = [];
@@ -267,16 +274,44 @@ function isJobSeriesRescalable( series ) {
     return !/-cpu$/.test(series);
 }
 
-$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
+function processLogEventForGraph(event, eventData) {
     if( eventData.properties.text ) {
         eventData.properties.text.split('\n').forEach( function( logLine ) {
             processLogLineForChart( logLine );
         } );
     }
-} );
+}
+
+$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
+    processLogEventForGraph(event, eventData);
+    if (!window.jobGraphShown) {
+        // Draw immediately, instead of waiting for the 5-second
+        // timer.
+        redrawIfNeeded.call(window, this);
+    }
+});
+
+function redrawIfNeeded(graph_div) {
+    if (!window.redraw) {
+        return;
+    }
+    window.redraw = false;
+
+    if (window.recreate) {
+        // Series have changed: we need to draw an entirely new graph.
+        // Running createJobGraph in a show() callback ensures the div
+        // is fully shown when morris uses it to size its svg element.
+        $(graph_div).show(0, createJobGraph.bind(window, $(graph_div).attr('id')));
+        window.jobGraphShown = true;
+        window.recreate = false;
+    } else {
+        window.jobGraph.setData(window.jobGraphData);
+    }
+}
 
 $(document).on('ready ajax:complete', function() {
     $('#log_graph_div').not('.graph-is-setup').addClass('graph-is-setup').each( function( index, graph_div ) {
+        window.jobGraphShown = false;
         window.jobGraphData = [];
         window.jobGraphSeries = [];
         window.jobGraphSortedSeries = [];
@@ -284,30 +319,17 @@ $(document).on('ready ajax:complete', function() {
         window.recreate = false;
         window.redraw = false;
 
-        createJobGraph($(graph_div).attr('id'));
-        var object_uuid = $(graph_div).data('object-uuid');
-        // if there are any listeners for this object uuid or "all", we will trigger the event
-        var matches = ".arv-log-event-listener[data-object-uuid=\"" + object_uuid + "\"],.arv-log-event-listener[data-object-uuids~=\"" + object_uuid + "\"]";
-
-        $(document).trigger('ajax:send');
         $.get('/jobs/' + $(graph_div).data('object-uuid') + '/logs.json', function(data) {
             data.forEach( function( entry ) {
-                $(matches).trigger('arv-log-event', entry);
+                processLogEventForGraph({}, entry);
             });
+            // Update the graph now to show the recent data points
+            // received via /logs.json (along with any new data points
+            // we received via websockets while waiting for /logs.json
+            // to respond).
+            redrawIfNeeded(graph_div);
         });
 
-        setInterval( function() {
-            if (window.recreate || window.redraw) {
-                if (window.recreate) {
-                    // series have changed, draw entirely new graph.
-                    $(graph_div).html('').show(500);
-                    createJobGraph($(graph_div).attr('id'));
-                } else {
-                    jobGraph.setData(jobGraphData);
-                }
-                window.recreate = false;
-                window.redraw = false;
-            }
-        }, 5000);
+        setInterval(redrawIfNeeded.bind(window, graph_div), 5000);
     });
 });

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list