2872: Merge branch 'master' into 2872-folder-nav
[arvados.git] / apps / workbench / app / views / pipeline_instances / _show_components.html.erb
1 <% template = PipelineTemplate.find(@object.pipeline_template_uuid) rescue nil %>
2 <%= content_for :content_top do %>
3   <h2>
4     <%= render_editable_attribute @object, 'name', nil %>
5   </h2>
6   <% if template %>
7   <blockquote><span class="deemphasize">From template:</span><br />
8     <%= link_to_if_arvados_object template, friendly_name: true %><br />
9     <%= template.description %>
10   </blockquote>
11   <% end %>
12 <% end %>
13
14 <% content_for :tab_line_buttons do %>
15   <%= link_to(copy_pipeline_instance_path('id' => @object.uuid, 'pipeline_instance[state]' => 'New'),
16       class: 'btn btn-primary',
17       #data: {toggle: :tooltip, placement: :top}, title: 'copy and modify',
18       method: :post,
19       ) do %>
20     Clone and edit <i class="fa fa-fw fa-copy"></i>
21   <% end %>
22 <% end %>
23
24 <% if !@object.state.in? ['New', 'Ready'] %>
25
26   <% content_for :tab_line_buttons do %>
27     <% if @object.state.in? ['RunningOnClient', 'RunningOnServer'] %>
28       <%= link_to(url_for('pipeline_instance[state]' => 'Paused'),
29           class: 'btn btn-primary run-pipeline-button',
30           method: :patch
31           ) do %>
32         Stop <i class="fa fa-fw fa-stop"></i>
33       <% end %>
34     <% elsif @object.state == 'Paused' %>
35       <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
36           class: 'btn btn-primary run-pipeline-button',
37           method: :patch
38           ) do %>
39         Resume <i class="fa fa-fw fa-play"></i>
40       <% end %>
41     <% end %>
42   <% end %>
43
44   <% pipeline_job_uuids = [] %>
45
46   <div class="pull-right">
47     Current state: <span class="badge badge-info"><%= @object.state.sub('OnServer', '') %></span>&nbsp;
48   </div>
49
50   <table class="table pipeline-components-table">
51     <colgroup>
52       <col style="width: 15%" />
53       <col style="width: 25%" />
54       <col style="width: 8%" />
55       <col style="width: 13%" />
56       <col style="width: 12%" />
57       <col style="width: 14%" />
58       <col style="width: 13%" />
59     </colgroup>
60     <thead>
61       <tr>
62         <th colspan="2">
63           component
64         </th><th colspan="5">
65           job
66           <%# format:'js' here helps browsers avoid using the cached js
67           content in html context (e.g., duplicate tab -> see
68           javascript) %>
69           <%= link_to '(refresh)', {format: :js}, {class: 'refresh hide', remote: true, method: 'get'} %>
70         </th>
71       </tr>
72     </thead>
73     <tbody>
74       <% render_pipeline_jobs.each do |pj| %>
75         <% if pj[:job].andand[:uuid]
76              pipeline_job_uuids << pj[:job][:uuid]
77            end %>
78       <tr>
79         <td>
80           <%= pj[:name] %>
81         </td><td>
82           <%= pj[:script] %>
83           <br /><span class="deemphasize"><%= pj[:script_version] %></span>
84         </td><td>
85           <%= render(partial: 'job_status_label', locals: { j: pj[:job] }) %>
86         </td><td>
87           <%= pj[:progress_bar] %>
88         </td>
89         <% current_job = Job.find(pj[:job][:uuid]) rescue nil %>
90         <td>
91           <% if current_job %>
92             <%= render partial: 'show_object_button', locals: {object: current_job, size: 'xs', link_text: 'Show job details'} %>
93           <% end %>
94         </td><td>
95           <% if current_job.andand[:log] %>
96             <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(current_job[:log])%>
97             <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
98               <% c.files.first.andand do |file| %>
99                 <%= 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 %>
100                   <i class="fa fa-fw fa-info"></i> Show log messages
101                 <% end %>
102               <% end %>
103             <% end %>
104           <% end %>
105         </td><td>
106           <% if current_job.andand[:output] %>
107             <%= 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'} %>
108           <% end %>
109         </td>
110       </tr>
111       <% end %>
112     </tbody>
113     <tfoot>
114       <tr><td colspan="7"></td></tr>
115     </tfoot>
116   </table>
117
118   <% if @object.state.in? %w(RunningOnServer RunningOnClient) %>
119
120     <% content_for :js do %>
121       setInterval(function(){$('a.refresh').click()}, 15000);
122     <% end %>
123
124     <% if !pipeline_job_uuids.empty? %>
125       <h4>Log messages from running jobs</h4>
126       <% log_history = pipeline_log_history(pipeline_job_uuids) %>
127       <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(" ")%>">
128         <% log_history.each do |entry| %>
129           <%=entry%><br/>
130         <% end %>
131       </div>
132     <% end %>
133
134   <% end %>
135
136 <% else %>
137   <%# state is either New or Ready %>
138
139   <% if @object.state.in? %w(New Ready) %>
140     <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>
141   <% end %>
142
143   <% content_for :tab_line_buttons do %>
144     <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
145         class: 'btn btn-primary run-pipeline-button',
146         method: :patch
147         ) do %>
148       Run <i class="fa fa-fw fa-play"></i>
149     <% end %>
150   <% end %>
151
152   <% if @object.state.in? ['New', 'Ready'] %>
153     <%= render partial: 'show_components_editable', locals: {editable: true} %>
154   <% else %>
155     <%= render partial: 'show_components_editable', locals: {editable: false} %>
156   <% end %>
157 <% end %>