render pipeline_invocation components as job/progress table
authorTom Clegg <tom@clinicalfuture.com>
Sun, 10 Feb 2013 06:51:40 +0000 (01:51 -0500)
committerTom Clegg <tom@clinicalfuture.com>
Sun, 10 Feb 2013 06:51:40 +0000 (01:51 -0500)
app/helpers/pipeline_invocations_helper.rb
app/views/application/_orvos_object.html.erb
app/views/application/_orvos_object_attr.html.erb [new file with mode: 0644]
app/views/pipeline_invocations/show.html.erb

index 2d8ead42ece470b39b3409b1f5044890afc3e7cc..69709364b06455a5dcb9144b36fd94adc755e038 100644 (file)
@@ -1,2 +1,50 @@
 module PipelineInvocationsHelper
+  def pipeline_jobs
+    ret = []
+    @object.components[:steps].each_with_index do |step, i|
+      pj = {index: i, name: step[:name]}
+      if step[:complete] and step[:complete] != 0
+        if step[:output_data_locator]
+          pj[:progress] = 1.0
+        else
+          pj[:progress] = 0.0
+        end
+      else
+        if step[:progress] and
+            (re = step[:progress].match /^(\d+)\+(\d+)\/(\d+)$/)
+          pj[:progress] = (((re[1].to_f + re[2].to_f/2) / re[3].to_f) rescue 0.5)
+        else
+          pj[:progress] = 0.0
+        end
+        if step[:failed]
+          pj[:result] = 'failed'
+          pj[:failed] = true
+        end
+      end
+      if step[:warehousejob]
+        if step[:complete]
+          pj[:result] = 'complete'
+          pj[:complete] = true
+          pj[:progress] = 1.0
+        elsif step[:warehousejob][:finishtime]
+          pj[:result] = 'failed'
+          pj[:failed] = true
+        elsif step[:warehousejob][:starttime]
+          pj[:result] = 'running'
+        else
+          pj[:result] = 'queued'
+        end
+      end
+      pj[:progress_detail] = (step[:progress] rescue nil)
+      pj[:job_id] = (step[:warehousejob][:id] rescue nil)
+      pj[:command] = step[:function]
+      pj[:command_version] = (step[:warehousejob][:revision] rescue nil)
+      pj[:output] = step[:output_data_locator]
+      pj[:finished_at] = (Time.parse(step[:warehousejob][:finishtime]) rescue nil)
+      pj[:progress_bar] = raw("<div class=\"progress\" style=\"width:100px\"><div class=\"bar\" style=\"width:#{pj[:progress]*100}%\"></div></div>")
+      pj[:output_link] = link_to_if_orvos_object pj[:output]
+      ret << pj
+    end
+    ret
+  end
 end
index b0d4259ff0904c6a82c6561bba6ba738ea35129a..5f86de8b3a61dd3e6a12a969cd14d14b640e3638 100644 (file)
@@ -3,27 +3,7 @@
   </thead>
   <tbody>
     <% @object.attributes_for_display.each do |attr, attrvalue| %>
-    <% if attrvalue.is_a? Hash then attrvalue.each do |infokey, infocontent| %>
-    <tr>
-      <td><%= attr %>[<%= infokey %>]</td>
-      <td>
-        <tt>
-          <% if infocontent.is_a? Array then infocontent.each do |message| %>
-          <%= message %><br />
-          <% end; elsif infocontent.is_a? String %>
-          <%= infocontent %>
-          <% else %>
-          <%= infocontent.inspect %>
-          <% end %>
-        </tt>
-      </td>
-    </tr>
+    <%= render partial: 'application/orvos_object_attr', locals: { attr: attr, attrvalue: attrvalue } %>
     <% end %>
-    <% elsif attrvalue.is_a? String or attrvalue.respond_to? :to_s %>
-    <tr>
-      <td><%= attr %></td>
-      <td><%= link_to_if_orvos_object attrvalue, {referring_attr: attr, referring_object: @object, with_prefixes: true, with_class_name: true} %></td>
-    </tr>
-    <% end; end %>
   </tbody>
 </table>
diff --git a/app/views/application/_orvos_object_attr.html.erb b/app/views/application/_orvos_object_attr.html.erb
new file mode 100644 (file)
index 0000000..3778e2e
--- /dev/null
@@ -0,0 +1,22 @@
+<% if attrvalue.is_a? Hash then attrvalue.each do |infokey, infocontent| %>
+<tr>
+  <td><%= attr %>[<%= infokey %>]</td>
+  <td>
+    <tt>
+      <% if infocontent.is_a? Array then infocontent.each do |message| %>
+      <%= message %><br />
+      <% end; elsif infocontent.is_a? String %>
+      <%= infocontent %>
+      <% else %>
+      <%= infocontent.inspect %>
+      <% end %>
+    </tt>
+  </td>
+</tr>
+<% end %>
+<% elsif attrvalue.is_a? String or attrvalue.respond_to? :to_s %>
+<tr>
+  <td><%= attr %></td>
+  <td><%= link_to_if_orvos_object attrvalue, {referring_attr: attr, referring_object: @object, with_prefixes: true, with_class_name: true} %></td>
+</tr>
+<% end %>
index 68f5fa9a549ca3c88602de47015223ed711475f1..32a221b226043853c8d25c029a2039f6497e95bd 100644 (file)
@@ -1 +1,30 @@
-<%= render :partial => 'application/orvos_object' %>
+<table class="table topalign">
+  <thead>
+  </thead>
+  <tbody>
+    <% @object.attributes_for_display.each do |attr, attrvalue| %>
+    <% if attr == 'components' and attrvalue.is_a? Hash %>
+
+    <tr><td><%= attr %></td><td>
+        <table class="table">
+          <% pipeline_jobs.each do |pj| %>
+          <tr><% %w(index name result job_id command command_version progress_detail progress_bar output_link).each do |key| %>
+            <td>
+              <% if key == 'command_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/orvos_object_attr', locals: { attr: attr, attrvalue: attrvalue } %>
+    <% end %>
+    <% end %>
+  </tbody>
+</table>