[ARVADOS] updated: 222ce2930a9ab719e2f6f8d0c9268535f7b50abf

git at public.curoverse.com git at public.curoverse.com
Wed Oct 22 16:40:52 EDT 2014


Summary of changes:
 .../app/assets/javascripts/pipeline_instances.js   | 14 +++--
 apps/workbench/app/assets/javascripts/tab_panes.js | 71 ++++++++++++----------
 .../controllers/pipeline_instances_controller.rb   |  6 +-
 .../app/views/application/_content.html.erb        |  5 +-
 apps/workbench/app/views/jobs/_show_log.html.erb   |  7 +--
 .../workbench/app/views/jobs/_show_status.html.erb | 19 ++++--
 apps/workbench/app/views/jobs/show.html.erb        | 44 ++++----------
 .../pipeline_instances/_running_component.html.erb |  2 +-
 .../app/views/pipeline_instances/show.html.erb     |  4 +-
 apps/workbench/app/views/projects/index.html.erb   | 10 +--
 10 files changed, 88 insertions(+), 94 deletions(-)

       via  222ce2930a9ab719e2f6f8d0c9268535f7b50abf (commit)
      from  47221ee04bee623850c559274b5ff64fe3068ae6 (commit)

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 222ce2930a9ab719e2f6f8d0c9268535f7b50abf
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Oct 22 16:40:45 2014 -0400

    4084: Job display, log and buttons refresh using same mechanism as pipeline instances.
    * Job cancel button is now an AJAX call instead of a page reload.
    * Remove "cancel job" button from tab line buttons of job page since it is redundant.
    * Fix job status rendering to include progress bar
    * Added no_auto_reload option to tab to suppress reload on click.
    * Dashboard now uses 'arv-refresh-on-log-event' with a 15 second throttle

diff --git a/apps/workbench/app/assets/javascripts/pipeline_instances.js b/apps/workbench/app/assets/javascripts/pipeline_instances.js
index 1868b38..b00f547 100644
--- a/apps/workbench/app/assets/javascripts/pipeline_instances.js
+++ b/apps/workbench/app/assets/javascripts/pipeline_instances.js
@@ -47,6 +47,14 @@ $(document).on('ready ajax:complete', function() {
     run_pipeline_button_state();
 });
 
+$(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event, eventData){
+    if (eventData.event_type == "update" &&
+        eventData.properties.old_attributes.state != eventData.properties.new_attributes.state)
+    {
+        $(event.target).trigger('arv:pane:reload');
+    }
+});
+
 $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
     var wasatbottom = ($(this).scrollTop() + $(this).height() >= this.scrollHeight);
 
@@ -86,9 +94,3 @@ var showhide_compare = function() {
 };
 $('[data-object-uuid*=-d1hrv-] input[name="uuids[]"]').on('click', showhide_compare);
 showhide_compare();
