13200: remove git tag from gittaggers
[arvados.git] / apps / workbench / app / views / collections / _show_files.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <%
6   preview_selectable_container = ''
7   preview_selectable = ''
8   padding_left = '1em'
9   if !params['use_preview_selection'].nil? and params['use_preview_selection'] == 'true'
10     preview_selectable_container = 'preview-selectable-container selectable-container'
11     preview_selectable = 'preview-selectable selectable'
12     padding_left = '0em'
13   end
14 %>
15
16 <% object = @object unless object %>
17
18 <div class="selection-action-container" style="padding-left: <%=padding_left%>">
19   <% if Collection.creatable? and (!defined? no_checkboxes or !no_checkboxes) %>
20     <div class="row">
21       <div class="pull-left">
22         <div class="btn-group btn-group-sm">
23           <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Selection... <span class="caret"></span></button>
24           <ul class="dropdown-menu" role="menu">
25             <li><%= link_to "Create new collection with selected files", '#',
26                     method: :post,
27                     'data-href' => combine_selected_path(
28                       action_data: {current_project_uuid: object.owner_uuid}.to_json
29                     ),
30                     'data-selection-param-name' => 'selection[]',
31                     'data-selection-action' => 'combine-collections',
32                     'data-toggle' => 'dropdown'
33               %></li>
34             <% if object.editable? %>
35             <li><%= link_to "Remove selected files", '#',
36                     method: :post,
37                     'data-href' => url_for(controller: 'collections', action: :remove_selected_files),
38                     'data-selection-param-name' => 'selection[]',
39                     'data-selection-action' => 'remove-selected-files',
40                     'data-toggle' => 'dropdown',
41                     'class' => 'btn-remove-selected-files'
42               %></li>
43             <% end %>
44           </ul>
45         </div>
46         <div class="btn-group btn-group-sm">
47           <button id="select-all" type="button" class="btn btn-default" onClick="select_all_items()">Select all</button>
48           <button id="unselect-all" type="button" class="btn btn-default" onClick="unselect_all_items()">Unselect all</button>
49         </div>
50       </div>
51       <div class="pull-right">
52         <input class="form-control filterable-control" data-filterable-target="ul#collection_files" id="file_regex" name="file_regex" placeholder="filename regex" type="text"/>
53       </div>
54     </div>
55     <p/>
56   <% end %>
57
58   <% file_tree = object.andand.files_tree %>
59   <% if file_tree.nil? or file_tree.empty? %>
60     <p>This collection is empty.</p>
61   <% else %>
62     <ul id="collection_files" class="collection_files arv-selectable-items <%=preview_selectable_container%>">
63     <% dirstack = [file_tree.first.first] %>
64     <% file_tree.take(10000).each_with_index do |(dirname, filename, size), index| %>
65       <% file_path = CollectionsHelper::file_path([dirname, filename]) %>
66       <% while dirstack.any? and (dirstack.last != dirname) %>
67         <% dirstack.pop %></ul></li>
68       <% end %>
69       <li>
70       <% if size.nil?  # This is a subdirectory. %>
71         <% dirstack.push(File.join(dirname, filename)) %>
72         <div class="collection_files_row">
73          <div class="collection_files_name"><i class="fa fa-fw fa-folder-open"></i> <%= filename %></div>
74         </div>
75         <ul class="collection_files">
76       <% else %>
77         <% link_params = {controller: 'collections', action: 'show_file',
78                           uuid: object.portable_data_hash, file: file_path, size: size} %>
79          <div class="collection_files_row filterable <%=preview_selectable%>" href="<%=object.uuid%>/<%=file_path%>">
80           <div class="collection_files_buttons pull-right">
81             <%= raw(human_readable_bytes_html(size)) %>
82             <%= link_to(raw('<i class="fa fa-search"></i>'),
83                         link_params.merge(disposition: 'inline'),
84                         {title: "View #{file_path}", class: "btn btn-info btn-sm", disabled: !preview_allowed_for(file_path)}) %>
85             <%= link_to(raw('<i class="fa fa-download"></i>'),
86                         link_params.merge(disposition: 'attachment'),
87                         {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %>
88           </div>
89
90           <div class="collection_files_name">
91             <% if (!defined? no_checkboxes or !no_checkboxes) and current_user %>
92             <%= check_box_tag 'uuids[]', "#{object.uuid}/#{file_path}", false, {
93                   :class => "persistent-selection",
94                   :friendly_type => "File",
95                   :friendly_name => "#{object.uuid}/#{file_path}",
96                   :href => url_for(controller: 'collections', action: 'show_file',
97                                    uuid: object.portable_data_hash, file: file_path),
98                   :title => "Include #{file_path} in your selections",
99                   :id => "#{object.uuid}_file_#{index}",
100                 } %>
101             <span>&nbsp;</span>
102             <% end %>
103
104             <% if object.editable? %>
105                 <span class="btn-collection-remove-file-span">
106                 <%= link_to({controller: 'collections', action: 'remove_selected_files', id: object.uuid, selection: [object.portable_data_hash+'/'+file_path]}, method: :post, remote: true, data: {confirm: "Remove #{file_path}?", toggle: 'tooltip', placement: 'top'}, class: 'btn btn-sm btn-default btn-nodecorate btn-collection-file-control', title: 'Remove this file') do %>
107                   <i class="fa fa-fw fa-trash-o"></i>
108                 <% end %>
109                 </span>
110             <% end %>
111         <% if CollectionsHelper::is_image(filename) %>
112             <i class="fa fa-fw fa-bar-chart-o"></i>
113               <% if object.editable? %>
114                 <span class="btn-collection-rename-file-span">
115                 <%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_name' => 'rename-file-path:'+file_path}, {tiptitle: 'Edit name or directory or both for this file', btnclass: 'collection-file-control'} %>
116                 </span>
117               <% else %>
118                 <%= filename %>
119               <% end %>
120             </div>
121           <div class="collection_files_inline">
122             <%= link_to(image_tag("#{url_for object}/#{file_path}"),
123                         link_params.merge(disposition: 'inline'),
124                         {title: file_path}) %>
125           </div>
126          </div>
127         <% else %>
128               <% if object.editable? %>
129                 <i class="fa fa-fw fa-file"></i><span class="btn-collection-rename-file-span"><%= render_editable_attribute object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_name' => 'rename-file-path:'+file_path}, {tiptitle: 'Edit name or directory or both for this file', btnclass: 'collection-file-control'}  %>
130                 </span>
131               <% else %>
132                 <i class="fa fa-fw fa-file" href="<%=object.uuid%>/<%=file_path%>" ></i> <%= filename %>
133               <% end %>
134             </div>
135          </div>
136         <% end %>
137         </li>
138       <% end  # if file or directory %>
139     <% end  # file_tree.each %>
140     <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
141   <% end  # if file_tree %>
142 </div>
143
144 <% content_for :footer_html do %>
145 <div id="collection-sharing-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
146 <% end %>