1 <%# Copyright (C) The Arvados Authors. All rights reserved.
3 SPDX-License-Identifier: AGPL-3.0 %>
6 preview_selectable_container = ''
7 preview_selectable = ''
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'
16 <% object = @object unless object %>
18 <div class="selection-action-container" style="padding-left: <%=padding_left%>">
19 <% if Collection.creatable? and (!defined? no_checkboxes or !no_checkboxes) %>
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", '#',
27 'data-href' => combine_selected_path(
28 action_data: {current_project_uuid: object.owner_uuid}.to_json
30 'data-selection-param-name' => 'selection[]',
31 'data-selection-action' => 'combine-collections',
32 'data-toggle' => 'dropdown'
34 <% if object.editable? %>
35 <li><%= link_to "Remove selected files", '#',
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'
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>
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"/>
58 <% file_tree = object.andand.files_tree %>
59 <% if file_tree.nil? or file_tree.empty? %>
60 <p>This collection is empty.</p>
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>
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>
75 <ul class="collection_files">
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"}) %>
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}",
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>
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'} %>
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}) %>
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'} %>
132 <i class="fa fa-fw fa-file" href="<%=object.uuid%>/<%=file_path%>" ></i> <%= filename %>
138 <% end # if file or directory %>
139 <% end # file_tree.each %>
140 <%= raw(dirstack.map { |_| "</ul>" }.join("</li>")) %>
141 <% end # if file_tree %>
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>