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