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