Merge branch '3381-job-progress-bar-bug' closes #3381
[arvados.git] / apps / workbench / app / views / users / _tables.html.erb
1 <% if current_user.andand.is_active %>
2   <div>
3     <strong>Recent jobs</strong>
4     <%= link_to '(refresh)', {format: :js}, {class: 'refresh', remote: true, method: 'get'} %>
5     <%= link_to raw("Show all jobs &rarr;"), jobs_path, class: 'pull-right' %>
6     <% if not current_user.andand.is_active or @my_jobs.empty? %>
7       <p>(None)</p>
8     <% else %>
9       <table class="table table-bordered table-condensed table-fixedlayout">
10         <colgroup>
11           <col width="20%" />
12           <col width="20%" />
13           <col width="20%" />
14           <col width="13%" />
15           <col width="13%" />
16           <col width="20%" />
17         </colgroup>
18
19         <tr>
20           <th>Script</th>
21           <th>Output</th>
22           <th>Log</th>
23           <th>Created at</th>
24           <th>Status</th>
25         </tr>
26
27         <%# Preload collections, logs, and pipeline instance objects %>
28         <%
29           collection_uuids = []
30           log_uuids = []
31           @my_jobs[0..6].each do |j|
32             collection_uuids << j.output
33             log_uuids << j.log
34           end
35
36           @my_collections[0..6].each do |c|
37             collection_uuids << c.uuid
38           end
39
40           preload_collections_for_objects collection_uuids
41           preload_log_collections_for_objects log_uuids
42
43           pi_uuids = []
44           @my_pipelines[0..6].each do |p|
45             pi_uuids << p.uuid
46           end
47           resource_class = resource_class_for_uuid(pi_uuids.first, friendly_name: true)
48           preload_objects_for_dataclass resource_class, pi_uuids
49         %>
50
51         <% @my_jobs[0..6].each do |j| %>
52           <tr data-object-uuid="<%= j.uuid %>">
53             <td>
54               <small>
55                 <%= link_to((j.script.andand[0..31] || j.uuid), job_path(j.uuid)) %>
56               </small>
57             </td>
58
59             <td>
60               <small>
61                 <% if j.state == "Complete" and j.output %>
62                   <a href="<%= collection_path(j.output) %>">
63                     <% collections = collections_for_object(j.output) %>
64                       <% if collections && !collections.empty? %>
65                       <% c = collections.first %>
66                       <% c.files.each do |file| %>
67                         <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
68                       <% end %>
69                      <% end %>
70                   </a>
71               <% end %>
72             </small>
73           </td>
74
75 <td>
76   <small>
77     <% if j.log %>
78       <% log_collections = log_collections_for_object(j.log) %>
79       <% if log_collections && !log_collections.empty? %>
80         <% c = log_collections.first %>
81         <% c.files.each do |file| %>
82           <a href="<%= collection_path(j.log) %>/<%= file[1] %>?disposition=inline&size=<%= file[2] %>">Log</a>
83         <% end %>
84       <% end %>
85     <% elsif j.respond_to? :log_buffer and j.log_buffer.is_a? String %>
86       <% buf = j.log_buffer.strip.split("\n").last %>
87       <span title="<%= buf %>"><%= buf %></span>
88     <% end %>
89   </small>
90 </td>
91
92 <td>
93   <small>
94     <%= j.created_at.to_s if j.created_at %>
95   </small>
96 </td>
97
98 <td>
99   <div class="inline-progress-container">
100   <%= render partial: 'job_progress', locals: {:j => j} %>
101   </div>
102 </td>
103
104 </tr>
105 <% end %>
106 </table>
107 <% end %>
108 </div>
109
110 <div>
111   <strong>Recent pipeline instances</strong>
112   <%= link_to '(refresh)', {format: :js}, {class: 'refresh', remote: true, method: 'get'} %>
113   <%= link_to raw("Show all pipeline instances &rarr;"), pipeline_instances_path, class: 'pull-right' %>
114   <% if not current_user.andand.is_active or @my_pipelines.empty? %>
115     <p>(None)</p>
116   <% else %>
117     <table class="table table-bordered table-condensed table-fixedlayout">
118       <colgroup>
119         <col width="30%" />
120         <col width="30%" />
121         <col width="13%" />
122         <col width="13%" />
123         <col width="20%" />
124       </colgroup>
125
126       <tr>
127         <th>Instance</th>
128         <th>Template</th>
129         <th>Created at</th>
130         <th>Status</th>
131         <th>Progress</th>
132       </tr>
133
134       <% @my_pipelines[0..6].each do |p| %>
135         <tr data-object-uuid="<%= p.uuid %>">
136           <td>
137             <small>
138               <%= link_to_if_arvados_object p.uuid, friendly_name: true %>
139             </small>
140           </td>
141
142           <td>
143             <small>
144               <%= link_to_if_arvados_object p.pipeline_template_uuid, friendly_name: true %>
145             </small>
146           </td>
147
148           <td>
149             <small>
150               <%= (p.created_at.to_s) if p.created_at %>
151             </small>
152           </td>
153
154           <td>
155             <%= render partial: 'pipeline_status_label', locals: {:p => p} %>
156           </td>
157
158           <td>
159             <div class="inline-progress-container">
160               <%= render partial: 'pipeline_progress', locals: {:p => p} %>
161             </div>
162           </td>
163         </tr>
164       <% end %>
165     </table>
166   <% end %>
167 </div>
168
169 <div>
170   <strong>Recent collections</strong>
171   <%= link_to '(refresh)', {format: :js}, {class: 'refresh', remote: true, method: 'get'} %>
172   <%= link_to raw("Show all collections &rarr;"), collections_path, class: 'pull-right' %>
173   <div class="pull-right" style="padding-right: 1em; width: 30%;">
174     <%= form_tag collections_path,
175           method: 'get',
176           class: 'form-search small-form-margin' do %>
177     <div class="input-group input-group-sm">
178       <%= text_field_tag :search, params[:search], class: 'form-control', placeholder: 'Search' %>
179       <span class="input-group-btn">
180         <%= button_tag(class: 'btn btn-info') do %>
181         <span class="glyphicon glyphicon-search"></span>
182         <% end %>
183       </span>
184     </div>
185     <% end %>
186   </div>
187   <% if not current_user.andand.is_active or @my_collections.empty? %>
188     <p>(None)</p>
189   <% else %>
190     <table class="table table-bordered table-condensed table-fixedlayout">
191       <colgroup>
192         <col width="46%" />
193         <col width="32%" />
194         <col width="10%" />
195         <col width="12%" />
196       </colgroup>
197
198       <tr>
199         <th>Contents</th>
200         <th>Tags</th>
201         <th>Age</th>
202         <th>Storage</th>
203       </tr>
204
205       <% @my_collections[0..6].each do |c| %>
206         <tr data-object-uuid="<%= c.uuid %>">
207           <td>
208             <small>
209               <a href="<%= collection_path(c.uuid) %>">
210                 <% c.files.each do |file| %>
211                   <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
212                 <% end %>
213               </a>
214             </small>
215           </td>
216           <td>
217             <% if @my_tag_links[c.uuid] %>
218             <small>
219               <%= @my_tag_links[c.uuid].collect(&:name).join(", ") %>
220             </small>
221             <% end %>
222           </td>
223           <td>
224             <small>
225               <%= c.created_at.to_s if c.created_at %>
226             </small>
227           </td>
228           <td>
229             <%= render partial: 'collections/toggle_persist', locals: { uuid: c.uuid, current_state: @persist_state[c.uuid] } %>
230           </td>
231         </tr>
232       <% end %>
233     </table>
234   <% end %>
235 </div>
236
237 <% else %>
238
239   <div class="row-fluid">
240     <div class="col-sm-4">
241       <%= image_tag "dax.png", style: "max-width:100%" %>
242     </div>
243     <div class="col-sm-8">
244       <h2>Welcome to Arvados, <%= current_user.first_name %>!</h2>
245       <div class="well">
246         <p>
247           Your account must be activated by an Arvados administrator.  If this
248           is your first time accessing Arvados and would like to request
249           access, or you believe you are seeing the page in error, please
250           <%= link_to "contact us", Rails.configuration.activation_contact_link %>.
251           You should receive an email at the address you used to log in when
252           your account is activated.  In the mean time, you can
253           <%= link_to "learn more about Arvados", "https://arvados.org/projects/arvados/wiki/Introduction_to_Arvados" %>,
254           and <%= link_to "read the Arvados user guide", "http://doc.arvados.org/user" %>.
255         </p>
256         <p style="padding-bottom: 1em">
257           <%= link_to raw('Contact us &#x2709;'),
258               Rails.configuration.activation_contact_link, class: "pull-right btn btn-primary" %></p>
259       </div>
260     </div>
261   </div>
262 <% end %>
263
264 <% content_for :js do %>
265 setInterval(function(){$('a.refresh:eq(0)').click()}, 60000);
266 <% end %>