From 7e4cdc1969319161c8412f57e4c68692421408a4 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 13 Jan 2014 13:48:33 -0800 Subject: [PATCH] Add collection search box on home page. refs #1499 --- .../app/assets/stylesheets/application.css | 6 ++++++ .../app/controllers/users_controller.rb | 7 +++++++ .../app/views/users/_tables.html.erb | 21 ++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/apps/workbench/app/assets/stylesheets/application.css b/apps/workbench/app/assets/stylesheets/application.css index eca9be826d..9c67653233 100644 --- a/apps/workbench/app/assets/stylesheets/application.css +++ b/apps/workbench/app/assets/stylesheets/application.css @@ -69,3 +69,9 @@ table.table-fixedlayout td { table.table-smallcontent td { font-size: 85%; } +form input.search-mini { + padding: 0 6px; +} +form.small-form-margin { + margin-bottom: 2px; +} diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb index 89d336f5e9..f9a74e2c73 100644 --- a/apps/workbench/app/controllers/users_controller.rb +++ b/apps/workbench/app/controllers/users_controller.rb @@ -15,6 +15,8 @@ class UsersController < ApplicationController # @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login') # @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write') + @my_tag_links = {} + @my_jobs = Job. limit(10). order('created_at desc'). @@ -25,6 +27,11 @@ class UsersController < ApplicationController order('created_at desc'). where(created_by: current_user.uuid) + Link.limit(1000).where(head_uuid: @my_collections.collect(&:uuid), + link_class: 'tag').each do |link| + (@my_tag_links[link.head_uuid] ||= []) << link + end + @my_pipelines = PipelineInstance. limit(10). order('created_at desc'). diff --git a/apps/workbench/app/views/users/_tables.html.erb b/apps/workbench/app/views/users/_tables.html.erb index 6e740df5a4..bcbf3d7c6d 100644 --- a/apps/workbench/app/views/users/_tables.html.erb +++ b/apps/workbench/app/views/users/_tables.html.erb @@ -140,17 +140,29 @@
Recent collections <%= link_to raw("Show all collections →"), collections_path, class: 'pull-right' %> +
+ <%= form_tag collections_path, + method: 'get', + class: 'form-search small-form-margin' do %> +
+ <%= text_field_tag :search, params[:search], class: 'search-query search-mini' %> + <%= submit_tag "Search", name: nil, class: 'btn btn-mini btn-info' %> +
+ <% end %> +
<% if not current_user.andand.is_active or @my_collections.empty? %>
(None) <% else %> - + + + @@ -165,6 +177,13 @@ +
ContentsTags Age
+ <% if @my_tag_links[c.uuid] %> + + <%= @my_tag_links[c.uuid].collect(&:name).join(", ") %> + + <% end %> + <%= raw(distance_of_time_in_words(c.created_at, Time.now).sub('about -- 2.30.2