-
-setInterval(function(){
-    if ($('[data-pipeline-state=RunningOnServer],[data-pipeline-state=RunningOnClient]').length > 0) {
-        $('#Components-tab,#Graph-tab,#pipeline-instance-tab-buttons').trigger('arv:pane:reload');
-    }
-}, 15000);
diff --git a/apps/workbench/app/assets/javascripts/tab_panes.js b/apps/workbench/app/assets/javascripts/tab_panes.js
index 7e2527e..b856663 100644
--- a/apps/workbench/app/assets/javascripts/tab_panes.js
+++ b/apps/workbench/app/assets/javascripts/tab_panes.js
@@ -23,34 +23,42 @@ $(document).on('shown.bs.tab', '[data-toggle="tab"]', function(event) {
 $(document).on('arv:pane:reload', function(e) {
     e.stopPropagation();
 
-    if ($(e.target).hasClass('pane-loading')) {
+    var etarget = $(e.target);
+
+    if (etarget.hasClass('pane-loading')) {
         // Already loading, mark stale to schedule a reload after this one.
-        console.log(e.target.id + " stale");
-        $(e.target).addClass('pane-stale');
+        //console.log(e.target.id + " stale");
+        etarget.addClass('pane-stale');
         return;
     }
 
-    var throttle = $(e.target).attr('data-load-throttle');
-    if (throttle) {
-        var now = (new Date()).getTime();
-        var loaded_at = $(e.target).attr('data-loaded-at');
-        if (loaded_at && (now - loaded_at) < throttle) {
-            setTimeout(function() {
-                $(e.target).trigger('arv:pane:reload');
-            });
-            return;
-        }
+    if (etarget.hasClass('pane-no-auto-reload') && etarget.hasClass('pane-loaded')) {
+        // Have to explicitly remove pane-loaded if we want it to reload.
+        return;
+    }
+
+    var throttle = etarget.attr('data-load-throttle');
+    if (!throttle) {
+        throttle = 3000;
+    }
+    var now = (new Date()).getTime();
+    var loaded_at = etarget.attr('data-loaded-at');
+    if (loaded_at && (now - loaded_at) < throttle) {
+        setTimeout(function() {
+            etarget.trigger('arv:pane:reload');
+        });
+        return;
     }
 
-    var $pane = $($(e.target).attr('href'));
+    var $pane = $(etarget.attr('href'));
     if ($pane.hasClass('active')) {
-        console.log(e.target.id + " loading");
+        //console.log(e.target.id + " loading");
 
-        $(e.target).removeClass('pane-loaded');
-        $(e.target).removeClass('pane-stale');
-        $(e.target).addClass('pane-loading');
+        etarget.removeClass('pane-loaded');
+        etarget.removeClass('pane-stale');
+        etarget.addClass('pane-loading');
 
-        var content_url = $(e.target).attr('data-pane-content-url');
+        var content_url = etarget.attr('data-pane-content-url');
         $.ajax(content_url, {dataType: 'html', type: 'GET', context: $pane}).
             done(function(data, status, jqxhr) {
                 // Preserve collapsed state
@@ -67,15 +75,15 @@ $(document).on('arv:pane:reload', function(e) {
                     }
                 });
                 $pane.html(tmp);
-                $(e.target).removeClass('pane-loading');
-                $(e.target).addClass('pane-loaded');
-                $(e.target).attr('data-loaded-at', (new Date()).getTime());
+                etarget.removeClass('pane-loading');
+                etarget.addClass('pane-loaded');
+                etarget.attr('data-loaded-at', (new Date()).getTime());
                 $pane.trigger('arv:pane:loaded');
 
-                console.log(e.target.id + " loaded");
+                //console.log(e.target.id + " loaded");
 
-                if ($(e.target).hasClass('pane-stale')) {
-                    $(e.target).trigger('arv:pane:reload');
+                if (etarget.hasClass('pane-stale')) {
+                    etarget.trigger('arv:pane:reload');
                 }
             }).fail(function(jqxhr, status, error) {
                 var errhtml;
@@ -100,7 +108,7 @@ $(document).on('arv:pane:reload', function(e) {
                         'Reload tab</a></p><iframe></iframe></div>');
                 $('.tab_reload', $pane).click(function() {
                     $pane.html('<div class="spinner spinner-32px spinner-h-center"></div>');
-                    $(e.target).trigger('arv:pane:reload');
+                    etarget.trigger('arv:pane:reload');
                 });
                 // We want to render the error in an iframe, in order to
                 // avoid conflicts with the main page's element ids, etc.
@@ -112,15 +120,16 @@ $(document).on('arv:pane:reload', function(e) {
                     $('body', iframe.contentDocument).html(errhtml);
                     iframe.height = iframe.contentDocument.body.scrollHeight + "px";
                 }, 1);
-                $(e.target).addClass('pane-loaded');
+                etarget.addClass('pane-loaded');
             });
     } else {
-        console.log($(e.target).attr('href') + " is not active");
+        //console.log(etarget.attr('href') + " is not active");
+
         // When the user selects e.target tab, show a spinner instead of
         // old content while loading.
-        $(e.target).removeClass('pane-loading');
-        $(e.target).removeClass('pane-loaded');
-        $(e.target).removeClass('pane-stale');
+        etarget.removeClass('pane-loading');
+        etarget.removeClass('pane-loaded');
+        etarget.removeClass('pane-stale');
 
         $pane.html('<div class="spinner spinner-32px spinner-h-center"></div>');
     }
diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb
index a618d43..41664c9 100644
--- a/apps/workbench/app/controllers/pipeline_instances_controller.rb
+++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb
@@ -231,9 +231,11 @@ class PipelineInstancesController < ApplicationController
   end
 
   def show_pane_list
-    panes = %w(Components Log Graph Advanced)
+    panes = %w(Components Graph Advanced)
     if @object and @object.state.in? ['New', 'Ready']
-      panes = %w(Inputs) + panes - %w(Log)
+      panes = %w(Inputs) + panes
+    else
+      panes.insert(1, {:name => "Log", :no_auto_reload => true})
     end
     if not @object.components.values.any? { |x| x[:job] rescue false }
       panes -= ['Graph']
diff --git a/apps/workbench/app/views/application/_content.html.erb b/apps/workbench/app/views/application/_content.html.erb
index 632a291..8c6860b 100644
--- a/apps/workbench/app/views/application/_content.html.erb
+++ b/apps/workbench/app/views/application/_content.html.erb
@@ -7,7 +7,7 @@
       <% pane_name = (pane.is_a?(Hash) ? pane[:name] : pane) %>
       <li class="<%= 'active' if i==0 %>">
         <a href="#<%= pane_name %>"
-           class="pane-anchor"
+           class="pane-anchor <%= 'pane-no-auto-reload' if pane.is_a?(Hash) && pane[:no_auto_reload] %>"
            id="<%= pane_name %>-tab"
            data-toggle="tab"
            data-tab-history=true
@@ -22,8 +22,9 @@
   <div class="tab-content">
     <% pane_list.each_with_index do |pane, i| %>
       <% pane_name = (pane.is_a?(Hash) ? pane[:name] : pane) %>
+      <% puts pane.is_a?(Hash) && pane[:no_auto_reload] %>
       <div id="<%= pane_name %>"
-           class="tab-pane <%= 'in active loaded' if i==0 %>"
+           class="tab-pane <%= 'in active pane-loaded' if i==0 %>"
            <% if controller.action_name == "index" %>
              data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
            <% else %>
diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb
index 7324104..2531f14 100644
--- a/apps/workbench/app/views/jobs/_show_log.html.erb
+++ b/apps/workbench/app/views/jobs/_show_log.html.erb
@@ -1,12 +1,11 @@
 <% if !@object.log %>
 
 <% log_history = stderr_log_history([@object.uuid]) %>
-<div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%= @object.uuid %>">
-  <% log_history.each do |entry| %>
-    <%=entry%><br/>
-  <% end %>
+
+<div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuid="<%= @object.uuid %>"><%= log_history.join("\n") %>
 </div>
 
+
 <% else %>
 
 <script>
diff --git a/apps/workbench/app/views/jobs/_show_status.html.erb b/apps/workbench/app/views/jobs/_show_status.html.erb
index cec6340..976bf19 100644
--- a/apps/workbench/app/views/jobs/_show_status.html.erb
+++ b/apps/workbench/app/views/jobs/_show_status.html.erb
@@ -1,9 +1,16 @@
 <div style="margin-top: 10px">
-<% pj = {} %>
-<% pj[:job] = @object %>
-<% pj[:name] = @object[:name] || "this job" %>
-<% tasks = JobTask.filter([['job_uuid', '=', @object.uuid]]).results %>
-<%= render partial: 'pipeline_instances/running_component', locals: {tasks: tasks, pj: pj, i: 0, expanded: true} %>
+
+<div id="job-status"
+     class="pane-anchor arv-log-event-listener arv-refresh-on-log-event"
+     href="#job-status-pane"
+     data-pane-content-url="<%= url_for(params.merge(tab_pane: "job_component")) %>"
+     data-object-uuid="<%= @object.uuid %>"
+     data-load-throttle="5000"
+     >
+  <div id="job-status-pane" class="active">
+    <%= render 'show_job_component' %>
+  </div>
+</div>
 </div>
 
   <div class="panel panel-default">
@@ -17,7 +24,7 @@
   <% pipeline.components.each do |k, v| %>
     <% if v[:job] and v[:job][:uuid] == @object.uuid %>
       <div>
-      <b><%= k %></b> component of <%= link_to_if_arvados_object pipeline, friendly_name: true %> 
+      <b><%= k %></b> component of <%= link_to_if_arvados_object pipeline, friendly_name: true %>
       created at <%= render_localized_date(pipeline.created_at) %>.
       </div>
     <% end %>
diff --git a/apps/workbench/app/views/jobs/show.html.erb b/apps/workbench/app/views/jobs/show.html.erb
index 74c53ca..5f46505 100644
--- a/apps/workbench/app/views/jobs/show.html.erb
+++ b/apps/workbench/app/views/jobs/show.html.erb
@@ -1,37 +1,15 @@
 <% content_for :tab_line_buttons do %>
-    <% if @object.state == "Running" %>
-    <%= form_tag "/jobs/#{@object.uuid}/cancel", style: "display:inline; padding-left: 1em" do |f| %>
-      <%= button_tag "Cancel running job", {class: 'btn btn-sm btn-danger', id: "cancel-job-button"} %>
-    <% end %>
-  <% else %>
-    <%= form_tag '/jobs', style: "display:inline; padding-left: 1em" do |f| %>
-      <% [:script, :script_version, :repository, :supplied_script_version, :nondeterministic].each do |d| %>
-        <%= hidden_field :job, d, :value => @object[d] %>
-      <% end %>
-      <% [:script_parameters, :runtime_constraints].each do |d| %>
-        <%= hidden_field :job, d, :value => JSON.dump(@object[d]) %>
-      <% end %>
-      <%= button_tag ({class: 'btn btn-sm btn-primary', id: "re-run-same-job-button",
-                       title: 'Re-run job using the same script version as this run'}) do %>
-        <i class="fa fa-fw fa-gear"></i> Re-run same version
-      <% end %>
-    <% end %>
-  <% if @object.respond_to? :supplied_script_version and !@object.supplied_script_version.nil? and !@object.supplied_script_version.empty? and @object.script_version != @object.supplied_script_version%>
-      <%= form_tag '/jobs', style: "display:inline" do |f| %>
-      <% [:script, :repository, :supplied_script_version, :nondeterministic].each do |d| %>
-        <%= hidden_field :job, d, :value => @object[d] %>
-      <% end %>
-      <%= hidden_field :job, :script_version, :value => @object[:supplied_script_version] %>
-      <% [:script_parameters, :runtime_constraints].each do |d| %>
-        <%= hidden_field :job, d, :value => JSON.dump(@object[d]) %>
-      <% end %>
-      <%= button_tag ({class: 'btn btn-sm btn-primary', id: "re-run-latest-job-button",
-                       title: 'Re-run job using the latest script version'}) do%>
-        <i class="fa fa-fw fa-gear"></i> Re-run latest version
-      <% end %>
-    <% end %>
-  <% end %>
-<% end %>
+  <div id="job-tab-buttons"
+       class="pane-anchor active arv-log-event-listener arv-refresh-on-state-change"
+       href="#job-tab-buttons-pane"
+       data-pane-content-url="<%= url_for(params.merge(tab_pane: "job_buttons")) %>"
+       data-object-uuid="<%= @object.uuid %>"
+       style="display: inline"
+       >
+    <div id="job-tab-buttons-pane" class="active" style="display: inline">
+      <%= render partial: 'show_job_buttons', locals: {object: @object}%>
+    </div>
+  </div>
 <% end %>
 
 <%= render partial: 'title_and_buttons' %>
diff --git a/apps/workbench/app/views/pipeline_instances/_running_component.html.erb b/apps/workbench/app/views/pipeline_instances/_running_component.html.erb
index caa8377..f53285a 100644
--- a/apps/workbench/app/views/pipeline_instances/_running_component.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_running_component.html.erb
@@ -78,7 +78,7 @@
           <% if current_job[:state].in? ["Queued", "Running"] %>
             <%# column offset 11 %>
             <div class="col-md-1 pipeline-instance-spacing">
-              <%= form_tag "/jobs/#{current_job[:uuid]}/cancel", style: "display:inline; padding-left: 1em" do |f| %>
+              <%= form_tag "/jobs/#{current_job[:uuid]}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
                 <%= hidden_field_tag :return_to, url_for(@object) %>
                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
               <% end %>
diff --git a/apps/workbench/app/views/pipeline_instances/show.html.erb b/apps/workbench/app/views/pipeline_instances/show.html.erb
index 12b291f..2b07352 100644
--- a/apps/workbench/app/views/pipeline_instances/show.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/show.html.erb
@@ -18,12 +18,12 @@
 <% content_for :tab_line_buttons do %>
 
   <div id="pipeline-instance-tab-buttons"
-       class="pane-anchor active arv-log-event-listener arv-refresh-on-pipeline-state-change"
+       class="pane-anchor active arv-log-event-listener arv-refresh-on-state-change"
        href="#pipeline-instance-tab-buttons-pane"
        data-pane-content-url="<%= url_for(params.merge(tab_pane: "tab_buttons")) %>"
        data-object-uuid="<%= @object.uuid %>"
        >
-    <div id="pipeline-instance-tab-buttons-pane">
+    <div id="pipeline-instance-tab-buttons-pane" class="active">
       <%= render partial: 'show_tab_buttons', locals: {object: @object}%>
     </div>
   </div>
diff --git a/apps/workbench/app/views/projects/index.html.erb b/apps/workbench/app/views/projects/index.html.erb
index 4c0450c..ea52024 100644
--- a/apps/workbench/app/views/projects/index.html.erb
+++ b/apps/workbench/app/views/projects/index.html.erb
@@ -1,13 +1,9 @@
-<% content_for :js do %>
-    setInterval(function(){
-        $('#dashboard-content').trigger('arv:pane:reload');
-    }, 15000);
-<% end %>
-
 <div id="dashboard-content"
-     class="pane-anchor loaded"
+     class="pane-anchor pane-loaded arv-log-event-listener arv-refresh-on-log-event"
      href="#dashboard-content-pane"
      data-pane-content-url="<%= root_url tab_pane: "dashboard" %>"
+     data-object-uuid="all"
+     data-load-throttle="15000"
      >
   <div id="dashboard-content-pane" class="active">
     <%= render partial: 'show_dashboard' %>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list