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