2862: Use ?format=js so browser does not think js and html views are
[arvados.git] / apps / workbench / app / views / pipeline_instances / _show_components.html.erb
1 <% content_for :css do %>
2
3 <% end %>
4
5 <% template = PipelineTemplate.find(@object.pipeline_template_uuid) rescue nil %>
6
7 <%= content_for :content_top do %>
8   <h2>
9     <%= render_editable_attribute @object, 'name', nil, { 'data-emptytext' => 'Unnamed pipeline' } %>
10   </h2>
11   <% if template %>
12   <h4>
13     From template:
14     <%= link_to_if_arvados_object template, friendly_name: true %>
15   </h4>
16   <% end %>
17 <% end %>
18
19 <% pipeline_job_uuids = [] %>
20
21 <% if !@object.state.in? ['New', 'Ready', 'Paused'] %>
22 <table class="table pipeline-components-table">
23   <colgroup>
24     <col style="width: 15%" />
25     <col style="width: 20%" />
26     <col style="width: 12%" />
27     <col style="width: 12%" />
28     <col style="width: 45%" />
29   </colgroup>
30   <thead>
31     <tr>
32       <th>
33         component
34       </th><th>
35         script, version
36       </th><th>
37         job
38         <%# format:'js' here helps browsers avoid using the cached js
39         content in html context (e.g., duplicate tab -> see
40         javascript) %>
41         <%= link_to '(refresh)', {format: :js}, {class: 'refresh hide', remote: true, method: 'get'} %>
42       </th><th>
43       </th><th>
44         output
45       </th>
46     </tr>
47   </thead>
48   <tbody>
49     <% render_pipeline_jobs.each do |pj| %>
50       <% if pj[:job].andand[:uuid]
51            pipeline_job_uuids << pj[:job][:uuid]
52          end %>
53     <tr>
54       <td>
55         <%= pj[:name] %>
56       </td><td>
57         <%= pj[:script] %>
58         <br /><span class="deemphasize"><%= pj[:script_version] %></span>
59       </td><td>
60         <%= pj[:progress_bar] %>
61         <% if @object.state == 'Complete' || @object.state == 'Failed' %>
62           <% if pj[:job].andand[:uuid] %>
63             <span class="deemphasize">
64             <%= link_to("..."+pj[:job][:uuid].last(15), job_url(id: pj[:job][:uuid])) %>
65             </span>
66
67             <% current_job = Job.find(pj[:job][:uuid]) rescue nil %>
68             <% if current_job.andand[:log] %>
69               <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(current_job[:log])%>
70               <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
71                 <% c.files.each do |file| %>
72                   <br/><span class="deemphasize">
73                   <a href="<%= collection_path(current_job[:log]) %>/<%= file[1] %>?disposition=inline&size=<%= file[2] %>">log</a>
74                   </span>
75                 <% end %>
76               <% end %>
77             <% end %>
78           <% end %>
79         <% end %>
80       </td><td>
81         <%= render(partial: 'job_status_label',
82                                locals: { :j => pj[:job] }) %>
83       </td><td>
84         <%= link_to_if_arvados_object pj[:output], {:thumbnail => true} %>
85       </td>
86     </tr>
87     <% end %>
88   </tbody>
89   <tfoot>
90     <tr><td colspan="5"></td></tr>
91   </tfoot>
92 </table>
93
94 <% if @object.state == 'RunningOnServer' || @object.state == 'RunningOnClient' %>
95 <% content_for :js do %>
96 setInterval(function(){$('a.refresh').click()}, 15000);
97 <% end %>
98
99 <% content_for :tab_line_buttons do %>
100   <%= form_tag @object, :method => :put do |f| %>
101
102     <%= hidden_field @object.class.to_s.underscore.singularize.to_sym, :state, :value => 'Paused' %>
103
104     <%= button_tag({class: 'btn btn-primary pull-right run-pipeline-button'}) do %>
105       Stop <i class="fa fa-fw fa-stop"></i>
106     <% end %>
107   <% end %>
108 <% end %>
109
110     <% if !pipeline_job_uuids.empty? %>
111       <h4>Log messages from running jobs</h4>
112       <% log_history = pipeline_log_history(pipeline_job_uuids) %>
113       <div id="pipeline_event_log_history_div">
114         <% log_history.each do |entry| %>
115           <%=entry%><br/>
116         <% end %>
117       </div>
118       <div class="arv-log-event-listener arv-log-event-handler-append-logs" id="pipeline_event_log_div" data-object-uuids="<%=pipeline_job_uuids.join(" ")%>"/>
119     <% end %>
120   <% end %>
121
122 <% else %>    <%# State new or ready or paused %>
123   <% if @object.state == 'New' %>
124     <p>Please set the desired input parameters for the components of this pipeline.  Parameters highlighted in red are required.</p>
125   <% end %>
126
127   <% content_for :tab_line_buttons do %>
128     <%= form_tag @object, :method => :put do |f| %>
129
130       <%= hidden_field @object.class.to_s.underscore.singularize.to_sym, :state, :value => 'RunningOnServer' %>
131
132       <%= button_tag({class: 'btn btn-primary pull-right run-pipeline-button'}) do %>
133         Run <i class="fa fa-fw fa-play"></i>
134       <% end %>
135     <% end %>
136   <% end %>
137
138   <% if @object.state.in? ['New', 'Ready'] %>
139     <%= render partial: 'show_components_editable', locals: {editable: true} %>
140   <% else %>
141     <%= render partial: 'show_components_editable', locals: {editable: false} %>
142   <% end %>
143 <% end %>