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