[ARVADOS] created: 36601cdb390b06d0128152cbda6df7aadfab6aca

git at public.curoverse.com git at public.curoverse.com
Mon Jan 13 03:58:14 EST 2014


        at  36601cdb390b06d0128152cbda6df7aadfab6aca (commit)


commit 36601cdb390b06d0128152cbda6df7aadfab6aca
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Jan 13 00:56:26 2014 -0800

    Add AJAX tag search box to collections.index page.
    
    refs #1499

diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 548d4f7..f0e7765 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -7,7 +7,12 @@ class CollectionsController < ApplicationController
   end
 
   def index
-    @collections = Collection.limit(100)
+    if params[:search].andand.length > 0
+      tags = Link.where(link_class: 'tag', any: ['contains', params[:search]])
+      @collections = Collection.where(uuid: tags.collect(&:head_uuid))
+    else
+      @collections = Collection.limit(100)
+    end
     @links = Link.limit(1000).
       where(head_uuid: @collections.collect(&:uuid))
     @collection_info = {}
diff --git a/apps/workbench/app/views/collections/_index_tbody.html.erb b/apps/workbench/app/views/collections/_index_tbody.html.erb
new file mode 100644
index 0000000..f8fbcdc
--- /dev/null
+++ b/apps/workbench/app/views/collections/_index_tbody.html.erb
@@ -0,0 +1,27 @@
+<% @collections.each do |c| %>
+
+<tr class="collection">
+  <td>
+    <%= link_to_if_arvados_object c.uuid %>
+  </td><td>
+    <% c.files.each do |file| %>
+      <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
+    <% end %>
+  </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/collections/index.html.erb b/apps/workbench/app/views/collections/index.html.erb
index 6fb506d..11cacc7 100644
--- a/apps/workbench/app/views/collections/index.html.erb
+++ b/apps/workbench/app/views/collections/index.html.erb
@@ -1,6 +1,15 @@
 <%#= render :partial => 'nav' %>
 
-<table class="topalign table table-bordered table-condensed table-fixedlayout table-smallcontent">
+<div class="pull-right">
+  <%= form_tag collections_path, method: 'get', remote: true do %>
+  <div class="input-append">
+    <%= text_field_tag :search, params[:search] %>
+    <%= submit_tag "Search", name: nil, class: 'btn btn-info' %>
+  </div>  
+  <% end %>
+</div>
+
+<table id="collections-index" class="topalign table table-bordered table-condensed table-fixedlayout table-smallcontent">
   <colgroup>
     <col width="10%" />
     <col width="50%" />
@@ -24,34 +33,13 @@
     </tr>
   </thead>
   <tbody>
-
-    <% @collections.each do |c| %>
-
-    <tr class="collection">
-      <td>
-        <%= link_to_if_arvados_object c.uuid %>
-      </td><td>
-        <% c.files.each do |file| %>
-          <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
-        <% end %>
-      </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 %>
-
+    <%= render partial: 'index_tbody' %>
   </tbody>
 </table>
+
+<% 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/app/views/collections/index.js.erb b/apps/workbench/app/views/collections/index.js.erb
new file mode 100644
index 0000000..cbe1096
--- /dev/null
+++ b/apps/workbench/app/views/collections/index.js.erb
@@ -0,0 +1,2 @@
+$('table#collections-index tbody').html("<%= escape_javascript(render partial: 'index_tbody') %>");
+$('table#collections-index tbody').fadeTo(200, 1.0);

commit c16fd46f51a61f5d66e08b786362d91ef5a33f7d
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Jan 13 00:23:28 2014 -0800

    Update collections index to match front page table, and add tags column.
    
    refs #1511

diff --git a/apps/workbench/app/assets/stylesheets/application.css b/apps/workbench/app/assets/stylesheets/application.css
index a13d015..eca9be8 100644
--- a/apps/workbench/app/assets/stylesheets/application.css
+++ b/apps/workbench/app/assets/stylesheets/application.css
@@ -57,3 +57,15 @@ table.arv-index tbody td.arv-object-AuthorizedKey.arv-attr-public_key {
     overflow-x: hidden;
     max-width: 120px;
 }
+table.table-fixedlayout {
+    white-space: nowrap;
+    table-layout: fixed;
+}
+table.table-fixedlayout td {
+    overflow: hidden;
+    overflow-x: hidden;
+    text-overflow: ellipsis;
+}
+table.table-smallcontent td {
+    font-size: 85%;
+}
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 5d5eb79..548d4f7 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -7,38 +7,32 @@ class CollectionsController < ApplicationController
   end
 
   def index
-    @collections = Collection.limit(100).to_hash
-    @links = Link.eager.limit(100).where(head_kind: 'arvados#collection', link_class: 'resources', name: 'wants') |
-      Link.eager.limit(100).where(tail_kind: 'arvados#collection', link_class: 'data_origin')
-    @collections.merge!(Collection.
-                        limit(100).
-                        where(uuid: @links.select{|x|x.head_kind=='arvados#collection'}.collect(&:head_uuid) |
-                              @links.select{|x|x.tail_kind=='arvados#collection'}.collect(&:tail_uuid)).
-                        to_hash)
+    @collections = Collection.limit(100)
+    @links = Link.limit(1000).
+      where(head_uuid: @collections.collect(&:uuid))
     @collection_info = {}
