Merge branch 'master' into 3354-render-textile
[arvados.git] / apps / workbench / app / views / pipeline_instances / _show_components.html.erb
index d7b86bf1fb3b930fdbc178329c0f8988d9d301d4..c55a7253b8bca440b6f58d1059995aeb24406e18 100644 (file)
-<% template = PipelineTemplate.find(@object.pipeline_template_uuid) rescue nil %>
-<%= content_for :content_top do %>
-  <h2>
-    <%= render_editable_attribute @object, 'name', nil %>
-  </h2>
-  <% if template %>
-  <blockquote><span class="deemphasize">From template:</span><br />
-    <%= link_to_if_arvados_object template, friendly_name: true %><br />
-    <%= template.description %>
-  </blockquote>
-  <% end %>
-<% end %>
-
-<% content_for :tab_line_buttons do %>
-  <%= link_to(copy_pipeline_instance_path('id' => @object.uuid, 'pipeline_instance[state]' => 'New'),
-      class: 'btn btn-primary',
-      #data: {toggle: :tooltip, placement: :top}, title: 'copy and modify',
-      method: :post,
-      ) do %>
-    Clone and edit <i class="fa fa-fw fa-copy"></i>
-  <% end %>
-<% end %>
-
 <% if !@object.state.in? ['New', 'Ready'] %>
 
-  <% content_for :tab_line_buttons do %>
-    <% if @object.state.in? ['RunningOnClient', 'RunningOnServer'] %>
-      <%= link_to(url_for('pipeline_instance[state]' => 'Paused'),
-          class: 'btn btn-primary run-pipeline-button',
-          method: :patch
-          ) do %>
-        Stop <i class="fa fa-fw fa-stop"></i>
-      <% end %>
-    <% elsif @object.state == 'Paused' %>
-      <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
-          class: 'btn btn-primary run-pipeline-button',
-          method: :patch
-          ) do %>
-        Resume <i class="fa fa-fw fa-play"></i>
-      <% end %>
-    <% end %>
-  <% end %>
-
   <% pipeline_job_uuids = [] %>
 
   <div class="pull-right">
-    Current state: <span class="badge badge-info"><%= @object.state.sub('OnServer', '') %></span>&nbsp;
+    Current state: <span class="badge badge-info" data-pipeline-state="<%= @object.state %>"><%= @object.state.sub('OnServer', '') %></span>&nbsp;
   </div>
 
-  <table class="table pipeline-components-table">
-    <colgroup>
-      <col style="width: 15%" />
-      <col style="width: 25%" />
-      <col style="width: 8%" />
-      <col style="width: 13%" />
-      <col style="width: 12%" />
-      <col style="width: 14%" />
-      <col style="width: 13%" />
-    </colgroup>
-    <thead>
-      <tr>
-        <th colspan="2">
-          component
-        </th><th colspan="5">
-          job
-          <%# format:'js' here helps browsers avoid using the cached js
-          content in html context (e.g., duplicate tab -> see
-          javascript) %>
-          <%= link_to '(refresh)', {format: :js}, {class: 'refresh hide', remote: true, method: 'get'} %>
-        </th>
-      </tr>
-    </thead>
-    <tbody>
-      <% render_pipeline_jobs.each do |pj| %>
-        <% if pj[:job].andand[:uuid]
-             pipeline_job_uuids << pj[:job][:uuid]
-           end %>
-      <tr>
-        <td>
-          <%= pj[:name] %>
-        </td><td>
-          <%= pj[:script] %>
-          <br /><span class="deemphasize"><%= pj[:script_version] %></span>
-        </td><td>
-          <%= render(partial: 'job_status_label', locals: { j: pj[:job] }) %>
-        </td><td>
-          <%= pj[:progress_bar] %>
-        </td>
-        <% current_job = Job.find(pj[:job][:uuid]) rescue nil %>
-        <td>
-          <% if current_job %>
-            <%= render partial: 'show_object_button', locals: {object: current_job, size: 'xs', link_text: 'Show job details'} %>
-          <% end %>
-        </td><td>
-          <% if current_job.andand[:log] %>
-            <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(current_job[:log])%>
-            <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
-              <% c.files.first.andand do |file| %>
-                <%= link_to url_for(controller: 'collections', action: 'show_file', uuid: current_job[:log], file: "#{file[0]}/#{file[1]}", disposition: 'inline', size: file[2]), class: 'btn btn-default btn-xs' do %>
-                  <i class="fa fa-fw fa-info"></i> Show log messages
-                <% end %>
-              <% end %>
-            <% end %>
-          <% end %>
-        </td><td>
-          <% if current_job.andand[:output] %>
-            <%= link_to_if_arvados_object current_job[:output], {thumbnail: true, link_text: raw('<i class="fa fa-fw fa-archive"></i> Show output files')}, {class: 'btn btn-default btn-xs'} %>
-          <% end %>
-        </td>
-      </tr>
-      <% end %>
-    </tbody>
-    <tfoot>
-      <tr><td colspan="7"></td></tr>
-    </tfoot>
-  </table>
-
-  <% if @object.state.in? %w(RunningOnServer RunningOnClient) %>
+  <%= render_pipeline_components("running", :json, pipeline_job_uuids: pipeline_job_uuids) %>
 
-    <% content_for :js do %>
-      setInterval(function(){$('a.refresh').click()}, 15000);
-    <% end %>
+  <% if @object.state.in? %w(RunningOnServer RunningOnClient Failed) %>
 
-    <% if !pipeline_job_uuids.empty? %>
-      <h4>Log messages from running jobs</h4>
-      <% log_history = pipeline_log_history(pipeline_job_uuids) %>
-      <div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%=pipeline_job_uuids.join(" ")%>">
+      <h4>Log messages from jobs</h4>
+      <% log_history = pipeline_log_history((pipeline_job_uuids || []) + [@object.uuid]) %>
+      <div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%= @object.uuid %> <%=(pipeline_job_uuids || []).join(" ")%>">
         <% log_history.each do |entry| %>
           <%=entry%><br/>
         <% end %>
       </div>
-    <% end %>
 
   <% end %>
 
 <% else %>
   <%# state is either New or Ready %>
+  <p><i>Here are all of the pipeline's components (jobs that will need to run in order to complete the pipeline). If you know what you're doing (or you're experimenting) you can modify these parameters before starting the pipeline. Usually, you only need to edit the settings presented on the "Inputs" tab above.</i></p>
 
-  <% if @object.state.in? %w(New Ready) %>
-    <p><i>Here are all of the pipeline's components (jobs that will need to run in order to complete the pipeline). If you know what you're doing (or you're experimenting) you can modify these parameters before starting the pipeline. Usually, you only need to edit the settings presented on the "Inputs" tab above.</i></p>
-  <% end %>
-
-  <% content_for :tab_line_buttons do %>
-    <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
-        class: 'btn btn-primary run-pipeline-button',
-        method: :patch
-        ) do %>
-      Run <i class="fa fa-fw fa-play"></i>
-    <% end %>
-  <% end %>
-
-  <% if @object.state.in? ['New', 'Ready'] %>
-    <%= render partial: 'show_components_editable', locals: {editable: true} %>
-  <% else %>
-    <%= render partial: 'show_components_editable', locals: {editable: false} %>
-  <% end %>
+  <%= render_pipeline_components("editable", :json, editable: true) %>
 <% end %>