Merge branch 'master' into 3036-collection-uuids
[arvados.git] / apps / workbench / app / views / collections / _show_files.html.erb
1 <% file_tree = @object.andand.files_tree %>
2 <% if file_tree.nil? or file_tree.empty? %>
3   <p>This collection is empty.</p>
4 <% else %>
5   <ul id="collection_files" class="collection_files">
6   <% dirstack = [file_tree.first.first] %>
7   <% file_tree.each_with_index do |(dirname, filename, size), index| %>
8     <% file_path = CollectionsHelper::file_path([dirname, filename]) %>
9     <% while dirstack.any? and (dirstack.last != dirname) %>
10       <% dirstack.pop %></ul></li>
11     <% end %>
12     <li>
13     <% if size.nil?  # This is a subdirectory. %>
14       <% dirstack.push(File.join(dirname, filename)) %>
15       <div class="collection_files_row">
16        <div class="collection_files_name"><i class="fa fa-fw fa-folder-open"></i> <%= filename %></div>
17       </div>
18       <ul class="collection_files">
19     <% else %>
20       <% link_params = {controller: 'collections', action: 'show_file',
21                         uuid: @object.uuid, file: file_path, size: size} %>
22        <div class="collection_files_row">
23         <div class="collection_files_buttons pull-right">
24           <%= raw(human_readable_bytes_html(size)) %>
25           <% if !defined? no_checkboxes or !no_checkboxes %>
26           <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
27                 :class => 'persistent-selection',
28                 :friendly_type => "File",
29                 :friendly_name => "#{@object.uuid}/#{file_path}",
30                 :href => url_for(controller: 'collections', action: 'show_file',
31                                  uuid: @object.uuid, file: file_path),
32                 :title => "Include #{file_path} in your selections",
33               } %>
34           <% end %>
35           <%= link_to(raw('<i class="fa fa-search"></i>'),
36                       link_params.merge(disposition: 'inline'),
37                       {title: "View #{file_path}", class: "btn btn-info btn-sm"}) %>
38           <%= link_to(raw('<i class="fa fa-download"></i>'),
39                       link_params.merge(disposition: 'attachment'),
40                       {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %>
41         </div>
42       <% if CollectionsHelper::is_image(filename) %>
43         <div class="collection_files_name"><i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
44        </div>
45         <div class="collection_files_inline">
46           <%= link_to(image_tag("#{url_for @object}/#{file_path}"),
47                       link_params.merge(disposition: 'inline'),
48                       {title: file_path}) %>
49         </div>
50       <% else %>
51         <div class="collection_files_name"><i class="fa fa-fw fa-file"></i> <%= filename %></div>
52        </div>
53       <% end %>
54       </li>
55     <% end  # if file or directory %>
56   <% end  # file_tree.each %>
57   <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
58 <% end  # if file_tree %>
59
60 <% content_for :footer_html do %>
61 <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
62 <% end %>