Merge branch 'master' into 3654-combine-selections
[arvados.git] / apps / workbench / app / views / collections / _show_files.html.erb
1 <div class="selection-action-container" style="padding-left: 1em">
2   <div class="row">
3     <div class="pull-left">
4       <div class="btn-group btn-group-sm">
5         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection... <span class="caret"></span></button>
6         <ul class="dropdown-menu" role="menu">
7           <li><%= link_to "Combine selections into a new collection", '#',
8                   'data-href' => combine_selected_path,
9                   'data-selection-param-name' => 'selection[]',
10                   'data-selection-action' => 'combine-collections',
11                   'method' => 'post',
12                   'data-toggle' => 'dropdown'
13             %></li>
14         </ul>
15       </div>
16     </div>
17   </div>
18   <p/>
19
20 <% file_tree = @object.andand.files_tree %>
21 <% if file_tree.nil? or file_tree.empty? %>
22   <p>This collection is empty.</p>
23 <% else %>
24   <ul id="collection_files" class="collection_files">
25   <% dirstack = [file_tree.first.first] %>
26   <% file_tree.take(10000).each_with_index do |(dirname, filename, size), index| %>
27     <% file_path = CollectionsHelper::file_path([dirname, filename]) %>
28     <% while dirstack.any? and (dirstack.last != dirname) %>
29       <% dirstack.pop %></ul></li>
30     <% end %>
31     <li>
32     <% if size.nil?  # This is a subdirectory. %>
33       <% dirstack.push(File.join(dirname, filename)) %>
34       <div class="collection_files_row">
35        <div class="collection_files_name"><i class="fa fa-fw fa-folder-open"></i> <%= filename %></div>
36       </div>
37       <ul class="collection_files">
38     <% else %>
39       <% link_params = {controller: 'collections', action: 'show_file',
40                         uuid: @object.portable_data_hash, file: file_path, size: size} %>
41        <div class="collection_files_row">
42         <div class="collection_files_buttons pull-right">
43           <%= raw(human_readable_bytes_html(size)) %>
44           <% if !defined? no_checkboxes or !no_checkboxes %>
45           <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
46                 :class => 'persistent-selection',
47                 :friendly_type => "File",
48                 :friendly_name => "#{@object.uuid}/#{file_path}",
49                 :href => url_for(controller: 'collections', action: 'show_file',
50                                  uuid: @object.portable_data_hash, file: file_path),
51                 :title => "Include #{file_path} in your selections",
52               } %>
53           <% end %>
54
55           <% if Rails.configuration.filename_suffixes_with_view_icon.include? file_path.split('.')[-1] %>
56           <%= link_to(raw('<i class="fa fa-search"></i>'),
57                       link_params.merge(disposition: 'inline'),
58                       {title: "View #{file_path}", class: "btn btn-info btn-sm"}) %>
59           <% end %>
60
61           <%= link_to(raw('<i class="fa fa-download"></i>'),
62                       link_params.merge(disposition: 'attachment'),
63                       {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %>
64         </div>
65       <% if CollectionsHelper::is_image(filename) %>
66         <div class="collection_files_name"><i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
67        </div>
68         <div class="collection_files_inline">
69           <%= link_to(image_tag("#{url_for @object}/#{file_path}"),
70                       link_params.merge(disposition: 'inline'),
71                       {title: file_path}) %>
72         </div>
73       <% else %>
74         <div class="collection_files_name"><i class="fa fa-fw fa-file"></i> <%= filename %></div>
75        </div>
76       <% end %>
77       </li>
78     <% end  # if file or directory %>
79   <% end  # file_tree.each %>
80   <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
81 <% end  # if file_tree %>
82
83 <% content_for :footer_html do %>
84 <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
85 <% end %>
86
87 </div>