[ARVADOS] updated: f9b83eddf1125d682bc5d94820f39cf23ee70b75
git at public.curoverse.com
git at public.curoverse.com
Thu Feb 20 15:00:23 EST 2014
Summary of changes:
.../app/controllers/related_objects_controller.rb | 37 +++----------------
.../views/related_objects/_index_tbody.html.erb | 35 ++----------------
.../views/related_objects/_show_recent.html.erb | 39 ++++++++------------
3 files changed, 24 insertions(+), 87 deletions(-)
via f9b83eddf1125d682bc5d94820f39cf23ee70b75 (commit)
from b5941421bd4bc93b54b2ba9fbd3316685a3f5b93 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit f9b83eddf1125d682bc5d94820f39cf23ee70b75
Author: Tim Pierce <twp at curoverse.com>
Date: Thu Feb 20 15:00:54 2014 -0500
Perform search on Collections, Groups, Humans, Specimens, Traits. (refs #2013)
diff --git a/apps/workbench/app/controllers/related_objects_controller.rb b/apps/workbench/app/controllers/related_objects_controller.rb
index 5e88874..870cb58 100644
--- a/apps/workbench/app/controllers/related_objects_controller.rb
+++ b/apps/workbench/app/controllers/related_objects_controller.rb
@@ -1,42 +1,15 @@
class RelatedObjectsController < ApplicationController
+
def model_class
Collection
end
+
def index
+ @related_objs = {}
if params[:q].andand.length.andand > 0
- tags = Link.where(any: ['contains', params[:q]])
- @collections = (Collection.where(uuid: tags.collect(&:head_uuid)) |
- Collection.where(any: ['contains', params[:q]])).
- uniq { |c| c.uuid }
- else
- @collections = Collection.limit(100)
- end
- @links = Link.limit(1000).
- where(head_uuid: @collections.collect(&:uuid))
- @collection_info = {}
- @collections.each do |c|
- @collection_info[c.uuid] = {
- tags: [],
- wanted: false,
- wanted_by_me: false,
- provenance: [],
- links: []
- }
- end
- @links.each do |link|
- @collection_info[link.head_uuid] ||= {}
- info = @collection_info[link.head_uuid]
- case link.link_class
- when 'tag'
- info[:tags] << link.name
- when 'resources'
- info[:wanted] = true
- info[:wanted_by_me] ||= link.tail_uuid == current_user.uuid
- when 'provenance'
- info[:provenance] << link.name
+ [Collection, Group, Human, Specimen, Trait].each do |obj|
+ @related_objs[obj.name] = obj.where(any: ['contains', params[:q]])
end
- info[:links] << link
end
- @request_url = request.url
end
end
diff --git a/apps/workbench/app/views/related_objects/_index_tbody.html.erb b/apps/workbench/app/views/related_objects/_index_tbody.html.erb
index 9252886..8a04522 100644
--- a/apps/workbench/app/views/related_objects/_index_tbody.html.erb
+++ b/apps/workbench/app/views/related_objects/_index_tbody.html.erb
@@ -1,39 +1,10 @@
-<% @collections.each do |c| %>
+<% related_objs.each do |obj| %>
<tr class="collection">
<td>
- <%= link_to_if_arvados_object c.uuid %>
- </td>
- <td>
- <% i = 0 %>
- <% while i < 3 and i < c.files.length %>
- <% file = c.files[i] %>
- <% file_path = "#{file[0]}/#{file[1]}" %>
- <%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: c.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %><br />
- <% i += 1 %>
- <% end %>
- <% if i < c.files.length %>
- ⋮
- <% end %>
- </td>
- <td><%= link_to_if_arvados_object c.owner_uuid, friendly_name: true %></td>
- <td>
- <%= raw(distance_of_time_in_words(c.created_at, Time.now).sub('about ','~').sub(' ',' ')) if c.created_at %>
- </td>
- <td>
- <% if @collection_info[c.uuid] %>
- <%= @collection_info[c.uuid][:tags].uniq.join ', ' %>
- <% end %>
- </td>
- <td>
- <% if @collection_info[c.uuid][:wanted_by_me] %>
- <span class="label label-info">2×</span>
- <% elsif @collection_info[c.uuid][:wanted] %>
- <span class="label">2×</span>
- <% else %>
- <span class="label">cache</span>
- <% end %>
+ <%= link_to_if_arvados_object obj.uuid %>
</td>
+ <td><%= link_to_if_arvados_object obj.owner_uuid, friendly_name: true %></td>
</tr>
<% end %>
diff --git a/apps/workbench/app/views/related_objects/_show_recent.html.erb b/apps/workbench/app/views/related_objects/_show_recent.html.erb
index 71b762a..f0ae9b3 100644
--- a/apps/workbench/app/views/related_objects/_show_recent.html.erb
+++ b/apps/workbench/app/views/related_objects/_show_recent.html.erb
@@ -15,29 +15,22 @@
<div style="padding-right: 1em">
-<table id="collections-index" class="topalign table table-condensed table-fixedlayout">
- <colgroup>
- <col width="10%" />
- <col width="36%" />
- <col width="22%" />
- <col width="8%" />
- <col width="16%" />
- <col width="8%" />
- </colgroup>
- <thead>
- <tr class="contain-align-left">
- <th>uuid</th>
- <th>contents</th>
- <th>owner</th>
- <th>age</th>
- <th>tags</th>
- <th>storage</th>
- </tr>
- </thead>
- <tbody>
- <%= render partial: 'index_tbody' %>
- </tbody>
-</table>
+<% @related_objs.each do |obj_class, related_objs| %>
+ <h1><%= obj_class.pluralize %></h1>
+ <table id="collections-index" class="topalign table table-condensed table-fixedlayout">
+ <thead>
+ <tr class="contain-align-left">
+ <th>uuid</th>
+ <th>owner</th>
+ </tr>
+ </thead>
+ <tbody>
+ <%= render partial: 'index_tbody',
+ locals: {related_objs: related_objs} %>
+ </tbody>
+ </table>
+<% end %>
+
</div>
<% content_for :js do %>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list