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