[ARVADOS] updated: 76811cf6dd17e5a3ef32753a96714eae3fa96976

git at public.curoverse.com git at public.curoverse.com
Mon Feb 17 10:25:19 EST 2014


Summary of changes:
 ...zations.js.coffee => related_objects.js.coffee} |    0
 .../assets/stylesheets/related_objects.css.scss    |    2 +-
 .../app/controllers/related_objects_controller.rb  |   42 ++++++++++++++++++++
 .../app/helpers/related_objects_helper.rb          |    2 +
 .../app/views/layouts/application.html.erb         |    9 +++-
 .../_index_tbody.html.erb                          |    0
 .../_show_recent.html.erb                          |    0
 apps/workbench/config/routes.rb                    |    1 +
 .../related_objects_controller_test.rb}            |    2 +-
 .../unit/helpers/related_objects_helper_test.rb    |    4 ++
 10 files changed, 58 insertions(+), 4 deletions(-)
 copy apps/workbench/app/assets/javascripts/{api_client_authorizations.js.coffee => related_objects.js.coffee} (100%)
 copy services/api/app/assets/stylesheets/authorized_keys.css.scss => apps/workbench/app/assets/stylesheets/related_objects.css.scss (65%)
 create mode 100644 apps/workbench/app/controllers/related_objects_controller.rb
 create mode 100644 apps/workbench/app/helpers/related_objects_helper.rb
 copy apps/workbench/app/views/{collections => related_objects}/_index_tbody.html.erb (100%)
 copy apps/workbench/app/views/{collections => related_objects}/_show_recent.html.erb (100%)
 copy apps/workbench/test/{unit/api_client_authorization_test.rb => functional/related_objects_controller_test.rb} (54%)
 create mode 100644 apps/workbench/test/unit/helpers/related_objects_helper_test.rb

       via  76811cf6dd17e5a3ef32753a96714eae3fa96976 (commit)
      from  df517246e5f147dc944c0c1426a6df82ba65ba4e (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 76811cf6dd17e5a3ef32753a96714eae3fa96976
Author: Tim Pierce <twp at curoverse.com>
Date:   Mon Feb 17 10:24:27 2014 -0500

    Added 'related_objects' controller to handle search requests. Currently searches only collections. (refs #2013)

diff --git a/apps/workbench/app/assets/javascripts/related_objects.js.coffee b/apps/workbench/app/assets/javascripts/related_objects.js.coffee
new file mode 100644
index 0000000..7615679
--- /dev/null
+++ b/apps/workbench/app/assets/javascripts/related_objects.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/apps/workbench/app/assets/stylesheets/related_objects.css.scss b/apps/workbench/app/assets/stylesheets/related_objects.css.scss
new file mode 100644
index 0000000..4228cec
--- /dev/null
+++ b/apps/workbench/app/assets/stylesheets/related_objects.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the RelatedObjects controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/apps/workbench/app/controllers/related_objects_controller.rb b/apps/workbench/app/controllers/related_objects_controller.rb
new file mode 100644
index 0000000..5e88874
--- /dev/null
+++ b/apps/workbench/app/controllers/related_objects_controller.rb
@@ -0,0 +1,42 @@
+class RelatedObjectsController < ApplicationController
+  def model_class
+    Collection
+  end
+  def index
+    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
+      end
+      info[:links] << link
+    end
+    @request_url = request.url
+  end
+end
diff --git a/apps/workbench/app/helpers/related_objects_helper.rb b/apps/workbench/app/helpers/related_objects_helper.rb
new file mode 100644
index 0000000..f83177e
--- /dev/null
+++ b/apps/workbench/app/helpers/related_objects_helper.rb
@@ -0,0 +1,2 @@
+module RelatedObjectsHelper
+end
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 24991cd..67a681a 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -119,16 +119,21 @@
         </li>
 
         <% if current_user %>
-        <!-- XXX placeholder for this when search is implemented
+        <!-- XXX placeholder for this when search is implemented -->
         <li>
+	  <%= form_tag("/related_objects", method: "get") do %>
+	    <%= text_field_tag(:q) %>
+	    <%= submit_tag("Search") %>
+	  <% end %>
+	  <!--
           <form class="navbar-form" role="search">
             <div class="input-group" style="width: 220px">
               <input type="text" class="form-control" placeholder="search">
               <span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
             </div>
           </form>
+          -->
         </li>
-        -->
 
         <!-- XXX placeholder for this when persistent selection is implemented
         <li class="dropdown">
diff --git a/apps/workbench/app/views/related_objects/_index_tbody.html.erb b/apps/workbench/app/views/related_objects/_index_tbody.html.erb
new file mode 100644
index 0000000..9252886
--- /dev/null
+++ b/apps/workbench/app/views/related_objects/_index_tbody.html.erb
@@ -0,0 +1,39 @@
+<% @collections.each do |c| %>
+
+<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 %>
+  </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
new file mode 100644
index 0000000..71b762a
--- /dev/null
+++ b/apps/workbench/app/views/related_objects/_show_recent.html.erb
@@ -0,0 +1,48 @@
+<% content_for :tab_line_buttons do %>
+<div class="pull-right" style="width: 30%">
+  <%= form_tag collections_path, method: 'get', remote: true, class: 'form-search' do %>
+  <div class="input-group">
+    <%= text_field_tag :search, params[:search], class: 'form-control', placeholder: 'Search collections' %>
+    <span class="input-group-btn">
+      <%= button_tag(class: 'btn btn-info') do %>
+      <span class="glyphicon glyphicon-search"></span>
+      <% end %>
+    </span>
+  </div>  
+  <% end %>
+</div>
+<% end %>
+
+<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>
+</div>
+
+<% content_for :js do %>
+$(document).on('click', 'form[data-remote] input[type=submit]', function() {
+  $('table#collections-index tbody').fadeTo(200, 0.3);
+  return true;
+});
+<% end %>
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 5330a91..ae2ba8c 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -34,6 +34,7 @@ ArvadosWorkbench::Application.routes.draw do
   resources :collections
   get '/collections/:uuid/*file' => 'collections#show_file', :format => false
   root :to => 'users#welcome'
+  match '/related_objects' => 'related_objects#index'
 
   # Send unroutable requests to an arbitrary controller
   # (ends up at ApplicationController#render_not_found)
diff --git a/apps/workbench/test/functional/related_objects_controller_test.rb b/apps/workbench/test/functional/related_objects_controller_test.rb
new file mode 100644
index 0000000..5beefe5
--- /dev/null
+++ b/apps/workbench/test/functional/related_objects_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RelatedObjectsControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/apps/workbench/test/unit/helpers/related_objects_helper_test.rb b/apps/workbench/test/unit/helpers/related_objects_helper_test.rb
new file mode 100644
index 0000000..a91ee26
--- /dev/null
+++ b/apps/workbench/test/unit/helpers/related_objects_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class RelatedObjectsHelperTest < ActionView::TestCase
+end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list