Show images in files inline.
[arvados.git] / apps / workbench / app / views / collections / _show_files.html.erb
1 <table class="table table-condensed table-fixedlayout">
2   <colgroup>
3     <col width="35%" />
4     <col width="40%" />
5     <col width="15%" />
6     <col width="10%" />
7   </colgroup>
8   <thead>
9     <tr>
10       <th>path</th>
11       <th>file</th>
12       <th style="text-align:right">size</th>
13       <th>d/l</th>
14     </tr>
15   </thead><tbody>
16     <% if @object then @object.files.sort_by{|f|[f[0],f[1]]}.each do |file| %>
17     <% file_path = "#{file[0]}/#{file[1]}" %>
18     <tr>
19       <td>
20         <%= file[0] %>
21       </td>
22
23       <td>
24         <%= link_to((if /\.(jpg|jpeg|gif|png)$/.match(file[1]) then
25                        image_tag "#{url_for @object}/#{file_path}"
26                      else
27                        file[1]
28                      end), 
29                     {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, 
30                     {title: 'View in browser'}) %>
31       </td>
32
33       <td style="text-align:right">
34         <%= raw(human_readable_bytes_html(file[2])) %>
35       </td>
36
37       <td>
38         <div style="display:inline-block">
39           <%= link_to raw('<i class="glyphicon glyphicon-download-alt"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'btn btn-info btn-sm', title: 'Download'} %>
40         </div>
41       </td>
42     </tr>
43     <% end; end %>
44   </tbody>
45 </table>