a93895ba8285a1b9ec524cd924d7b7b5f9c51b38
[arvados.git] / apps / workbench / app / views / work_unit / _show_child.html.erb
1 <div class="panel panel-default">
2   <div class="panel-heading">
3     <div class="container-fluid">
4       <div class="row-fluid">
5         <%# column offset 0 %>
6         <div class="col-md-2" style="word-break:break-all;">
7           <h4 class="panel-title">
8             <a data-toggle="collapse" href="#collapse<%= i %>">
9               <%= current_obj.label %> <span class="caret"></span>
10             </a>
11           </h4>
12         </div>
13
14         <%# column offset 2 %>
15         <div class="col-md-2 pipeline-instance-spacing">
16           <%= render partial: 'work_unit/progress', locals: {wu: current_obj} %>
17         </div>
18
19         <%# column offset 4 %>
20         <% if not current_obj %>
21           <div class="col-md-8"></div>
22         <% else %>
23           <div class="col-md-1">
24               <% if current_obj.state_label.in? ["Complete", "Failed", "Cancelled"] %>
25                 <% if current_obj.log_collection %>
26                   <% logCollection = Collection.find? current_obj.log_collection %>
27                   <% if logCollection %>
28                     <%= link_to "Log", job_path(current_obj.uuid, anchor: "Log") %>
29                   <% else %>
30                     Log unavailable
31                   <% end %>
32                 <% end %>
33               <% elsif current_obj.state_label == "Running" %>
34                 <% job = Job.find? current_obj.uuid %>
35                 <% if job %>
36                   <%= link_to "Log", job_path(current_obj.uuid, anchor: "Log") %>
37                 <% else %>
38                   Log unavailable
39                 <% end %>
40               <% end %>
41           </div>
42
43           <%# column offset 5 %>
44           <% if current_obj.state_label != "Queued" %>
45           <div class="col-md-3">
46             <% if current_obj.started_at %>
47               <% walltime = ((if current_obj.finished_at then current_obj.finished_at else Time.now() end) - current_obj.started_at) %>
48               <% cputime = (current_obj.runtime_constraints.andand[:min_nodes] || 1) *
49                            ((current_obj.finished_at || Time.now()) - current_obj.started_at) %>
50               <%= render_runtime(walltime, false) %>
51               <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)<% end %>
52             <% end %>
53           </div>
54           <% end %>
55
56           <% if current_obj.state_label == "Queued" %>
57             <%# column offset 5 %>
58             <div class="col-md-6">
59               <% queuetime = Time.now - Time.parse(current_obj.created_at.to_s) %>
60               Queued for <%= render_runtime(queuetime, false) %>.
61             </div>
62           <% elsif current_obj.state_label == "Running" %>
63             <% if current_obj.child_summary %>
64               <%# column offset 8 %>
65               <div class="col-md-3">
66                 <span class="task-summary-status">
67                   <%= current_obj.child_summary[:done] %>&nbsp;<%= "task".pluralize(current_obj.child_summary[:done]) %> done,
68                   <%= current_obj.child_summary[:failed] %>&nbsp;failed,
69                   <%= current_obj.child_summary[:running] %>&nbsp;running,
70                   <%= current_obj.child_summary[:todo] %>&nbsp;pending
71                 </span>
72               </div>
73             <% end %>
74           <% elsif current_obj.state_label.in? ["Complete", "Failed", "Cancelled"] %>
75             <%# column offset 8 %>
76             <div class="col-md-4 text-overflow-ellipsis">
77               <% if current_obj.output %>
78                 <%= link_to_arvados_object_if_readable(current_obj.output, 'Output data not available', friendly_name: true) %>
79               <% elsif current_obj.output %>
80                 <%= link_to_arvados_object_if_readable(current_obj.output, 'Output data not available', link_text: "Output of #{current_obj.label}") %>
81               <% else %>
82                 No output.
83               <% end %>
84             </div>
85           <% end %>
86
87           <% if current_obj.state_label.in? ["Queued", "Running"] and @object.work_unit.can_cancel? and @object.editable? %>
88             <%# column offset 11 %>
89             <div class="col-md-1 pipeline-instance-spacing">
90               <%= form_tag "#{current_obj.uri}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
91                 <%= hidden_field_tag :return_to, url_for(@object) %>
92                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
93               <% end %>
94             </div>
95           <% end %>
96         <% end %>
97       </div>
98     </div>
99   </div>
100
101   <div id="collapse<%= i %>" class="panel-collapse collapse <%= if expanded then 'in' end %>">
102     <div class="panel-body">
103       <%= render partial: 'work_unit/show_component', locals: {wu: current_obj} %>
104     </div>
105   </div>
106 </div>