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