Added system status box
[arvados.git] / apps / workbench / app / views / users / home.html.erb
1 <% content_for :head do %>
2     <style>
3       .dash-list {
4         padding: 9px 0;
5       }
6       .dash-list>ul>li>a>span {
7       min-width: 1.5em;
8       margin-left: auto;
9       margin-right: auto;
10       }
11       .job-table {
12       white-space: nowrap;
13       table-layout: fixed;
14       }
15       .job-table td {
16       overflow: hidden;
17       overflow-x: hidden;
18       text-overflow: ellipsis;
19       }
20       .centerme {
21       margin-left: auto;
22       margin-right: auto;
23       text-align: center;
24       }
25       .bigfatnumber {
26       font-size: 4em;
27       font-weight: bold;
28       }
29       .dax {
30       max-width: 10%;
31       margin-right: 1em;
32       float: left
33       }
34       .daxalert {
35       overflow: hidden;
36       }
37     </style>
38 <% end %>
39
40 <% if current_user.andand.is_active %>
41
42 <div class="container-fluid">
43   
44   <div class="span7">
45
46     <div>
47       <strong>Recent jobs</strong>
48       <%= link_to raw("Show all jobs &rarr;"), jobs_path, class: 'pull-right' %>
49       <% if not current_user.andand.is_active or @my_jobs.empty? %>
50       (None)
51       <% else %>
52       <table class="table table-bordered table-condensed job-table">
53         <colgroup>
54           <col width="28%" />
55           <col width="38%" />
56           <col width="7%" />
57           <col width="15%" />
58           <col width="12%" />
59         </colgroup>
60
61         <tr>
62           <th>Script</th>
63           <th>Output</th>
64           <th>Log</th>
65           <th>Status</th>
66           <th>Age</th>
67         </tr>
68
69         <% @my_jobs[0..6].each do |j| %>
70         <tr>
71           <td>
72             <small>
73               <%= link_to j.script[0..31], job_path(j.uuid) %>
74             </small>
75           </td>
76
77           <td>
78             <small>
79             <% if j.success %>
80
81               <a href="<%= collection_path(j.output) %>">
82                 <% Collection.limit(1).where(uuid: j.output).each do |c|
83                        c.files.each do |file| %>
84                   <%= "#{file[0]}/#{file[1]}" %>
85                 <% end %>
86                 <% end %>
87               </a>
88
89             <% end %>
90             </small>
91           </td>
92
93           <td>
94             <small>
95             <% if j.success %>
96               <a href="<%= collection_path(j.log) %>">Log</a>
97             <% end %>
98             </small>
99           </td>
100
101           <td>
102             <small>
103 <%= raw(distance_of_time_in_words(j[:created_at], Time.now).sub('about
104 ','~').sub(' ','&nbsp;')) if j[:created_at] %> ago
105             </small>
106           </td>
107
108           <td>
109             <% if j.success %>
110             <span class="label label-success">finished</span>
111             <% elsif j.success == false %>
112             <span class="label label-danger">failed</span>
113             <% elsif j.running and j.started_at and not j.finished_at %>
114             <% percent_total_tasks = 100 / (j.tasks_summary[:running] + j.tasks_summary[:done] + j.tasks_summary[:todo]) rescue 0 %>
115             <div class="progress" style="margin-bottom: 0">
116               <div class="bar bar-success" style="width: <%= j.tasks_summary[:done] * percent_total_tasks rescue 0 %>%;"></div>
117               <div class="bar" style="width: <%= j.tasks_summary[:running] * percent_total_tasks rescue 0 %>%; opacity: 0.3"></div>
118             </div>
119             <% else %>
120             <span class="label">queued</span>
121             <% end %>
122           </td>
123
124         </tr>
125         <% end %>
126       </table>
127       <% end %>
128     </div>
129
130     <div>
131       <strong>Recent pipeline instances</strong>
132       <%= link_to raw("Show all pipeline instances &rarr;"), jobs_path, class: 'pull-right' %>
133       <% if not current_user.andand.is_active or @my_pipelines.empty? %>
134       (None)
135       <% else %>
136       <table class="table table-bordered table-condensed job-table">
137         <colgroup>
138           <col width="73%" />
139           <col width="15%" />
140           <col width="12%" />
141         </colgroup>
142
143         <tr>
144           <th>Pipeline template</th>
145           <th>Age</th>
146           <th>Status</th>
147         </tr>
148
149         <% @my_pipelines[0..6].each do |p| %>
150         <tr>
151           <td>
152             <small>
153               <% PipelineTemplate.limit(1).where(uuid: p.pipeline_template_uuid).each do |i| %>
154                 <%= link_to i.name, pipeline_instance_path(p.uuid) %>
155               <% end %>
156             </small>
157           </td>
158
159           <td>
160             <small>
161 <%= raw(distance_of_time_in_words(p[:created_at], Time.now).sub('about
162 ','~').sub(' ','&nbsp;')) if p[:created_at] %> ago
163             </small>
164           </td>
165
166           <td>
167             <% if p.success %>
168             <span class="label label-success">finished</span>
169             <% elsif p.success == false %>
170             <span class="label label-danger">failed</span>
171             <% elsif p.active %>
172             <span class="label label-info">running</span>
173             <% else %>
174             <span class="label">queued</span>
175             <% end %>
176           </td>
177
178         </tr>
179         <% end %>
180       </table>
181       <% end %>
182     </div>
183
184     <div>
185       <strong>Recent collections</strong>
186       <%= link_to raw("Show all collections &rarr;"), collections_path, class: 'pull-right' %>
187       <% if not current_user.andand.is_active or @my_collections.empty? %>
188       (None)
189       <% else %>
190       <table class="table table-bordered table-condensed job-table">
191         <colgroup>
192           <col width="73%" />
193           <col width="27%" />
194         </colgroup>
195
196         <tr>
197           <th>Contents</th>
198           <th>Age</th>
199         </tr>
200
201         <% @my_collections[0..6].each do |c| %>
202         <tr>
203           <td>
204             <small>
205               <a href="<%= collection_path(c.uuid) %>">
206               <% c.files.each do |file| %>
207               <%= "#{file[0]}/#{file[1]}" %>
208               <% end %>
209               </a>
210             </small>
211           </td>
212           <td>
213             <small>
214 <%= raw(distance_of_time_in_words(c[:created_at], Time.now).sub('about
215 ','~').sub(' ','&nbsp;')) if c[:created_at] %> ago
216             </small>
217           </td>
218         </tr>
219         <% end %>
220       </table>
221       <% end %>
222     </div>
223   </div>
224
225 <div class="span4">
226 <br/>
227
228 <% if @my_ssh_keys.count == 0%>
229   <div class="alert alert-info daxalert">
230     <button type="button" class="close" data-dismiss="alert">&times;</button>
231     <%= image_tag "dax.png", class: "dax" %>
232     <div>
233       Hi, I noticed that you have not yet set up an SSH public key for use with Arvados.  
234       <%= link_to "Click here to learn about SSH keys in Arvados.",
235           "http://doc.arvados.org/user/getting_started/ssh-access.html", 
236           style: "font-weight: bold",
237           target: "_blank" %>
238       When you have an SSH key you would like to use, paste the SSH public key
239       in the text box.
240     </div>
241       <%= form_for AuthorizedKey.new do |f| %>
242         <%= hidden_field_tag :return_to, request.original_url %>
243         <%= f.text_area :public_key, cols: 50, rows: 4, placeholder: "Paste your public key here", style: "width: 100%" %>
244         <%= f.submit :Save, value: raw("&check;"), class: "btn btn-primary pull-right" %>
245       <% end %>
246   </div>
247 <% end %>
248
249 <% if @my_collections.count == 0 %>
250 <div class="alert alert-info daxalert">
251   <button type="button" class="close" data-dismiss="alert">&times;</button>
252   <%= image_tag "dax.png", class: "dax" %>
253   <p>
254     Hi, I noticed you haven't uploaded a new collection yet. 
255     <%= link_to "Click here to learn how to upload data to Arvados Keep.", 
256         "http://doc.arvados.org/user/tutorials/tutorial-keep.html", 
257         style: "font-weight: bold", target: "_blank" %>
258   </p>
259 </div>
260
261 <% end %>
262
263 <% if @my_jobs.count == 0 %>
264 <div class="alert alert-info daxalert">
265   <button type="button" class="close" data-dismiss="alert">&times;</button>  
266   <p><%= image_tag "dax.png", class: "dax" %>
267     Hi, I noticed you haven't run a job yet. 
268     <%= link_to "Click here to learn how to run an Arvados Crunch job.", 
269         "http://doc.arvados.org/user/tutorials/tutorial-job1.html", 
270         style: "font-weight: bold",
271         target: "_blank" %>
272   </p>
273 </div>
274 <% end %>
275
276 <% if @my_pipelines.count == 0 %>
277 <div class="alert alert-info daxalert">
278   <button type="button" class="close" data-dismiss="alert">&times;</button>
279   <p><%= image_tag "dax.png", class: "dax" %>
280     Hi, I noticed you haven't run a pipeline yet.  
281     <%= link_to "Click here to learn how to run an Arvados Crunch pipeline.", 
282         "http://doc.arvados.org/user/tutorials/tutorial-new-pipeline.html", 
283         style: "font-weight: bold",
284         target: "_blank" %>
285   </p>
286 </div>
287 <% end %>
288
289 <div class="well">
290   <p><strong>Useful links</strong></p>
291   <p><ul>
292       <li><%= link_to "Arvados project page", "http://arvados.org", target: "_blank" %></li>
293       <li><%= link_to "Tutorials and user guide",
294       "http://doc.arvados.org/user/", target: "_blank" %></li>
295     </ul>
296   </p>
297 </div>
298
299 <div class="well">
300   <p><strong>System status</strong></p>
301     <table>
302       <% [Human, Trait, Collection, PipelineTemplate,
303           PipelineInstance].each do |aclass| %>
304         <tr>
305           <td>
306             <span style="margin-right: 2em">
307               <a href="/<%= raw(aclass.to_s.pluralize.underscore) %>">
308             <%= raw(aclass.to_s.pluralize.underscore.capitalize.gsub '_', '&nbsp;') %>
309             </a>
310             </span>
311             </td>
312           <td>
313         <% if aclass == 'File' %>
314           <%= Collection.limit(4000).where({}).collect(&:files).flatten(1).count %>
315         <% else %>
316           <%= aclass.limit(4000).where({}).count %>
317         <% end %>
318         </td>
319         </tr>
320       <% end %>
321       </table>
322 </div>
323
324 </div>
325 </div>
326
327 <% elsif current_user %>
328   <%= image_tag "dax.png", style: "float: left; max-width: 25%; margin-right: 2em" %>
329   <h1>Welcome to Arvados, <%= current_user.first_name %>!</h1>
330   <div class="row-fluid">
331     <div class="col span8">
332       <h4>Your account status</h4>
333       <div class="well clearfix">
334         <p><strong>New / inactive</strong></p>
335         <p>
336           Your account must be activated by an Arvados administrator.  If this
337           is your first time accessing Arvados and would like to request
338           access, or you believe you are seeing the page in error, please 
339           <%= link_to "contact us", Rails.configuration.activation_contact_link %>.  
340           You should receive an email at the address you used to log in when
341           your account is activated.  In the mean time, you can 
342           <%= link_to "learn more about Arvados", "https://arvados.org/projects/arvados/wiki/Introduction_to_Arvados" %>,
343           and <%= link_to "read the Arvados user guide", "http://doc.arvados.org/user" %>.
344         </p>
345         <p>
346           <%= link_to raw('Contact us &#x2709;'),
347               Rails.configuration.activation_contact_link, class: "pull-right btn btn-primary" %></p>
348       </div>
349     </div>
350   </div>
351 <% end %>