Merge branch 'master' of git.clinicalfuture.com:arvados
[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 raw("Show all jobs &rarr;"), jobs_path, class: 'pull-right' %>
5     <% if not current_user.andand.is_active or @my_jobs.empty? %>
6       <p>(None)</p>
7     <% else %>
8       <table class="table table-bordered table-condensed table-fixedlayout">
9         <colgroup>
10           <col width="28%" />
11           <col width="38%" />
12           <col width="7%" />
13           <col width="15%" />
14           <col width="12%" />
15         </colgroup>
16
17         <tr>
18           <th>Script</th>
19           <th>Output</th>
20           <th>Log</th>
21           <th>Age</th>
22           <th>Status</th>
23         </tr>
24
25         <% @my_jobs[0..6].each do |j| %>
26           <tr>
27             <td>
28               <small>
29                 <%= link_to j.script[0..31], job_path(j.uuid) %>
30               </small>
31             </td>
32
33             <td>
34               <small>
35                 <% if j.success %>
36
37                   <a href="<%= collection_path(j.output) %>">
38                     <% Collection.limit(1).where(uuid: j.output).each do |c| %>
39                          <% c.files.each do |file| %>
40                       <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
41                     <% end %>
42                 <% end %>
43                 </a>
44
45         <% end %>
46         </small>
47 </td>
48
49 <td>
50   <small>
51     <% if j.log %>
52       <% Collection.limit(1).where(uuid: j.log).each do |c| %>
53         <% c.files.each do |file| %>
54           <a href="<%= collection_path(j.log) %>/<%= file[1] %>?disposition=inline&size=<%= file[2] %>">Log</a>
55         <% end %>
56       <% end %>
57     <% end %>
58   </small>
59 </td>
60
61 <td>
62   <small>
63     <%= raw(distance_of_time_in_words(j.created_at, Time.now).sub('about
64 ','~').sub(' ','&nbsp;')) if j.created_at %>
65   </small>
66 </td>
67
68 <td>
69   <% if j.success %>
70     <span class="label label-success">finished</span>
71   <% elsif j.success == false %>
72     <span class="label label-danger">failed</span>
73   <% elsif j.running and j.started_at and not j.finished_at %>
74     <% percent_total_tasks = 100 / (j.tasks_summary[:running] + j.tasks_summary[:done] + j.tasks_summary[:todo]) rescue 0 %>
75     <div class="progress" style="margin-bottom: 0">
76       <div class="bar bar-success" style="width: <%= j.tasks_summary[:done] * percent_total_tasks rescue 0 %>%;"></div>
77       <div class="bar" style="width: <%= j.tasks_summary[:running] * percent_total_tasks rescue 0 %>%; opacity: 0.3"></div>
78     </div>
79   <% else %>
80     <span class="label">queued</span>
81   <% end %>
82 </td>
83
84 </tr>
85 <% end %>
86 </table>
87 <% end %>
88 </div>
89
90 <div>
91   <strong>Recent pipeline instances</strong>
92   <%= link_to raw("Show all pipeline instances &rarr;"), jobs_path, class: 'pull-right' %>
93   <% if not current_user.andand.is_active or @my_pipelines.empty? %>
94     <p>(None)</p>
95   <% else %>
96     <table class="table table-bordered table-condensed table-fixedlayout">
97       <colgroup>
98         <col width="73%" />
99         <col width="15%" />
100         <col width="12%" />
101       </colgroup>
102
103       <tr>
104         <th>Pipeline template</th>
105         <th>Age</th>
106         <th>Status</th>
107       </tr>
108
109       <% @my_pipelines[0..6].each do |p| %>
110         <tr>
111           <td>
112             <small>
113               <% PipelineTemplate.limit(1).where(uuid: p.pipeline_template_uuid).each do |i| %>
114                 <%= link_to i.name, pipeline_instance_path(p.uuid) %>
115               <% end %>
116             </small>
117           </td>
118
119           <td>
120             <small>
121               <%= raw(distance_of_time_in_words(p.created_at, Time.now).sub('about
122 ','~').sub(' ','&nbsp;')) if p.created_at %>
123             </small>
124           </td>
125
126           <td>
127             <% if p.success %>
128               <span class="label label-success">finished</span>
129             <% elsif p.success == false %>
130               <span class="label label-danger">failed</span>
131             <% elsif p.active %>
132               <span class="label label-info">running</span>
133             <% else %>
134               <span class="label">queued</span>
135             <% end %>
136           </td>
137
138         </tr>
139       <% end %>
140     </table>
141   <% end %>
142 </div>
143
144 <div>
145   <strong>Recent collections</strong>
146   <%= link_to raw("Show all collections &rarr;"), collections_path, class: 'pull-right' %>
147   <div class="pull-right" style="padding-right: 1em">
148     <%= form_tag collections_path,
149           method: 'get',
150           class: 'form-search small-form-margin' do %>
151     <div class="input-append">
152       <%= text_field_tag :search, params[:search], class: 'search-query search-mini' %>
153       <%= submit_tag "Search", name: nil, class: 'btn btn-mini btn-info' %>
154     </div>  
155     <% end %>
156   </div>
157   <% if not current_user.andand.is_active or @my_collections.empty? %>
158     <p>(None)</p>
159   <% else %>
160     <table class="table table-bordered table-condensed table-fixedlayout">
161       <colgroup>
162         <col width="46%" />
163         <col width="27%" />
164         <col width="27%" />
165       </colgroup>
166
167       <tr>
168         <th>Contents</th>
169         <th>Tags</th>
170         <th>Age</th>
171       </tr>
172
173       <% @my_collections[0..6].each do |c| %>
174         <tr>
175           <td>
176             <small>
177               <a href="<%= collection_path(c.uuid) %>">
178                 <% c.files.each do |file| %>
179                   <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
180                 <% end %>
181               </a>
182             </small>
183           </td>
184           <td>
185             <% if @my_tag_links[c.uuid] %>
186             <small>
187               <%= @my_tag_links[c.uuid].collect(&:name).join(", ") %>
188             </small>
189             <% end %>
190           </td>
191           <td>
192             <small>
193               <%= raw(distance_of_time_in_words(c.created_at, Time.now).sub('about
194 ','~').sub(' ','&nbsp;')) if c.created_at %>
195             </small>
196           </td>
197         </tr>
198       <% end %>
199     </table>
200   <% end %>
201 </div>
202
203 <% else %>
204   <%= image_tag "dax.png", style: "max-width=40%" %>
205 <% end %>