[ARVADOS] created: 59807e4ab334f7aec9772bf63f186974fba96821
git at public.curoverse.com
git at public.curoverse.com
Mon Oct 20 10:45:17 EDT 2014
at 59807e4ab334f7aec9772bf63f186974fba96821 (commit)
commit 59807e4ab334f7aec9772bf63f186974fba96821
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Oct 20 10:45:10 2014 -0400
4058: If a portable data hash correpsonds to a single collection, automatically
redirect to the collection page. If not, show a special "menu" page listing
the matching collections.
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 3c6c9d7..263f67f 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -195,51 +195,63 @@ class CollectionsController < ApplicationController
end
end
+ def find_object_by_uuid
+ if not Keep::Locator.parse params[:id]
+ super
+ end
+ end
+
def show
return super if !@object
if current_user
- jobs_with = lambda do |conds|
- Job.limit(RELATION_LIMIT).where(conds)
- .results.sort_by { |j| j.finished_at || j.created_at }
- end
- @output_of = jobs_with.call(output: @object.portable_data_hash)
- @log_of = jobs_with.call(log: @object.portable_data_hash)
- @project_links = Link.limit(RELATION_LIMIT).order("modified_at DESC")
- .where(head_uuid: @object.uuid, link_class: 'name').results
- project_hash = Group.where(uuid: @project_links.map(&:tail_uuid)).to_hash
- @projects = project_hash.values
-
- if @object.uuid.match /[0-9a-f]{32}/
+ if Keep::Locator.parse params["uuid"]
@same_pdh = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]])
- owners = @same_pdh.map {|s| s.owner_uuid}.to_a
+ 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
+ else
+ jobs_with = lambda do |conds|
+ Job.limit(RELATION_LIMIT).where(conds)
+ .results.sort_by { |j| j.finished_at || j.created_at }
+ end
+ @output_of = jobs_with.call(output: @object.portable_data_hash)
+ @log_of = jobs_with.call(log: @object.portable_data_hash)
+ @project_links = Link.limit(RELATION_LIMIT).order("modified_at DESC")
+ .where(head_uuid: @object.uuid, link_class: 'name').results
+ project_hash = Group.where(uuid: @project_links.map(&:tail_uuid)).to_hash
+ @projects = project_hash.values
+
+ @permissions = Link.limit(RELATION_LIMIT).order("modified_at DESC")
+ .where(head_uuid: @object.uuid, link_class: 'permission',
+ name: 'can_read').results
+ @logs = Log.limit(RELATION_LIMIT).order("created_at DESC")
+ .where(object_uuid: @object.uuid).results
+ @is_persistent = Link.limit(1)
+ .where(head_uuid: @object.uuid, tail_uuid: current_user.uuid,
+ link_class: 'resources', name: 'wants')
+ .results.any?
+ @search_sharing = search_scopes
+
+ if params["tab_pane"] == "Provenance_graph"
+ @prov_svg = ProvenanceHelper::create_provenance_graph(@object.provenance, "provenance_svg",
+ {:request => request,
+ :direction => :bottom_up,
+ :combine_jobs => :script_only}) rescue nil
+ end
+ if params["tab_pane"] == "Used_by"
+ @used_by_svg = ProvenanceHelper::create_provenance_graph(@object.used_by, "used_by_svg",
+ {:request => request,
+ :direction => :top_down,
+ :combine_jobs => :script_only,
+ :pdata_only => true}) rescue nil
+ end
end
-
- @permissions = Link.limit(RELATION_LIMIT).order("modified_at DESC")
- .where(head_uuid: @object.uuid, link_class: 'permission',
- name: 'can_read').results
- @logs = Log.limit(RELATION_LIMIT).order("created_at DESC")
- .where(object_uuid: @object.uuid).results
- @is_persistent = Link.limit(1)
- .where(head_uuid: @object.uuid, tail_uuid: current_user.uuid,
- link_class: 'resources', name: 'wants')
- .results.any?
- @search_sharing = search_scopes
- end
-
- if params["tab_pane"] == "Provenance_graph"
- @prov_svg = ProvenanceHelper::create_provenance_graph(@object.provenance, "provenance_svg",
- {:request => request,
- :direction => :bottom_up,
- :combine_jobs => :script_only}) rescue nil
- end
- if params["tab_pane"] == "Used_by"
- @used_by_svg = ProvenanceHelper::create_provenance_graph(@object.used_by, "used_by_svg",
- {:request => request,
- :direction => :top_down,
- :combine_jobs => :script_only,
- :pdata_only => true}) rescue nil
end
super
end
diff --git a/apps/workbench/app/views/collections/hash_matches.html.erb b/apps/workbench/app/views/collections/hash_matches.html.erb
new file mode 100644
index 0000000..1975d31
--- /dev/null
+++ b/apps/workbench/app/views/collections/hash_matches.html.erb
@@ -0,0 +1,23 @@
+<h1>Collection <%= params["uuid"] %></h1>
+<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">The following collection have this content:</h3>
+ </div>
+ <div class="panel-body">
+ <% @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 e1b0829..c3e0b7c 100644
--- a/apps/workbench/app/views/collections/show.html.erb
+++ b/apps/workbench/app/views/collections/show.html.erb
@@ -19,17 +19,9 @@
<%= render_editable_attribute @object, 'description', nil, { 'data-emptytext' => "(No description provided)", 'data-toggle' => 'manual' } %>
</div>
<img src="/favicon.ico" class="pull-right" alt="" style="opacity: 0.3"/>
- <% if defined? @same_pdh %>
- <p>Found in collections:<p>
- <p>
- <% @same_pdh.each do |c| %>
- <%= link_to_if_arvados_object get_object(c.owner_uuid), {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %><br>
- <% end %>
- </p>
- <% else %>
- <p><i>Content hash:</i><br />
- <span class="arvados-uuid"><%= link_to @object.portable_data_hash, collection_path(@object.portable_data_hash) %></span></p>
- <% end %>
+ <p><i>Content hash:</i><br />
+ <span class="arvados-uuid"><%= link_to @object.portable_data_hash, collection_path(@object.portable_data_hash) %></span>
+ </p>
<%= render partial: "show_source_summary" %>
</div>
</div>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list