Skip to content

Commit

Permalink
Virtual Collection Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
MontrealSergiy committed Sep 16, 2024
1 parent eafabe2 commit a013bd6
Show file tree
Hide file tree
Showing 7 changed files with 525 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

<%-
#
# CBRAIN Project
#
# Copyright (C) 2008-2012
# The Royal Institution for the Advancement of Learning
# McGill University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-%>
why this is shows
<% limit = 500 %>
<% base_dir = base_directory rescue params[:base_directory] %>
<% base_dir = base_dir.presence || "." %>

<% file_list ||= ( @userfile.list_linked_files(base_dir, [:regular, :directory, :link]) rescue [] ) %>

<% if file_list.blank? %>

<tr class="<%= cycle("list-odd", "list-even") %>">
<td></td>
<td colspan="2"> (<span class="warning">Empty</span>) </td>
<td></td>
</tr>

<% else %>

<% for file in file_list[0,limit] %>
<% if file.symbolic_type == :directory %>
<%= on_click_ajax_replace( { :element => "tr",
:url => url_for(:action => :display,
:viewer => "directory_contents",
:viewer_userfile_class => "FileCollection",
:base_directory => file.name.sub(/\A[^\/]+\//, ""),
:apply_div => "false"
),
:position => "after",
:before => "<td colspan='4' class='loading_message'>Loading...</td>"
},
{ :class => "#{cycle("list-odd", "list-even")}",
:id => file.name.gsub(/\W+/, "_")
}
) do %>
<%= render :file => @viewer.partial_path(:plain_file_list_row), :locals => {:file => file} %>
<% end %>
<% else %>
<tr class="<%= cycle("list-odd", "list-even") %>">
<%= render :file => @viewer.partial_path(:plain_file_list_row), :locals => {:file => file} %>
</tr>
<% end %>
<% end %>

<% if file_list.size > limit %>
<tr class="<%= cycle("list-odd", "list-even") %>">
<td></td>
<td colspan="2" class="left"> <%= ("&nbsp;" * 6 * file_list.first.depth).html_safe %> ... <%= image_tag "/images/lotsa_files_icon.png" %> <%= pluralize(file_list.size-limit, "more entry") %></td>
<td></td>
</tr>
<% end %>

<% end %>

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

<%-
#
# CBRAIN Project
#
# Copyright (C) 2008-2012
# The Royal Institution for the Advancement of Learning
# McGill University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-%>

<%
# This partial can be invoked directly as a viewer from the display action,
# or rendered as part of another piece of view code. As such it will
# accept a "base_directory" either as a params[] or as a local variable
base_dir = base_directory rescue params[:base_directory]
%>

<%= render :file => VirtualFileCollection.view_path(:file_collection_form),
:locals => { :base_directory => base_dir } %>

<div id="sub_viewer_filecollection_cbrain"></div>

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= @userfile.list_linked_files.to_json %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

<%-
#
# CBRAIN Project
#
# Copyright (C) 2008-2012
# The Royal Institution for the Advancement of Learning
# McGill University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-%>

<%
# This partial requires one local variable:
#
# base_directory : the subdirectory inside the userfile where we start to render the directory content
%>
Debug Virtual File Collection Form 1
<% if true # @userfile.num_files && @userfile.num_files > 0 %>

<%= form_for @userfile, :as => :userfile,
:url => { :controller => :userfiles,
:action => :extract_from_collection
},
:html => { :method => :post,
:id => "userfile_edit_#{@userfile.id}_#{base_directory}"
} do |f| %>
<%= ajax_element(display_userfile_path(@userfile,
:viewer => :file_collection_top_table,
:viewer_userfile_class => :VirtualFileCollection,
:base_directory => base_directory,
), :class => "loading_message") do %>
<br>
Loading...
<br>
<% end %>

<% if @userfile.is_locally_synced? %>
<P>
<%= submit_tag "Extract Files from Virtual Collection" %>
<% end %>

<% end %>

<% end %>

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

<%-
#
# CBRAIN Project
#
# Copyright (C) 2008-2012
# The Royal Institution for the Advancement of Learning
# McGill University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-%>

<%
# This partial requires one params variable:
# params[:base_directory] : a relative path to the subdirectory inside the userfile; we will list from that point.
%>

<%
base_dir = params[:base_directory].presence || ""
%>
<table class="plain_file_list" class="resource_list">
<tr class="list-odd">
<th>
<% if @userfile.is_locally_synced? %>
<%= select_all_checkbox "collection_checkbox" %>
<% end %>
</th>
<th>File</th>
<th title="Download file">DL</th>
<th>Size</th>
</tr>
<%= render :file => VirtualFileCollection.view_path(:directory_contents),
:locals => { :base_directory => base_dir }
%>
</table>

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

<%-
#
# CBRAIN Project
#
# Copyright (C) 2008-2012
# The Royal Institution for the Advancement of Learning
# McGill University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-%>

<%
# This partial receives one local variable:
# file : a file structure as returned by the FileCollection listing method
# Note that is contains a full relative path, starting with the @userfile's name itself.
%>

<td>
<% if @userfile.is_locally_synced? && file.symbolic_type == :regular %>
<%= check_box_tag("file_names[]", file.name, false, :class => "collection_checkbox", :id => nil) %>
<% end %>
</td>

<td class="left">
<%= ("&nbsp;" * 6 * file.depth).html_safe %>

<div style="display: inline-flex">
<% if file.symbolic_type == :directory %>
<%= image_tag "/images/folder_icon_solid.png" %>
<% else %>
<%= image_tag "/images/file_icon.png" %>
<% end %>

&nbsp;

<% if file.size > 0 %>
<%= data_link file.name, @userfile %>
<% else %>
<%= Pathname.new(file.name).basename.to_s %>
<% end %>

<% if file.symbolic_type == :directory %>
&nbsp;
<span class="ajax_onclick_show_child small warning">Expand</span>
<span class="ajax_onclick_hide_child small warning" style="display:none">Hide</span>
<% end %>
</div>
</td>

<td>
<% if file.symbolic_type == :regular && file.size > 0 && file.size < UserfilesController::MAX_DOWNLOAD_MEGABYTES.megabytes %>
<%= link_to url_for(:action => :content, :content_loader => :collection_file, :arguments => file.name) do %>
<span title="Download file" id="span" class="ui-button-icon ui-icon ui-icon-arrowthickstop-1-s"></span>
<% end %>
<% end %>
</td>

<td>
<% if file.symbolic_type != :directory %>
<%= colored_pretty_size(file.size) %>
<% end %>
</td>
Loading

0 comments on commit a013bd6

Please sign in to comment.