2872: Add "clone and edit" button to pipeline instance page.
[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   <% if @object.state.in? ['RunningOnClient', 'RunningOnServer'] %>
27     <% content_for :tab_line_buttons do %>
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     <% end %>
35   <% end %>
36
37   <% pipeline_job_uuids = [] %>
38
39   <div class="pull-right">
40     Current state: <span class="badge badge-info"><%= @object.state.sub('OnServer', '') %></span>&nbsp;
41   </div>
42
43   <table class="table pipeline-components-table">
44     <colgroup>
45       <col style="width: 15%" />
46       <col style="width: 20%" />
47       <col style="width: 12%" />
48       <col style="width: 12%" />
49       <col style="width: 45%" />
50     </colgroup>
51     <thead>
52       <tr>
53         <th>
54           component
55         </th><th>
56           script, version
57         </th><th>
58           job
59           <%# format:'js' here helps browsers avoid using the cached js
60           content in html context (e.g., duplicate tab -> see
61           javascript) %>
62           <%= link_to '(refresh)', {format: :js}, {class: 'refresh hide', remote: true, method: 'get'} %>
63         </th><th>
64         </th><th>
65           output
66         </th>
67       </tr>
68     </thead>
69     <tbody>
70       <% render_pipeline_jobs.each do |pj| %>
71         <% if pj[:job].andand[:uuid]
72              pipeline_job_uuids << pj[:job][:uuid]
73            end %>
74       <tr>
75         <td>
76           <%= pj[:name] %>
77         </td><td>
78           <%= pj[:script] %>
79           <br /><span class="deemphasize"><%= pj[:script_version] %></span>
80         </td><td>
81           <%= pj[:progress_bar] %>
82           <% if @object.state == 'Complete' || @object.state == 'Failed' %>
83             <% if pj[:job].andand[:uuid] %>
84               <span class="deemphasize">
85               <%= link_to("..."+pj[:job][:uuid].last(15), job_url(id: pj[:job][:uuid])) %>
86               </span>
87
88               <% current_job = Job.find(pj[:job][:uuid]) rescue nil %>
89               <% if current_job.andand[:log] %>
90                 <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(current_job[:log])%>
91                 <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
92                   <% c.files.each do |file| %>
93                     <br/><span class="deemphasize">
94                     <a href="<%= collection_path(current_job[:log]) %>/<%= file[1] %>?disposition=inline&size=<%= file[2] %>">log</a>
95                     </span>
96                   <% end %>
97                 <% end %>
98               <% end %>
99             <% end %>
100           <% end %>
101         </td><td>
102           <%= render(partial: 'job_status_label',
103                                  locals: { :j => pj[:job] }) %>
104         </td><td>
105           <%= link_to_if_arvados_object pj[:output], {:thumbnail => true} %>
106         </td>
107       </tr>
108       <% end %>
109     </tbody>
110     <tfoot>
111       <tr><td colspan="5"></td></tr>
112     </tfoot>
113   </table>
114
115   <% if @object.state.in? %w(RunningOnServer RunningOnClient) %>
116
117     <% content_for :js do %>
118       setInterval(function(){$('a.refresh').click()}, 15000);
119     <% end %>
120
121     <% if !pipeline_job_uuids.empty? %>
122       <h4>Log messages from running jobs</h4>
123       <% log_history = pipeline_log_history(pipeline_job_uuids) %>
124       <div id="pipeline_event_log_history_div">
125         <% log_history.each do |entry| %>
126           <%=entry%><br/>
127         <% end %>
128       </div>
129       <div class="arv-log-event-listener arv-log-event-handler-append-logs" id="pipeline_event_log_div" data-object-uuids="<%=pipeline_job_uuids.join(" ")%>"/>
130     <% end %>
131
132   <% end %>
133
134 <% else %>
135   <%# state is either New or Ready %>
136
137   <% if @object.state.in? %w(New Ready) %>
138     <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>
139   <% end %>
140
141   <% content_for :tab_line_buttons do %>
142     <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
143         class: 'btn btn-primary run-pipeline-button',
144         method: :patch
145         ) do %>
146       Run <i class="fa fa-fw fa-play"></i>
147     <% end %>
148   <% end %>
149
150   <% if @object.state.in? ['New', 'Ready'] %>
151     <%= render partial: 'show_components_editable', locals: {editable: true} %>
152   <% else %>
153     <%= render partial: 'show_components_editable', locals: {editable: false} %>
154   <% end %>
155 <% end %>