Merge branch '8082-col-markup' refs #8082
[arvados.git] / apps / workbench / app / views / pipeline_instances / _running_component.html.erb
1 <% current_job = pj[:job] if pj[:job] != {} and pj[:job][:uuid] %>
2 <div class="panel panel-default">
3   <div class="panel-heading">
4     <div class="container-fluid">
5       <div class="row-fluid">
6         <%# column offset 0 %>
7         <div class="col-md-2" style="word-break:break-all;">
8           <h4 class="panel-title">
9             <a data-toggle="collapse" href="#collapse<%= i %>">
10               <%= pj[:name] %> <span class="caret"></span>
11             </a>
12           </h4>
13         </div>
14
15         <%# column offset 2 %>
16         <div class="col-md-2 pipeline-instance-spacing">
17           <%= pj[:progress_bar] %>
18         </div>
19
20         <%# column offset 4 %>
21         <% if not current_job %>
22           <div class="col-md-8"></div>
23         <% else %>
24           <div class="col-md-1">
25             <% if (pipeline_display rescue nil) %>
26               <% if current_job[:state].in? ["Complete", "Failed", "Cancelled"] %>
27                 <% if current_job[:log] %>
28                   <% logCollection = Collection.find? current_job[:log] %>
29                   <% if logCollection %>
30                     <%= link_to "Log", job_path(current_job[:uuid], anchor: "Log") %>
31                   <% else %>
32                     Log unavailable
33                   <% end %>
34                 <% end %>
35               <% elsif current_job[:state] == "Running" %>
36                 <% job = Job.find? current_job[:uuid] %>
37                 <% if job %>
38                   <%= link_to "Log", job_path(current_job[:uuid], anchor: "Log") %>
39                 <% else %>
40                   Log unavailable
41                 <% end %>
42               <% end %>
43             <% end %>
44           </div>
45
46           <%# column offset 5 %>
47           <% if current_job[:state] != "Queued" %>
48           <div class="col-md-3">
49             <% if current_job[:started_at] %>
50               <% walltime = ((if current_job[:finished_at] then current_job[:finished_at] else Time.now() end) - current_job[:started_at]) %>
51               <% cputime = (current_job[:runtime_constraints].andand[:min_nodes] || 1) *
52                            ((current_job[:finished_at] || Time.now()) - current_job[:started_at]) %>
53               <%= render_runtime(walltime, false) %>
54               <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)<% end %>
55             <% end %>
56           </div>
57           <% end %>
58
59           <% if current_job[:state] == "Queued" %>
60             <%# column offset 5 %>
61             <div class="col-md-6">
62               <% queuetime = Time.now - Time.parse(current_job[:created_at].to_s) %>
63               Queued for <%= render_runtime(queuetime, false) %>.
64               <% begin %>
65                 <% if current_job[:queue_position] == 0 %>
66                   This job is next in the queue to run.
67                 <% elsif current_job[:queue_position] == 1 %>
68                   There is 1 job in the queue ahead of this one.
69                 <% elsif current_job[:queue_position] %>
70                   There are <%= current_job[:queue_position] %> jobs in the queue ahead of this one.
71                 <% end %>
72               <% rescue %>
73               <% end %>
74             </div>
75           <% elsif current_job[:state] == "Running" %>
76             <%# column offset 8 %>
77             <div class="col-md-3">
78               <span class="task-summary-status">
79                 <%= current_job[:tasks_summary][:done] %>&nbsp;<%= "task".pluralize(current_job[:tasks_summary][:done]) %> done,
80                 <%= current_job[:tasks_summary][:failed] %>&nbsp;failed,
81                 <%= current_job[:tasks_summary][:running] %>&nbsp;running,
82                 <%= current_job[:tasks_summary][:todo] %>&nbsp;pending
83               </span>
84             </div>
85           <% elsif current_job[:state].in? ["Complete", "Failed", "Cancelled"] %>
86             <%# column offset 8 %>
87             <div class="col-md-4 text-overflow-ellipsis">
88               <% if pj[:output_uuid] %>
89                 <%= link_to_arvados_object_if_readable(pj[:output_uuid], 'Output data not available', friendly_name: true) %>
90               <% elsif current_job[:output] %>
91                 <%= link_to_arvados_object_if_readable(current_job[:output], 'Output data not available', link_text: "Output of #{pj[:name]}") %>
92               <% else %>
93                 No output.
94               <% end %>
95             </div>
96           <% end %>
97
98           <% if current_job[:state].in? ["Queued", "Running"] and @object.editable? %>
99             <%# column offset 11 %>
100             <div class="col-md-1 pipeline-instance-spacing">
101               <%= form_tag "/jobs/#{current_job[:uuid]}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
102                 <%= hidden_field_tag :return_to, url_for(@object) %>
103                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
104               <% end %>
105             </div>
106           <% end %>
107         <% end %>
108       </div>
109     </div>
110   </div>
111
112   <div id="collapse<%= i %>" class="panel-collapse collapse <%= if expanded then 'in' end %>">
113     <div class="panel-body">
114       <div class="container">
115         <% current_component = (if current_job then current_job else pj end) %>
116         <div class="row">
117           <div class="col-md-6">
118             <table>
119               <% # link to repo tree/file only if the repo is readable
120                  # and the commit is a sha1...
121                  repo =
122                  (/^[0-9a-f]{40}$/ =~ current_component[:script_version] and
123                  Repository.where(name: current_component[:repository]).first)
124
125                  # ...and the api server provides an http:// or https:// url
126                  repo = nil unless repo.andand.http_fetch_url
127                  %>
128               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic].each do |k| %>
129                 <tr>
130                   <td style="padding-right: 1em">
131                     <%= k.to_s %>:
132                   </td>
133                   <td>
134                     <% if current_component[k].nil? %>
135                       (none)
136                     <% elsif repo and k == :repository %>
137                       <%= link_to current_component[k], show_repository_tree_path(id: repo.uuid, commit: current_component[:script_version], path: '/') %>
138                     <% elsif repo and k == :script %>
139                       <%= link_to current_component[k], show_repository_blob_path(id: repo.uuid, commit: current_component[:script_version], path: 'crunch_scripts/'+current_component[:script]) %>
140                     <% elsif repo and k == :script_version %>
141                       <%= link_to current_component[k], show_repository_commit_path(id: repo.uuid, commit: current_component[:script_version]) %>
142                     <% else %>
143                       <%= current_component[k] %>
144                     <% end %>
145                   </td>
146                 </tr>
147               <% end %>
148               <% if current_component[:runtime_constraints].andand[:docker_image] and current_component[:docker_image_locator] %>
149                 <tr>
150                   <td style="padding-right: 1em">
151                     docker_image:
152                   </td>
153                   <td>
154                     <%= current_component[:runtime_constraints][:docker_image] %>
155                   </td>
156                 </tr>
157                 <tr>
158                   <td style="padding-right: 1em">
159                     docker_image_locator:
160                   </td>
161                   <td>
162                     <%= link_to_arvados_object_if_readable(current_component[:docker_image_locator],
163                       current_component[:docker_image_locator], friendly_name: true) %>
164                   </td>
165                 </tr>
166               <% else %>
167                 <tr>
168                   <td style="padding-right: 1em">
169                     docker_image:
170                   </td>
171                   <td>
172                     Not run in Docker
173                   </td>
174                 </tr>
175               <% end %>
176             </table>
177           </div>
178           <div class="col-md-5">
179             <table>
180               <% [:uuid, :modified_by_user_uuid, :priority, :created_at, :started_at, :finished_at].each do |k| %>
181                 <tr>
182                   <td style="padding-right: 1em">
183                     <%= k.to_s %>:
184                   </td>
185                   <td>
186                     <% if k == :uuid %>
187                       <%= link_to_arvados_object_if_readable(current_component[k], current_component[k], link_text: current_component[k]) %>
188                     <% elsif k.to_s.end_with? 'uuid' %>
189                       <%= link_to_arvados_object_if_readable(current_component[k], current_component[k], friendly_name: true) %>
190                     <% elsif k.to_s.end_with? '_at' %>
191                       <%= render_localized_date(current_component[k]) %>
192                     <% else %>
193                       <%= current_component[k] %>
194                     <% end %>
195                   </td>
196                 </tr>
197               <% end %>
198             </table>
199           </div>
200         </div>
201         <div class="row">
202           <div class="col-md-6">
203             <p>script_parameters:</p>
204             <pre><%= JSON.pretty_generate(current_component[:script_parameters]) rescue nil %></pre>
205           </div>
206         </div>
207       </div>
208     </div>
209   </div>
210 </div>