Dashboard now consists of recent collections, jobs, and pipeline instances.
[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: 5%;
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
43 <% if @my_ssh_keys.count == 0%>
44   <div class="alert alert-info daxalert">
45     <button type="button" class="close" data-dismiss="alert">&times;</button>
46     <%= image_tag "dax.png", class: "dax" %>
47     <div class="span5" style="margin-right: 1em">
48       Hi, I noticed that you have not yet set up an SSH public key for use with Arvados.  
49       <%= link_to "Click here to learn about SSH keys in Arvados.",
50           "http://doc.arvados.org/user/getting_started/ssh-access.html", style: "font-weight: bold" %>
51       Once have an SSH key you would like to use, paste your SSH public key
52       in the text box.
53     </div>
54       <%= form_for AuthorizedKey.new do |f| %>
55         <%= hidden_field_tag :return_to, request.original_url %>
56         <%= f.text_area :public_key, cols: 50, rows: 4, placeholder: "Paste your public key here", style: "width: 40%" %>
57         <%= f.submit :Save, value: raw("&check;"), class: "btn btn-primary", style: "vertical-align: top" %>
58       <% end %>
59   </div>
60 <% end %>
61
62 <% if Collection.limit(1).where(created_by: current_user.uuid).count == 0 %>
63 <div class="alert alert-info daxalert">
64   <button type="button" class="close" data-dismiss="alert">&times;</button>
65   <%= image_tag "dax.png", class: "dax" %>
66   <p>
67     Hi, I noticed you haven't uploaded a new collection yet. 
68     <%= link_to "Click here to learn how to upload data to Arvados Keep.", "http://doc.arvados.org/user/tutorials/tutorial-keep.html", style: "font-weight: bold" %>
69   </p>
70 </div>
71
72 <% end %>
73
74 <% if Job.limit(1).where(created_by: current_user.uuid).count == 0 %>
75 <div class="alert alert-info daxalert">
76   <button type="button" class="close" data-dismiss="alert">&times;</button>  
77   <p><%= image_tag "dax.png", class: "dax" %>
78     Hi, I noticed you haven't run a job yet. 
79     <%= link_to "Click here to learn how to run an Arvados Crunch job.", "http://doc.arvados.org/user/tutorials/tutorial-job1.html", style: "font-weight: bold" %>
80   </p>
81 </div>
82 <% end %>
83
84 <% if PipelineInstance.limit(1).where(created_by: current_user.uuid).count == 0 %>
85 <div class="alert alert-info daxalert">
86   <button type="button" class="close" data-dismiss="alert">&times;</button>
87   <p><%= image_tag "dax.png", class: "dax" %>
88     Hi, I noticed you haven't run a pipeline yet.  
89     <%= link_to "Click here to learn how to run an Arvados Crunch pipeline.", "http://doc.arvados.org/user/tutorials/tutorial-new-pipeline.html", style: "font-weight: bold" %>
90   </p>
91 </div>
92 <% end %>
93
94 <div class="row-fluid">
95
96   <div class="col span4">
97     <div class="clearfix">
98       <h4>Recent collections</h4>
99       <% if not current_user.andand.is_active or @my_collections.empty? %>
100       (None)
101       <% else %>
102       <table class="table table-bordered table-condensed job-table">
103         <colgroup>
104           <col width="70%" />
105           <col width="30%" />
106         </colgroup>
107         <% @my_collections[0..8].each do |c| %>
108         <tr>
109           <td>
110             <small>
111               <%= link_to c.uuid[0..31], collection_path(c.uuid) %> 
112             </small>
113           </td>
114           <td>
115             <small>
116 <%= raw(distance_of_time_in_words(c[:created_at], Time.now).sub('about
117 ','~').sub(' ','&nbsp;')) if c[:created_at] %> ago
118             </small>
119           </td>
120         </tr>
121         <% end %>
122       </table>
123       <%= link_to raw("Show all collections &rarr;"), collections_path, class: 'pull-right' %>
124       <% end %>
125     </div>
126   </div>
127
128   <div class="col span4">
129     <div class="clearfix">
130       <h4>Recent jobs</h4>
131       <% if not current_user.andand.is_active or @my_jobs.empty? %>
132       (None)
133       <% else %>
134       <table class="table table-bordered table-condensed job-table">
135         <colgroup>
136           <col width="40%" />
137           <col width="20%" />
138           <col width="40%" />
139         </colgroup>
140
141         <% @my_jobs[0..8].each do |j| %>
142         <tr>
143           <td>
144             <small>
145               <%= link_to j.script[0..31], job_path(j.uuid) %>
146             </small>
147           </td>
148           <td>
149             <% if j.success %>
150             <span class="label label-success">finished</span>
151             <% elsif j.success == false %>
152             <span class="label label-danger">failed</span>
153             <% elsif j.running and j.started_at and not j.finished_at %>
154             <% percent_total_tasks = 100 / (j.tasks_summary[:running] + j.tasks_summary[:done] + j.tasks_summary[:todo]) rescue 0 %>
155             <div class="progress" style="margin-bottom: 0">
156               <div class="bar bar-success" style="width: <%= j.tasks_summary[:done] * percent_total_tasks rescue 0 %>%;"></div>
157               <div class="bar" style="width: <%= j.tasks_summary[:running] * percent_total_tasks rescue 0 %>%; opacity: 0.3"></div>
158             </div>
159             <% else %>
160             <span class="label">queued</span>
161             <% end %>
162           </td>
163           <td>
164             <small>
165             <% if j.success %>
166             <%= link_to j.output[0..31], collection_path(j.output) %>  
167             <% end %>
168             </small>
169           </td>
170         </tr>
171         <% end %>
172       </table>
173       <%= link_to raw("Show all jobs &rarr;"), jobs_path, class: 'pull-right' %>
174       <% end %>
175     </div>
176   </div>
177
178   <div class="col span4">
179     <div class="clearfix">
180       <h4>Recent pipeline instances</h4>
181       <% if not current_user.andand.is_active or @my_pipelines.empty? %>
182       (None)
183       <% else %>
184       <table class="table table-bordered table-condensed job-table">
185         <colgroup>
186           <col width="80%" />
187           <col width="20%" />
188         </colgroup>
189
190         <% @my_pipelines[0..8].each do |p| %>
191         <tr>
192           <td>
193             <small>
194               <% i = PipelineTemplate.limit(1).where(uuid: p.pipeline_template_uuid)[0] %>
195                 <%= link_to i.name, pipeline_instance_path(p.uuid) %>
196             </small>
197           </td>
198           <td>
199             <% if p.success %>
200             <span class="label label-success">finished</span>
201             <% elsif p.success == false %>
202             <span class="label label-danger">failed</span>
203             <% elsif p.active %>
204             <span class="label label-info">running</span>
205             <% else %>
206             <span class="label">queued</span>
207             <% end %>
208           </td>
209         </tr>
210         <% end %>
211       </table>
212       <%= link_to raw("Show all pipeline instances &rarr;"), jobs_path, class: 'pull-right' %>
213       <% end %>
214     </div>
215   </div>
216
217
218 </div>
219
220 <% elsif current_user %>
221   <%= image_tag "dax.png", style: "float: left; max-width: 25%; margin-right: 2em" %>
222   <h1>Welcome to Arvados, <%= current_user.first_name %>!</h1>
223   <div class="row-fluid">
224     <div class="col span8">
225       <h4>Your account status</h4>
226       <div class="well clearfix">
227         <p><strong>New / inactive</strong></p>
228         <p>
229           Your account must be activated by an Arvados administrator.  If this
230           is your first time accessing Arvados and would like to request
231           access, or you believe you are seeing the page in error, please 
232           <%= link_to "contact us", Rails.configuration.activation_contact_link %>.  
233           You should receive an email at the address you used to log in when
234           your account is activated.  In the mean time, you can 
235           <%= link_to "learn more about Arvados", "https://arvados.org/projects/arvados/wiki/Introduction_to_Arvados" %>,
236           and <%= link_to "read the Arvados user guide", "http://doc.arvados.org/user" %>.
237         </p>
238         <p>
239           <%= link_to raw('Contact us &#x2709;'),
240               Rails.configuration.activation_contact_link, class: "pull-right btn btn-primary" %></p>
241       </div>
242     </div>
243   </div>
244 <% end %>