Merge branch '3781-browser-friendly-servers' refs #3781
[arvados.git] / apps / workbench / app / assets / javascripts / pipeline_instances.js
index 78fd195cdca3f26c8163bd030c679428abd658f2..102c60233a6e470aca3898321f7032eb1b15ce81 100644 (file)
@@ -1,5 +1,5 @@
 function run_pipeline_button_state() {
-    var a = $('a.editable.required.editable-empty,input.form-control.required[value=]');
+    var a = $('a.editable.required.editable-empty,input.form-control.required[value=""]');
     if (a.length > 0) {
         $(".run-pipeline-button").addClass("disabled");
     }
@@ -47,7 +47,11 @@ $(document).on('ready ajax:complete', function() {
     run_pipeline_button_state();
 });
 
-$(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event, eventData){
+$(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event, eventData) {
+    if (this != event.target) {
+        // Not interested in events sent to child nodes.
+        return;
+    }
     if (eventData.event_type == "update" &&
         eventData.properties.old_attributes.state != eventData.properties.new_attributes.state)
     {
@@ -56,25 +60,49 @@ $(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event,
 });
 
 $(document).on('arv-log-event', '.arv-log-event-subscribe-to-pipeline-job-uuids', function(event, eventData){
-    if (eventData.event_type == "create" || eventData.event_type == "update") {
-        if (eventData.object_kind == 'arvados#pipelineInstance') {
-            var objs = "";
-            var components = eventData.properties.new_attributes.components;
-            for (a in components) {
-                if (components[a].job && components[a].job.uuid) {
-                    objs += " " + components[a].job.uuid;
-                }
-            }
-            $(event.target).attr("data-object-uuids", eventData.object_uuid + objs);
+    if (this != event.target) {
+        // Not interested in events sent to child nodes.
+        return;
+    }
+    if (!((eventData.object_kind == 'arvados#pipelineInstance') &&
+          (eventData.event_type == "create" ||
+           eventData.event_type == "update") &&
+         eventData.properties &&
+         eventData.properties.new_attributes &&
+         eventData.properties.new_attributes.components)) {
+        return;
+    }
+    var objs = "";
+    var components = eventData.properties.new_attributes.components;
+    for (a in components) {
+        if (components[a].job && components[a].job.uuid) {
+            objs += " " + components[a].job.uuid;
         }
     }
+    $(event.target).attr("data-object-uuids", eventData.object_uuid + objs);
+});
+
+$(document).on('ready ajax:success', function() {
+    $('.arv-log-refresh-control').each(function() {
+        var uuids = $(this).attr('data-object-uuids');
+        var $pane = $(this).closest('[data-pane-content-url]');
+        $pane.attr('data-object-uuids', uuids);
+    });
 });
 
 $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
+    if (this != event.target) {
+        // Not interested in events sent to child nodes.
+        return;
+    }
     var wasatbottom = ($(this).scrollTop() + $(this).height() >= this.scrollHeight);
 
     if (eventData.event_type == "stderr" || eventData.event_type == "stdout") {
-        $(this).append(eventData.properties.text);
+        if( eventData.prepend ) {
+            $(this).prepend(eventData.properties.text);
+        } else {
+            $(this).append(eventData.properties.text);
+        }
     }
 
     if (wasatbottom) {
@@ -96,5 +124,9 @@ var showhide_compare = function() {
         });
     }
 };
-$('[data-object-uuid*=-d1hrv-] input[name="uuids[]"]').on('click', showhide_compare);
-showhide_compare();
+$(document).on('change', '[data-object-uuid*=-d1hrv-] input[name="uuids[]"]', function(e) {
+    if(e.target == this) {
+        showhide_compare();
+    }
+});
+$(document).on('ready ajax:success', showhide_compare);