8876: remove some job specific bits and make them generic
[arvados.git] / apps / workbench / app / views / work_unit / _show_component.html.erb
index cea3395f64a0fd9e604435be04d671fdb0597c69..23ac3d393d5025cce157566036488982fe0a1ad0 100644 (file)
 <%# Work unit status %>
 
-<div class="pull-right" style="padding-left: 1em">
-  Current state: <span class="badge badge-<%= wu.state_bootstrap_class %>" data-wu-state="<%= wu.state_label %>">
-    <% if wu.state_label == "running" %>
-      Active
-    <% else %>
-      <%= wu.state_label %>
+<div class="container-fluid>
+  <div class="row-fluid">
+    <%# Need additional handling for main object display  %>
+    <% if @object.uuid == wu.uuid %>
+      <div class="col-md-2 pull-right">
+        <div class="container-fluid">
+          <div class="row-fluid">
+            <%# column offset 0 %>
+            <% if wu.state_label.in? ["Queued", "Running"] and wu.can_cancel? and @object.editable? %>
+                <div class="col-md-1">
+                  <%= form_tag "#{wu.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-obj-button"} %>
+                  <% end %>
+                </div>
+            <% end %>
+            <%# column offset 1 %>
+            <div class="pull-right col-md-5 pipeline-instance-spacing">
+              <%= render partial: 'work_unit/progress', locals: {wu: wu} %>
+            </div>
+          </div>
+        </div>
+      </div>
     <% end %>
-  </span>&nbsp;
-</div>
 
-<% if wu.state_label == 'Paused' %>
-  <p>
-    This work unit is paused. Work unit children that are
-    already running will continue to run, but no new work units will be submitted.
-  </p>
-<% end %>
+    <div class="col-md-10" >
+      <% if wu.state_label == 'Paused' %>
+        <p>
+          This <%= wu.title %> is paused. Children that are
+          already running will continue to run, but no new work will be submitted.
+        </p>
+      <% end %>
 
-<% runningtime = determine_wallclock_runtime(wu.children) %>
+      <% runningtime = determine_wallclock_runtime(wu.children) %>
 
-<p>
-  <% if wu.started_at %>
-    This work unit started at <%= render_localized_date(wu.started_at) %>.
-    It
-    <% if wu.state_label == 'Complete' %>
-      completed in
-    <% elsif wu.state_label == 'Failed' %>
-      failed after
-    <% else %>
-      has been active for
-    <% end %>
+      <p>
+        <% if wu.started_at %>
+          This <%= wu.title %> started at <%= render_localized_date(wu.started_at) %>.
+          It
+          <% if wu.state_label == 'Complete' %>
+            completed in
+          <% elsif wu.state_label == 'Failed' %>
+            failed after
+          <% else %>
+            has been active for
+          <% end %>
 
-    <% walltime = if wu.finished_at then
-                    wu.finished_at - wu.started_at
-                  else
-                    Time.now - wu.started_at
-                  end %>
+          <% walltime = if wu.finished_at then
+                          wu.finished_at - wu.started_at
+                        else
+                          Time.now - wu.started_at
+                        end %>
 
-    <%= if walltime > runningtime
-          render_runtime(walltime, false)
-        else
-          render_runtime(runningtime, false)
-        end %><% if wu.finished_at %> at <%= render_localized_date(wu.finished_at) %><% end %>.
-    <% else %>
-      It is <%= if wu.state_label == 'Running' then 'active' else wu.state.downcase end %>.
-        <% walltime = 0%>
-    <% end %>
+          <%= if walltime > runningtime
+                render_runtime(walltime, false)
+              else
+                render_runtime(runningtime, false)
+              end %><% if wu.finished_at %> at <%= render_localized_date(wu.finished_at) %><% end %>.
+        <% else %>
+          <% if wu.state_label %> This <%= wu.title %> is <%= if wu.state_label == 'Running' then 'active' else wu.state_label.downcase end %>. <% end %>
+            <% walltime = 0 %>
+        <% end %>
 
