038efece35e06fb00dc5431d95e58a287c78e72d
[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">
6           <div class="col-md-3">
7             <h4 class="panel-title">
8               <a data-toggle="collapse" href="#collapse<%= i %>" style="white-space: nowrap;">
9                 <%= pj[:name] %> <span class="caret"></span>
10               </a>
11             </h4>
12           </div>
13
14           <% if current_job %>
15             <div class="col-md-1">
16               <%= render(partial: 'job_status_label', locals: { j: current_job }) %>
17             </div>
18
19             <div class="col-md-3">
20               <% if current_job[:started_at] %>
21                 <% walltime = ((if current_job[:finished_at] then current_job[:finished_at] else Time.now() end) - current_job[:started_at]) %>
22                 <% cputime = tasks.map { |task|
23                      if task.started_at and task.job_uuid == current_job[:uuid]
24                        (if task.finished_at then task.finished_at else Time.now() end) - task.started_at
25                      else
26                        0
27                      end
28                    }.reduce(:+) || 0 %>
29                 <%= render_runtime(walltime, false, false) %>
30                 <% if cputime > 0 %> / <%= render_runtime(cputime, false, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)<% end %>
31               <% end %>
32             </div>
33
34             <% if current_job[:state].in? ["Complete", "Failed", "Cancelled"] %>
35               <div class="col-md-5 text-overflow-ellipsis">
36                 <% if pj[:output_uuid] %>
37                   <%= link_to_if_arvados_object pj[:output_uuid], friendly_name: true %>
38                 <% elsif current_job[:output] %>
39                   <%= link_to_if_arvados_object current_job[:output], link_text: "Output of #{pj[:name]}" %>
40                 <% else %>
41                   No output.
42                 <% end %>
43               </div>
44             <% elsif current_job[:state] == "Running" %>
45               <div class="col-md-3 pipeline-instance-spacing">
46                 <%= pj[:progress_bar] %>
47               </div>
48               <div class="col-md-1 pipeline-instance-spacing">
49                 <%= form_tag "/jobs/#{current_job[:uuid]}/cancel", style: "display:inline; padding-left: 1em" do |f| %>
50                 <%= hidden_field_tag :return_to, url_for(@object) %>
51                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
52             </div>
53             <% end %>
54           <% elsif current_job[:state] == "Queued" %>
55             <div class="col-md-5">
56               <% queuetime = Time.now - current_job[:created_at] %>
57               Queued for <%= render_runtime(queuetime, true) %>.
58               <% begin %>
59               <% if current_job[:queue_position] == 0 %>
60                 This job is next in the queue to run.
61               <% elsif current_job[:queue_position] == 1 %>
62                 There is 1 job in the queue ahead of this one.
63               <% else  %>
64                 There are <%= current_job[:queue_position] %> jobs in the queue ahead of this one.
65               <% end %>
66               <% rescue %>
67           <% end %>
68             </div>
69           <% end %>
70         <% else %>
71           <div class="col-md-3 col-md-offset-3">
72             <span class="label label-default">Not ready</span>
73           </div>
74 <% end %>
75 </div>
76 </div>
77 </div>
78
79 <div id="collapse<%= i %>" class="panel-collapse collapse <%= if expanded then 'in' end %>">
80   <div class="panel-body">
81     <div class="container">
82         <% current_component = (if current_job then current_job else pj end) %>
83         <div class="row">
84           <div class="col-md-6">
85             <table>
86               <% [:script, :repository, :script_version, :supplied_script_version, :nondeterministic].each do |k| %>
87                 <tr>
88                   <td style="padding-right: 1em">
89                     <%= k.to_s %>:
90                   </td>
91                   <td>
92                     <% if current_component[k].nil? %>
93                       (none)
94                     <% else %>
95                       <%= current_component[k] %>
96                     <% end %>
97                   </td>
98                 </tr>
99               <% end %>
100               <% if current_component[:runtime_constraints].andand[:docker_image] and current_component[:docker_image_locator] %>
101                 <tr>
102                   <td style="padding-right: 1em">
103                     docker_image:
104                   </td>
105                   <td>
106                     <%= current_component[:runtime_constraints][:docker_image] %>
107                   </td>
108                 </tr>
109                 <tr>
110                   <td style="padding-right: 1em">
111                     docker_image_locator:
112                   </td>
113                   <td>
114                     <%= link_to_if_arvados_object current_component[:docker_image_locator], friendly_name: true %>
115                   </td>
116                 </tr>
117               <% else %>
118                 <tr>
119                   <td style="padding-right: 1em">
120                     docker_image:
121                   </td>
122                   <td>
123                     Not run in Docker
124                   </td>
125                 </tr>
126               <% end %>
127             </table>
128           </div>
129           <div class="col-md-5">
130             <table>
131               <% [:uuid, :modified_by_user_uuid, :priority, :created_at, :started_at, :finished_at].each do |k| %>
132                 <tr>
133                   <td style="padding-right: 1em">
134                     <%= k.to_s %>:
135                   </td>
136                   <td>
137                     <% if k == :uuid %>
138                       <%= link_to_if_arvados_object current_component[k], link_text: current_component[k] %>
139                     <% elsif k.to_s.end_with? 'uuid' %>
140                       <%= link_to_if_arvados_object current_component[k], friendly_name: true %>
141                     <% elsif k.to_s.end_with? '_at' %>
142                       <%= render_localized_date(current_component[k]) %>
143                     <% else %>
144                       <%= current_component[k] %>
145                     <% end %>
146                   </td>
147                 </tr>
148               <% end %>
149             </table>
150           </div>
151         </div>
152         <div class="row">
153           <div class="col-md-6">
154             <p>script_parameters:</p>
155             <pre><%= JSON.pretty_generate(current_component[:script_parameters]) rescue nil %></pre>
156           </div>
157           <% if current_component[:tasks_summary] %>
158           <div class="col-md-3">
159             <table>
160               <% [:done, :running, :failed, :todo].each do |d| %>
161               <tr>
162                 <td style="padding-right: 1em"><%= 'tasks:' if d == :done %></td>
163                 <td style="padding-right: 1em"><%= d.to_s %></td>
164                 <td><%= current_component[:tasks_summary][d] %></td>
165               </tr>
166               <% end %>
167             </table>
168           </div>
169           <% end %>
170         </div>
171     </div>
172   </div>
173 </div>
174 </div>