9767: need to parse the json string of the workflow yaml
[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             </div>
65           <% elsif current_job[:state] == "Running" %>
66             <%# column offset 8 %>
67             <div class="col-md-3">
68               <span class="task-summary-status">
69                 <%= current_job[:tasks_summary][:done] %>&nbsp;<%= "task".pluralize(current_job[:tasks_summary][:done]) %> done,
70                 <%= current_job[:tasks_summary][:failed] %>&nbsp;failed,
71                 <%= current_job[:tasks_summary][:running] %>&nbsp;running,
72                 <%= current_job[:tasks_summary][:todo] %>&nbsp;pending
73               </span>
74             </div>
75           <% elsif current_job[:state].in? ["Complete", "Failed", "Cancelled"] %>
76             <%# column offset 8 %>
77             <div class="col-md-4 text-overflow-ellipsis">
78               <% if pj[:output_uuid] %>
79                 <%= link_to_arvados_object_if_readable(pj[:output_uuid], 'Output data not available', friendly_name: true) %>
80               <% elsif current_job[:output] %>
81                 <%= link_to_arvados_object_if_readable(current_job[:output], 'Output data not available', link_text: "Output of #{pj[:name]}") %>
82               <% else %>
83                 No output.
84               <% end %>
85             </div>
86           <% end %>
87
88           <% if current_job[:state].in? ["Queued", "Running"] and @object.editable? %>
89             <%# column offset 11 %>
90             <div class="col-md-1 pipeline-instance-spacing">
91               <%= form_tag "/jobs/#{current_job[:uuid]}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
92                 <%= hidden_field_tag :return_to, url_for(@object) %>
93                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
94               <% end %>
95             </div>
96           <% end %>
97         <% end %>
98       </div>
99     </div>
100   </div>
101
102   <div id="collapse<%= i %>" class="panel-collapse collapse <%= if expanded then 'in' end %>">
103     <div class="panel-body">
104       <div class="container">
105         <% current_component = (if current_job then current_job else pj end) %>
106         <div class="row">
107           <div class="col-md-6">
108             <table>
109               <% # link to repo tree/file only if the repo is readable
110                  # and the commit is a sha1...
111                  repo =
112                  (/^[0-9a-f]{40}$/ =~ current_component[:script_version] and
113                  Repository.where(name: current_component[:repository]).first)
114
115                  # ...and the api server provides an http:// or https:// url
116                  repo = nil unless repo.andand.http_fetch_url
117                  %>
118               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic].each do |k| %>
119                 <tr>
120                   <td style="padding-right: 1em">
121                     <%= k.to_s %>:
122                   </td>
123                   <td>
124                     <% if current_component[k].nil? %>
125                       (none)
126                     <% elsif repo and k == :repository %>
127                       <%= link_to current_component[k], show_repository_tree_path(id: repo.uuid, commit: current_component[:script_version], path: '/') %>
128                     <% elsif repo and k == :script %>
129                       <%= link_to current_component[k], show_repository_blob_path(id: repo.uuid, commit: current_component[:script_version], path: 'crunch_scripts/'+current_component[:script]) %>
130                     <% elsif repo and k == :script_version %>
131                       <%= link_to current_component[k], show_repository_commit_path(id: repo.uuid, commit: current_component[:script_version]) %>
132                     <% else %>
133                       <%= current_component[k] %>
134                     <% end %>
135                   </td>
136                 </tr>
137               <% end %>
138               <% if current_component[:runtime_constraints].andand[:docker_image] and current_component[:docker_image_locator] %>
139                 <tr>
140                   <td style="padding-right: 1em">
141                     docker_image:
142                   </td>
143                   <td>
144                     <%= current_component[:runtime_constraints][:docker_image] %>
145                   </td>
146                 </tr>
147                 <tr>
148                   <td style="padding-right: 1em">
149                     docker_image_locator:
150                   </td>
151                   <td>
152                     <%= link_to_arvados_object_if_readable(current_component[:docker_image_locator],
153                       current_component[:docker_image_locator], friendly_name: true) %>
154                   </td>
155                 </tr>
156               <% else %>
157                 <tr>
158                   <td style="padding-right: 1em">
159                     docker_image:
160                   </td>
161                   <td>
162                     Not run in Docker
163                   </td>
164                 </tr>
165               <% end %>
166             </table>
167           </div>
168           <div class="col-md-5">
169             <table>
170               <% [:uuid, :modified_by_user_uuid, :priority, :created_at, :started_at, :finished_at].each do |k| %>
171                 <tr>
172                   <td style="padding-right: 1em">
173                     <%= k.to_s %>:
174                   </td>
175                   <td>
176                     <% if k == :uuid %>
177                       <%= link_to_arvados_object_if_readable(current_component[k], current_component[k], link_text: current_component[k]) %>
178                     <% elsif k.to_s.end_with? 'uuid' %>
179                       <%= link_to_arvados_object_if_readable(current_component[k], current_component[k], friendly_name: true) %>
180                     <% elsif k.to_s.end_with? '_at' %>
181                       <%= render_localized_date(current_component[k]) %>
182                     <% else %>
183                       <%= current_component[k] %>
184                     <% end %>
185                   </td>
186                 </tr>
187               <% end %>
188             </table>
189           </div>
190         </div>
191         <div class="row">
192           <div class="col-md-6">
193             <p>script_parameters:</p>
194             <pre><%= JSON.pretty_generate(current_component[:script_parameters]) rescue nil %></pre>
195           </div>
196         </div>
197       </div>
198     </div>
199   </div>
200 </div>