[ARVADOS] created: 0260d6ee3a9135550e6ab7b04b85d2c79dd56c9a
git at public.curoverse.com
git at public.curoverse.com
Sat Apr 25 21:56:11 EDT 2015
at 0260d6ee3a9135550e6ab7b04b85d2c79dd56c9a (commit)
commit 0260d6ee3a9135550e6ab7b04b85d2c79dd56c9a
Author: Radhika Chippada <radhika at curoverse.com>
Date: Sat Apr 25 21:54:41 2015 -0400
5622: add paging to hash matches display page.
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 8d25e68..b1e5014 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -18,9 +18,10 @@ class CollectionsController < ApplicationController
RELATION_LIMIT = 5
def show_pane_list
- panes = %w(Files Upload Provenance_graph Used_by Advanced)
- panes = panes - %w(Upload) unless (@object.editable? rescue false)
- panes
+ return @panes if @panes.andand.any?
+ @panes = %w(Files Upload Provenance_graph Used_by Advanced)
+ @panes = @panes - %w(Upload) unless (@object.editable? rescue false)
+ @panes
end
def set_persistent
@@ -189,6 +190,35 @@ class CollectionsController < ApplicationController
@logs = []
+ # Hash_matches page
+ if params[:partial].andand.eql?('contents_rows')
+ @limit = 50
+ find_objects_for_index
+
+ owners = @objects.map(&:owner_uuid).to_a.uniq
+ preload_objects_for_dataclass Group, owners
+ preload_objects_for_dataclass User, owners
+ uuids = @objects.map(&:uuid).to_a.uniq
+ preload_links_for_objects uuids
+
+ @next_page_href = next_page_href(partial: :contents_rows,
+ filters: @filters.to_json,
+ offset: @offset,
+ order: @order.to_json)
+
+ respond_to do |f|
+ f.json {
+ render json: {
+ content: render_to_string(partial: 'show_contents_rows.html',
+ formats: [:html]),
+ next_page_href: @next_page_href
+ }
+ }
+ end
+ return
+ end
+
+ # Collection show
if params["tab_pane"] == "Provenance_graph"
@prov_svg = ProvenanceHelper::create_provenance_graph(@object.provenance, "provenance_svg",
{:request => request,
@@ -198,16 +228,17 @@ class CollectionsController < ApplicationController
if current_user
if Keep::Locator.parse params["uuid"]
+ @limit = 2
@same_pdh = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]])
+
+ # If there is only uuid matching this pdh, show it
if @same_pdh.results.size == 1
redirect_to collection_path(@same_pdh[0]["uuid"])
return
end
- owners = @same_pdh.map(&:owner_uuid).to_a.uniq
- preload_objects_for_dataclass Group, owners
- preload_objects_for_dataclass User, owners
- render 'hash_matches'
- return
+
+ # This pdh has more than one uuid matching. Show the hash matches page listing those uuids.
+ @panes = %w(Hash_matches)
else
jobs_with = lambda do |conds|
Job.limit(RELATION_LIMIT).where(conds)
@@ -241,6 +272,7 @@ class CollectionsController < ApplicationController
end
end
end
+
super
end
diff --git a/apps/workbench/app/views/application/_title_and_buttons.html.erb b/apps/workbench/app/views/application/_title_and_buttons.html.erb
index 398f248..268bafd 100644
--- a/apps/workbench/app/views/application/_title_and_buttons.html.erb
+++ b/apps/workbench/app/views/application/_title_and_buttons.html.erb
@@ -11,7 +11,10 @@
<% end %>
<% end %>
-<% if @object.class.goes_in_projects? && @object.uuid != current_user.andand.uuid # Not the "Home" project %>
+<% if @object.class.goes_in_projects? &&
+ @object.uuid != current_user.andand.uuid && # Not the "Home" project
+ !CollectionsHelper.match(@object.uuid) # not collection pdh
+%>
<% content_for :tab_line_buttons do %>
<% if current_user.andand.is_active && @object.class.copies_to_projects? %>
<%= link_to(
diff --git a/apps/workbench/app/views/collections/_show_contents_rows.html.erb b/apps/workbench/app/views/collections/_show_contents_rows.html.erb
new file mode 100644
index 0000000..3a0b660
--- /dev/null
+++ b/apps/workbench/app/views/collections/_show_contents_rows.html.erb
@@ -0,0 +1,14 @@
+<%# Currently this partial is used to display hash matches. %>
+
+<% @objects.sort { |a,b| b.created_at <=> a.created_at }.each do |c| %>
+ <div class="row">
+ <div class="col-md-8">
+ <% owner = object_for_dataclass(Group, c.owner_uuid) || object_for_dataclass(User, c.owner_uuid) %>
+ <%= link_to_if_arvados_object owner, {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %><br>
+ </div>
+ <div class="col-md-4">
+ <%= render_localized_date c.created_at %>
+ </div>
+ </div>
+<% end %>
+
diff --git a/apps/workbench/app/views/collections/_show_hash_matches.html.erb b/apps/workbench/app/views/collections/_show_hash_matches.html.erb
new file mode 100644
index 0000000..4010dd3
--- /dev/null
+++ b/apps/workbench/app/views/collections/_show_hash_matches.html.erb
@@ -0,0 +1,3 @@
+<%= render_pane 'tab_contents', to_string: true, locals: {
+ filters: [["portable_data_hash", "=", @object.portable_data_hash]]
+ }.merge(local_assigns) %>
diff --git a/apps/workbench/app/views/collections/_show_tab_contents.html.erb b/apps/workbench/app/views/collections/_show_tab_contents.html.erb
new file mode 100644
index 0000000..0ea71c6
--- /dev/null
+++ b/apps/workbench/app/views/collections/_show_tab_contents.html.erb
@@ -0,0 +1,8 @@
+<%# Currently this partial is used to display hash matches. %>
+
+<p><i>The following collections have the content from <%= params["uuid"]%> </i></p>
+
+<div class="arv-collection-<%= tab_pane %>">
+ <div data-infinite-scroller="#<%= tab_pane %>-scroll" data-infinite-content-href="<%= url_for partial: :contents_rows %>" data-infinite-content-params-collectiontab="<%= local_assigns.select{|k| [:order, :offset, :limit, :filters].include? k }.to_json %>" data-infinite-content-params-attr="collectiontab">
+ </div>
+</div>
diff --git a/apps/workbench/app/views/collections/hash_matches.html.erb b/apps/workbench/app/views/collections/hash_matches.html.erb
deleted file mode 100644
index 7c4abb0..0000000
--- a/apps/workbench/app/views/collections/hash_matches.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-<div class="row">
- <div class="col-md-10 col-md-offset-1">
- <div class="panel panel-info">
- <div class="panel-heading">
- <h3 class="panel-title"><%= params["uuid"] %></h3>
- </div>
- <div class="panel-body">
- <p><i>The following collections have this content:</i></p>
- <% @same_pdh.sort { |a,b| b.created_at <=> a.created_at }.each do |c| %>
- <div class="row">
- <div class="col-md-8">
- <% owner = object_for_dataclass(Group, c.owner_uuid) || object_for_dataclass(User, c.owner_uuid) %>
- <%= link_to_if_arvados_object owner, {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %><br>
- </div>
- <div class="col-md-4">
- <%= render_localized_date c.created_at %>
- </div>
- </div>
- <% end %>
- </div>
- </div>
- </div>
-</div>
diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb
index c6bad7d..74133df 100644
--- a/apps/workbench/app/views/collections/show.html.erb
+++ b/apps/workbench/app/views/collections/show.html.erb
@@ -1,3 +1,4 @@
+<% if !CollectionsHelper.match(params['uuid']) %> <%# not pdh %>
<div class="row row-fill-height">
<div class="col-md-6">
<div class="panel panel-info">
@@ -116,5 +117,6 @@
</div>
<% end %>
</div>
+<% end %>
<%= render file: 'application/show.html.erb', locals: local_assigns %>
diff --git a/apps/workbench/test/integration/collections_test.rb b/apps/workbench/test/integration/collections_test.rb
index 4a7014c..96e1d47 100644
--- a/apps/workbench/test/integration/collections_test.rb
+++ b/apps/workbench/test/integration/collections_test.rb
@@ -104,7 +104,7 @@ class CollectionsTest < ActionDispatch::IntegrationTest
Capybara.current_driver = :rack_test
uuid = 'd41d8cd98f00b204e9800998ecf8427e+0'
visit page_with_token('active', "/collections/#{uuid}")
- assert page.has_text?(/This collection is empty|The following collections have this content/)
+ assert page.has_text?(/This collection is empty|The following collections have the content/)
end
test "combine selected collections into new collection" do
@@ -212,7 +212,7 @@ class CollectionsTest < ActionDispatch::IntegrationTest
end
test "Collection portable data hash with multiple matches" do
- pdh = api_fixture('collections')['baz_file']['portable_data_hash']
+ pdh = api_fixture('collections')['foo_file']['portable_data_hash']
visit page_with_token('admin', "/collections/#{pdh}")
matches = api_fixture('collections').select {|k,v| v["portable_data_hash"] == pdh}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list