Improve progress view on pipeline_instances.show page and add AJAX
authorTom Clegg <tom@curoverse.com>
Mon, 3 Feb 2014 08:07:24 +0000 (00:07 -0800)
committerTom Clegg <tom@curoverse.com>
Mon, 3 Feb 2014 08:07:24 +0000 (00:07 -0800)
auto-refresh.

refs #1976
refs #2004

apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/helpers/pipeline_instances_helper.rb
apps/workbench/app/models/pipeline_instance.rb
apps/workbench/app/views/layouts/application.html.erb
apps/workbench/app/views/pipeline_instances/show.html.erb
apps/workbench/app/views/pipeline_instances/show.js.erb [new file with mode: 0644]

index 8d23c71a739f6c62c1ac02ce5ea1aec0ca415488..21941b266e6f13780da1e2ad4ad0d5e1b5a54826 100644 (file)
@@ -59,6 +59,7 @@ class ApplicationController < ActionController::Base
     respond_to do |f|
       f.json { render json: @objects }
       f.html { render }
+      f.js { render }
     end
   end
 
@@ -75,6 +76,7 @@ class ApplicationController < ActionController::Base
           redirect_to params[:return_to] || @object
         end
       }
+      f.js { render }
     end
   end
 
index f314c658cedd5c8ecc3ea3ada0d364292af8f52c..fbce7f550b60190ecb81d8418b954c156fcba254 100644 (file)
@@ -61,23 +61,23 @@ module PipelineInstancesHelper
           pj[:progress] = 0.0
         end
       end
-      if pj[:job]
-        if pj[:job][:success]
-          pj[:result] = 'complete'
-          pj[:complete] = true
-          pj[:progress] = 1.0
-        elsif pj[:job][:finished_at]
-          pj[:result] = 'failed'
-          pj[:failed] = true
-        elsif pj[:job][:started_at]
-          pj[:result] = 'running'
-        else
-          pj[:result] = 'queued'
-        end
+      if pj[:job][:success]
+        pj[:result] = 'complete'
+        pj[:complete] = true
+        pj[:progress] = 1.0
+      elsif pj[:job][:finished_at]
+        pj[:result] = 'failed'
+        pj[:failed] = true
+      elsif pj[:job][:started_at]
+        pj[:result] = 'running'
+      elsif pj[:job][:uuid]
+        pj[:result] = 'queued'
+      else
+        pj[:result] = 'none'
       end
       pj[:job_id] = pj[:job][:uuid]
-      pj[:script] = pj[:job][:script]
-      pj[:script_version] = pj[:job][:script_version]
+      pj[:script] = pj[:job][:script] || c[:script]
+      pj[:script_version] = pj[:job][:script_version] || c[:script_version]
       pj[:output] = pj[:job][:output]
       pj[:finished_at] = (Time.parse(pj[:job][:finished_at]) rescue nil)
       ret << pj
index 81cd42bf4693d29d78119a50007a884750d745fc..f6dbf4003fbbe41961ae2601f9d85b39d58dc1d2 100644 (file)
@@ -20,4 +20,8 @@ class PipelineInstance < ArvadosBase
   def attribute_editable?(attr)
     attr == 'name'
   end
+
+  def attributes_for_display
+    super.reject { |k,v| k == 'components' }
+  end
 end
index 3d2c6faec0190b18e12cb060114fbd68ad034be2..9af00d5fd2b33368212f715fab691fb7f7c197ce 100644 (file)
   <div class="container">
 
     <%= content_for?(:breadcrumbs) ? yield(:breadcrumbs) : render(partial: 'breadcrumbs') %>
-    <%= yield %>
+
+    <div class="body-content">
+      <%= yield %>
+    </div>
 
   </div> <!-- /container -->
 
index a36412eb5c2408d8bf840f96398ff9b9297dc9f4..900075084da45e2d816ed742f93247880176c05b 100644 (file)
@@ -1,33 +1,72 @@
-<table class="table table-condensed table-hover topalign">
+<% content_for :css do %>
+table.pipeline-components-table thead th {
+  text-align: bottom;
+}
+table.pipeline-components-table div.progress {
+  margin-bottom: 0;
+}
+<% end %>
+<br />
+
+<table class="table pipeline-components-table">
+  <colgroup>
+    <col width="15%" />
+    <col width="15%" />
+    <col width="35%" />
+    <col width="35%" />
+  </colgroup>
   <thead>
+    <tr>
+      <th>
+        component
+      </th><th>
+        progress
+        <%= link_to '(refresh)', request.fullpath, class: 'refresh', remote: true, method: 'get' %>
+      </th><th>
+        script, version
+      </th><th>
+        output
+      </th>
+    </tr>
   </thead>
   <tbody>
-    <% @object.attributes_for_display.each do |attr, attrvalue| %>
-    <% if attr == 'components' and attrvalue.is_a? Hash %>
-
-    <tr class="info"><td><%= attr %></td><td>
-        <table class="table">
-          <% render_pipeline_jobs.each do |pj| %>
-          <tr><% %w(index name result job_link script script_version progress_detail progress_bar output_link).each do |key| %>
-            <td>
-              <% if key == 'script_version' %>
-              <%= pj[key.to_sym][0..6] rescue '' %>
-              <% else %>
-              <%= pj[key.to_sym] %>
-              <% end %>
-            </td>
-            <% end %>
-          </tr>
-          <% end %>
-        </table>
-    </td></tr>
-
-    <% else %>
-    <%= render partial: 'application/arvados_object_attr', locals: { attr: attr, attrvalue: attrvalue } %>
-    <% end %>
+    <% render_pipeline_jobs.each do |pj| %>
+    <tr>
+      <td>
+        <% if pj[:job].andand[:uuid] %>
+        <%= link_to pj[:name], job_url(id: pj[:job][:uuid]) %>
+        <% else %>
+        <%= pj[:name] %>
+        <% end %>
+      </td><td>
+        <%= pj[:progress_bar] %>
+        <% if pj[:job].andand[:cancelled_at] %>
+        <span class="pull-right label label-warning">cancelled</span>
+        <% elsif pj[:failed] %>
+        <span class="pull-right label label-warning">failed</span>
+        <% elsif pj[:result] == 'queued' %>
+        <span class="pull-right label">queued</span>
+        <% end %>
+      </td><td>
+        <%= pj[:script] %>
+        <br /><span class="deemphasize"><%= pj[:script_version] %></span>
+      </td><td>
+        <%= link_to_if_arvados_object pj[:output] %>
+      </td>
+    </tr>
     <% end %>
   </tbody>
+  <tfoot>
+    <tr><td colspan="4"></td></tr>
+  </tfoot>
 </table>
-<pre>
-<%= JSON.pretty_generate(@object.attributes) rescue nil %>
-</pre>
+
+<div style="height: 1em"></div>
+
+<%= render partial: 'arvados_object' %>
+
+<% if @object.active %>
+<% content_for :js do %>
+setInterval(function(){$('a.refresh').click()}, 30000);
+<% end %>
+<% end %>
diff --git a/apps/workbench/app/views/pipeline_instances/show.js.erb b/apps/workbench/app/views/pipeline_instances/show.js.erb
new file mode 100644 (file)
index 0000000..9460f0b
--- /dev/null
@@ -0,0 +1,3 @@
+var new_content = "<%= escape_javascript(render template: 'pipeline_instances/show.html') %>";
+if ($('div.body-content').html() != new_content)
+   $('div.body-content').html(new_content);