Almost working sharing button.
[arvados.git] / apps / workbench / app / views / collections / _show_files.html.erb
1 <% content_for :css do %>
2 .file-list-inline-image {
3   width: 50%;
4   height: auto;
5 }
6 <% end %>
7
8 <% content_for :tab_line_buttons do %>
9 <div class="row">
10   <div class="col-md-6"></div>
11   <div class="col-md-6">
12     <div class="pull-right">
13       <% if @search_sharing.any? %>
14         <% linktext = "Shared" %>
15         <% btnstyle = "btn-success" %>
16       <% else %>
17         <% linktext = "Share" %>
18         <% btnstyle = "btn-info" %>
19       <% end %>
20       <%= link_to linktext, sharing_popup_collection_url(id: @object.uuid),  {class: "btn #{btnstyle}", :remote => true, 'data-toggle' =>  "modal", 'data-target' => '#collection-sharing-modal-window'}  %>
21       <span style="padding-left: 1em">Collection storage status:</span>
22       <%= render partial: 'toggle_persist', locals: { uuid: @object.uuid, current_state: (@is_persistent ? 'persistent' : 'cache') } %>
23
24     </div>
25   </div>
26 </div>
27 <% end %>
28
29 <table class="table table-condensed table-fixedlayout">
30   <colgroup>
31     <col width="4%" />
32     <col width="35%" />
33     <col width="40%" />
34     <col width="15%" />
35     <col width="10%" />
36   </colgroup>
37   <thead>
38     <tr>
39       <th></th>
40       <th>path</th>
41       <th>file</th>
42       <th style="text-align:right">size</th>
43       <th>d/l</th>
44     </tr>
45   </thead><tbody>
46     <% if @object then @object.files.sort_by{|f|[f[0],f[1]]}.each do |file| %>
47       <% file_path = CollectionsHelper::file_path file %>
48       <tr>
49         <td>
50           <%= check_box_tag 'uuids[]', @object.uuid+'/'+file_path, false, {
51                 :class => 'persistent-selection',
52                 :friendly_type => "File",
53                 :friendly_name => "#{@object.uuid}/#{file_path}",
54                 :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}",
55                 :title => "Click to add this item to your selection list"
56               } %>
57         </td>
58         <td>
59           <%= file[0] %>
60         </td>
61
62       <td>
63         <%= link_to (if CollectionsHelper::is_image file[1]
64                        image_tag "#{url_for @object}/#{file_path}", class: "file-list-inline-image"
65                      else
66                        file[1]
67                      end),
68             {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'},
69             {title: file_path} %>
70       </td>
71
72         <td style="text-align:right">
73           <%= raw(human_readable_bytes_html(file[2])) %>
74         </td>
75
76         <td>
77           <div style="display:inline-block">
78             <%= 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'} %>
79           </div>
80         </td>
81       </tr>
82     <% end; end %>
83   </tbody>
84 </table>
85
86 <% content_for :footer_html do %>
87 <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
88 <% end %>