[ARVADOS] created: 507442f6712d751b947083fa6946ee6d96f8ad96

git at public.curoverse.com git at public.curoverse.com
Mon Feb 3 03:23:59 EST 2014


        at  507442f6712d751b947083fa6946ee6d96f8ad96 (commit)


commit 507442f6712d751b947083fa6946ee6d96f8ad96
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 3 00:21:52 2014 -0800

    Use AJAX/remote requests when deleting objects. Add delete button to
    pipeline_instances index.
    
    refs #1976

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 21941b2..6b9b6fc 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -112,7 +112,12 @@ class ApplicationController < ActionController::Base
 
   def destroy
     if @object.destroy
-      redirect_to(params[:return_to] || :back)
+      respond_to do |f|
+        f.html {
+          redirect_to(params[:return_to] || :back)
+        }
+        f.js { render }
+      end
     else
       self.render_error status: 422
     end
diff --git a/apps/workbench/app/views/application/_index.html.erb b/apps/workbench/app/views/application/_index.html.erb
index 02a1aa1..64b94c8 100644
--- a/apps/workbench/app/views/application/_index.html.erb
+++ b/apps/workbench/app/views/application/_index.html.erb
@@ -31,7 +31,7 @@
       
   <tbody>
     <% @objects.each do |object| %>
-    <tr>
+    <tr data-object-uuid="<%= object.uuid %>">
       <% object.attributes_for_display.each do |attr, attrvalue| %>
       <% next if attr_blacklist.index(" "+attr) %>
       <td class="arv-object-<%= object.class.to_s %> arv-attr-<%= attr %>">
@@ -51,9 +51,8 @@
       <% end %>
       <td>
         <% if object.editable? %>
-        <%= link_to({action: 'destroy', id: object.uuid}, method: :delete, data: {confirm: "You are about to delete #{controller.model_class} #{object.uuid}.\n\nAre you sure?"}) do %>
+        <%= link_to({action: 'destroy', id: object.uuid}, method: :delete, remote: true, data: {confirm: "You are about to delete #{controller.model_class} #{object.uuid}.\n\nAre you sure?"}) do %>
         <i class="icon-trash"></i>
-        <!-- <%= object.inspect %> -->
         <% end %>
         <% end %>
       </td>
diff --git a/apps/workbench/app/views/application/destroy.js.erb b/apps/workbench/app/views/application/destroy.js.erb
new file mode 100644
index 0000000..05b2c3e
--- /dev/null
+++ b/apps/workbench/app/views/application/destroy.js.erb
@@ -0,0 +1,3 @@
+$('[data-object-uuid=<%= @object.uuid %>]').hide('slow', function() {
+    $(this).remove();
+});
diff --git a/apps/workbench/app/views/pipeline_instances/index.html.erb b/apps/workbench/app/views/pipeline_instances/index.html.erb
index 2789ca1..ad941da 100644
--- a/apps/workbench/app/views/pipeline_instances/index.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/index.html.erb
@@ -21,6 +21,7 @@
 	dependencies
       </th><th>
 	created
+      </th><th>
       </th>
     </tr>
   </thead>
@@ -28,7 +29,7 @@
 
     <% @objects.sort_by { |ob| ob.created_at }.reverse.each do |ob| %>
 
-    <tr>
+    <tr data-object-uuid="<%= ob.uuid %>">
       <td>
         <%= check_box_tag 'uuids[]', ob.uuid, false %>
       </td><td>
@@ -58,6 +59,12 @@
         </small>
       </td><td>
         <%= ob.created_at %>
+      </td><td>
+        <% if ob.editable? %>
+        <%= link_to({action: 'destroy', id: ob.uuid}, method: :delete, remote: true, data: {confirm: "You are about to delete #{controller.model_class} #{ob.uuid}.\n\nAre you sure?"}) do %>
+        <i class="icon-trash"></i>
+        <% end %>
+        <% end %>
       </td>
     </tr>
 

commit ce408713e3067fc278a5a8f9c2d534567f65c636
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 3 00:07:24 2014 -0800

    Improve progress view on pipeline_instances.show page and add AJAX
    auto-refresh.
    
    refs #1976
    refs #2004

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 8d23c71..21941b2 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -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
 
diff --git a/apps/workbench/app/helpers/pipeline_instances_helper.rb b/apps/workbench/app/helpers/pipeline_instances_helper.rb
index f314c65..fbce7f5 100644
--- a/apps/workbench/app/helpers/pipeline_instances_helper.rb
+++ b/apps/workbench/app/helpers/pipeline_instances_helper.rb
@@ -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
diff --git a/apps/workbench/app/models/pipeline_instance.rb b/apps/workbench/app/models/pipeline_instance.rb
index 81cd42b..f6dbf40 100644
--- a/apps/workbench/app/models/pipeline_instance.rb
+++ b/apps/workbench/app/models/pipeline_instance.rb
@@ -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
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 3d2c6fa..9af00d5 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -113,7 +113,10 @@
   <div class="container">
 
     <%= content_for?(:breadcrumbs) ? yield(:breadcrumbs) : render(partial: 'breadcrumbs') %>
-    <%= yield %>
+
+    <div class="body-content">
+      <%= yield %>
+    </div>
 
   </div> <!-- /container -->
 
diff --git a/apps/workbench/app/views/pipeline_instances/show.html.erb b/apps/workbench/app/views/pipeline_instances/show.html.erb
index a36412e..9000750 100644
--- a/apps/workbench/app/views/pipeline_instances/show.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/show.html.erb
@@ -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
index 0000000..9460f0b
--- /dev/null
+++ b/apps/workbench/app/views/pipeline_instances/show.js.erb
@@ -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);

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list