-    @collections.each do |uuid, c|
-      ci = (@collection_info[uuid] ||= {uuid: uuid})
-      ci[:created_at] = c.created_at
+    @collections.each do |c|
+      @collection_info[c.uuid] = {
+        tags: [],
+        wanted: false,
+        wanted_by_me: false,
+        provenance: [],
+        links: []
+      }
     end
-    @links.each do |l|
-      if l.head_kind == 'arvados#collection'
-        c = (@collection_info[l.head_uuid] ||= {uuid: l.head_uuid})
-        if l.link_class == 'resources' and l.name == 'wants'
-          if l.head.respond_to? :created_at
-            c[:created_at] = l.head.created_at
-          end
-          c[:wanted] = true
-          if l.owner_uuid == current_user.uuid
-            c[:wanted_by_me] = true
-          end
-        end
-      end
-      if l.tail_kind == 'arvados#collection'
-        c = (@collection_info[l.tail_uuid] ||= {uuid: l.tail_uuid})
-        if l.link_class == 'data_origin'
-          c[:origin] = l
-        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
   end
 
diff --git a/apps/workbench/app/views/collections/index.html.erb b/apps/workbench/app/views/collections/index.html.erb
index b5055a2..6fb506d 100644
--- a/apps/workbench/app/views/collections/index.html.erb
+++ b/apps/workbench/app/views/collections/index.html.erb
@@ -1,43 +1,53 @@
 <%#= render :partial => 'nav' %>
 
-<table class="topalign table table-bordered table-striped">
+<table class="topalign table table-bordered table-condensed table-fixedlayout table-smallcontent">
+  <colgroup>
+    <col width="10%" />
+    <col width="50%" />
+    <col width="16%" />
+    <col width="16%" />
+    <col width="8%" />
+  </colgroup>
   <thead>
     <tr class="contain-align-left">
       <th>
 	uuid
       </th><th>
-	created
+	contents
       </th><th>
-	protected
+	age
       </th><th>
-	groups
+	tags
       </th><th>
-	origin
+	storage
       </th>
     </tr>
   </thead>
   <tbody>
 
-    <% @collection_info.sort_by { |k,c| c[:created_at].is_a?(Time) ? c[:created_at] : Time.now }.reverse.each do |uuid, c| %>
+    <% @collections.each do |c| %>
 
     <tr class="collection">
       <td>
-	<% if @collections.has_key? uuid %>
-	<%= link_to_if_arvados_object uuid %>
-	<% else %>
-	<%= uuid %>
-	<% end %>
+        <%= link_to_if_arvados_object c.uuid %>
       </td><td>
-	<%= raw(distance_of_time_in_words(c[:created_at], Time.now).sub('about ','~').sub(' ',' ')) if c[:created_at] %>
+        <% c.files.each do |file| %>
+          <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
+        <% end %>
       </td><td>
-	<%= ('Y' if c[:wanted_by_me]) or ('y' if c[:wanted]) %>
+	<%= raw(distance_of_time_in_words(c.created_at, Time.now).sub('about ','~').sub(' ',' ')) if c.created_at %>
       </td><td>
-	<%= c[:groups].size if c[:groups] %>
+        <% if @collection_info[c.uuid] %>
+          <%= @collection_info[c.uuid][:tags].uniq.join ', ' %>
+        <% end %>
       </td><td>
-	<% if c[:origin] %>
-	<span class="deemphasize"><%= c[:origin].name %></span>
-	<%= c[:origin].head_uuid %>
-	<% end %>
+        <% 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>
 
diff --git a/apps/workbench/app/views/users/_home.html.erb b/apps/workbench/app/views/users/_home.html.erb
index 883b6a0..9ec9d80 100644
--- a/apps/workbench/app/views/users/_home.html.erb
+++ b/apps/workbench/app/views/users/_home.html.erb
@@ -7,15 +7,6 @@
       margin-left: auto;
       margin-right: auto;
       }
-      .job-table {
-      white-space: nowrap;
-      table-layout: fixed;
-      }
-      .job-table td {
-      overflow: hidden;
-      overflow-x: hidden;
-      text-overflow: ellipsis;
-      }
       .centerme {
       margin-left: auto;
       margin-right: auto;
diff --git a/apps/workbench/app/views/users/_tables.html.erb b/apps/workbench/app/views/users/_tables.html.erb
index cec0d87..6e740df 100644
--- a/apps/workbench/app/views/users/_tables.html.erb
+++ b/apps/workbench/app/views/users/_tables.html.erb
@@ -5,7 +5,7 @@
     <% if not current_user.andand.is_active or @my_jobs.empty? %>
       <br/>(None)
     <% else %>
-      <table class="table table-bordered table-condensed job-table">
+      <table class="table table-bordered table-condensed table-fixedlayout">
 	<colgroup>
           <col width="28%" />
           <col width="38%" />
@@ -89,7 +89,7 @@
   <% if not current_user.andand.is_active or @my_pipelines.empty? %>
     <br/>(None)
   <% else %>
-    <table class="table table-bordered table-condensed job-table">
+    <table class="table table-bordered table-condensed table-fixedlayout">
       <colgroup>
         <col width="73%" />
         <col width="15%" />
@@ -143,7 +143,7 @@
   <% if not current_user.andand.is_active or @my_collections.empty? %>
     <br/>(None)
   <% else %>
-    <table class="table table-bordered table-condensed job-table">
+    <table class="table table-bordered table-condensed table-fixedlayout">
       <colgroup>
         <col width="73%" />
         <col width="27%" />

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list