-  <% if wu.state_label == 'Failed' %>
-    Check the Log tab for more detail about why it failed.
-  <% end %>
-</p>
+        <% if wu.state_label == 'Failed' %>
+          Check the Log tab for more detail about why it failed.
+        <% end %>
+      </p>
 
-<p>
-    It
-    <% if wu.state_label == 'Running' %>
-      has run
-    <% else %>
-      ran
-    <% end %>
-    for
-    <%
-        cputime = wu.children.map { |c|
-        if c.started_at
-          (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
-        else
-          0
-        end
-       }.reduce(:+) || 0 %>
-    <%= render_runtime(runningtime, false) %><% if (walltime - runningtime) > 0 %>
-      (<%= render_runtime(walltime - runningtime, false) %> queued)<% end %><% if cputime == 0 %>.<% else %>
-      and used
-    <%= render_runtime(cputime, false) %>
-    of node allocation time (<%= (cputime/runningtime).round(1) %>&Cross; scaling).
-    <% end %>
-</p>
+      <% if wu.state_label %>
+        <p>
+            It
+            <% if wu.state_label == 'Running' %>
+              has run
+            <% else %>
+              ran
+            <% end %>
+            for
+            <%
+                cputime = wu.children.map { |c|
+                if c.started_at
+                  (c.runtime_constraints.andand[:min_nodes] || 1) * ((c.finished_at || Time.now()) - c.started_at)
+                else
+                  0
+                end
+               }.reduce(:+) || 0 %>
+            <%= render_runtime(runningtime, false) %><% if (walltime - runningtime) > 0 %>
+              (<%= render_runtime(walltime - runningtime, false) %> queued)<% end %><% if cputime == 0 %>.<% else %>
+              and used
+            <%= render_runtime(cputime, false) %>
+            of node allocation time (<%= (cputime/runningtime).round(1) %>&Cross; scaling).
+            <% end %>
+        </p>
+      <% end %>
+    </div>
+  </div>
 
 <p>
   <%= render(partial: 'work_unit/component_detail', locals: {current_obj: wu}) %>
 <%# Work unit children %>
 
 <%
-  job_uuids = wu.children.collect {|c| c.uuid}.compact
-  if job_uuids.any?
-    resource_class = resource_class_for_uuid(job_uuids.first, friendly_name: true)
-    preload_objects_for_dataclass resource_class, job_uuids
+  uuids = wu.children.collect {|c| c.uuid}.compact
+  if uuids.any?
+    resource_class = resource_class_for_uuid(uuids.first, friendly_name: true)
+    preload_objects_for_dataclass resource_class, uuids
   end
 
-  job_collections = wu.children.collect {|j| j.output}.compact
-  job_collections.concat wu.children.collect {|j| j.docker_image}.uniq.compact
-  job_collections_pdhs = job_collections.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
-  job_collections_uuids = job_collections - job_collections_pdhs
-  preload_collections_for_objects job_collections_uuids if job_collections_uuids.any?
-  preload_for_pdhs job_collections_pdhs if job_collections_pdhs.any?
+  collections = wu.children.collect {|j| j.output}.compact
+  collections.concat wu.children.collect {|j| j.docker_image}.uniq.compact
+  collections_pdhs = collections.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
+  collections_uuids = collections - collections_pdhs
+  preload_collections_for_objects collections_uuids if collections_uuids.any?
+  preload_for_pdhs collections_pdhs if collections_pdhs.any?
 %>
 
-<% @descendent_count = 0 if !@descendent_count %>
-
-<% wu.children.each_with_index do |c, i| %>
-  <% @descendent_count += 1 %>
-  <%= render(partial: 'work_unit/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
+<% if wu.has_unreadable_children %>
+  <%= render(partial: "pipeline_instances/show_components_json",
+             locals: {error_name: "Unreadable components", backtrace: nil, wu: wu}) %>
+<% else %>
+  <% @descendent_count = 0 if !@descendent_count %>
+  <% wu.children.each do |c| %>
+    <% @descendent_count += 1 %>
+    <%= render(partial: 'work_unit/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
+  <% end %>
 <% end %>