8876: introduce view helper methods such as link_to_log and queuedtime etc so that...
[arvados.git] / apps / workbench / app / views / work_unit / _show_child.html.erb
index dc88a216dbe4e0f639475d792a1e94608641d5fd..70e48cbdcbe1d83e67e02a66f18de68260759a13 100644 (file)
@@ -13,7 +13,7 @@
 
         <%# column offset 2 %>
         <div class="col-md-2 pipeline-instance-spacing">
-          <%= current_obj.progress %>
+          <%= render partial: 'work_unit/progress', locals: {wu: current_obj} %>
         </div>
 
         <%# column offset 4 %>
           <div class="col-md-8"></div>
         <% else %>
           <div class="col-md-1">
-              <% if current_obj.state_label.in? ["Complete", "Failed", "Cancelled"] %>
-                <% if current_obj.log_collection %>
-                  <% logCollection = Collection.find? current_obj.log_collection %>
-                  <% if logCollection %>
-                    <%= link_to "Log", job_path(current_obj.uuid, anchor: "Log") %>
-                  <% else %>
-                    Log unavailable
-                  <% end %>
-                <% end %>
-              <% elsif current_obj.state_label == "Running" %>
-                <% job = Job.find? current_obj.uuid %>
-                <% if job %>
-                  <%= link_to "Log", job_path(current_obj.uuid, anchor: "Log") %>
-                <% else %>
-                  Log unavailable
-                <% end %>
-              <% end %>
+            <%= current_obj.link_to_log %>
           </div>
 
           <%# column offset 5 %>
-          <% if current_obj.state_label != "Queued" %>
+          <% walltime = current_obj.walltime %>
+          <% cputime = current_obj.cputime %>
+          <% if walltime and cputime %>
           <div class="col-md-3">
-            <% if current_obj.started_at %>
-              <% walltime = ((if current_obj.finished_at then current_obj.finished_at else Time.now() end) - current_obj.started_at) %>
-              <% cputime = (current_obj.runtime_constraints.andand[:min_nodes] || 1) *
-                           ((current_obj.finished_at || Time.now()) - current_obj.started_at) %>
               <%= render_runtime(walltime, false) %>
               <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)<% end %>
-            <% end %>
           </div>
           <% end %>
 
-          <% if current_obj.state_label == "Queued" %>
+          <% queuetime = current_obj.queuedtime %>
+          <% if queuetime %>
             <%# column offset 5 %>
             <div class="col-md-6">
-              <% queuetime = Time.now - Time.parse(current_obj.created_at.to_s) %>
               Queued for <%= render_runtime(queuetime, false) %>.
             </div>
-          <% elsif current_obj.state_label == "Running" %>
+          <% elsif current_obj.show_child_summary %>
             <%# column offset 8 %>
             <div class="col-md-3">
               <span class="task-summary-status">
-                <%= current_obj.tasks_summary[:done] %>&nbsp;<%= "task".pluralize(current_obj.tasks_summary[:done]) %> done,
-                <%= current_obj.tasks_summary[:failed] %>&nbsp;failed,
-                <%= current_obj.tasks_summary[:running] %>&nbsp;running,
-                <%= current_obj.tasks_summary[:todo] %>&nbsp;pending
+                <%= current_obj.child_summary_str %>
               </span>
             </div>
-          <% elsif current_obj.state_label.in? ["Complete", "Failed", "Cancelled"] %>
+          <% elsif current_obj.is_finished? %>
             <%# column offset 8 %>
             <div class="col-md-4 text-overflow-ellipsis">
               <% if current_obj.output %>
-                <%= link_to_arvados_object_if_readable(current_obj.output, 'Output data not available', friendly_name: true) %>
-              <% elsif current_obj.output %>
                 <%= link_to_arvados_object_if_readable(current_obj.output, 'Output data not available', link_text: "Output of #{current_obj.label}") %>
               <% else %>
                 No output.
             </div>
           <% end %>
 
-          <% if current_obj.state_label.in? ["Queued", "Running"] and @object.editable? %>
+          <% if current_obj.can_be_canceled? and @object.editable? %>
             <%# column offset 11 %>
             <div class="col-md-1 pipeline-instance-spacing">
-              <%= form_tag "/jobs/#{current_obj.uuid}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
+              <%= form_tag "#{current_obj.uri}/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"} %>
+                <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-child-button"} %>
               <% end %>
             </div>
           <% end %>