Advertise filters param in discovery doc.
[arvados.git] / apps / workbench / app / controllers / users_controller.rb
1 class UsersController < ApplicationController
2   skip_before_filter :find_object_by_uuid, :only => :welcome
3   skip_around_filter :thread_with_mandatory_api_token, :only => :welcome
4
5   def welcome
6     if current_user
7       params[:action] = 'home'
8       home
9     end
10   end
11
12   def home
13     @showallalerts = false
14     @my_ssh_keys = AuthorizedKey.where(authorized_user_uuid: current_user.uuid)
15     # @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login')
16     # @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write')
17
18     @my_tag_links = {}
19
20     @my_jobs = Job.
21       limit(10).
22       order('created_at desc').
23       where(created_by: current_user.uuid)
24
25     @my_collections = Collection.
26       limit(10).
27       order('created_at desc').
28       where(created_by: current_user.uuid)
29
30     Link.limit(1000).where(head_uuid: @my_collections.collect(&:uuid),
31                            link_class: 'tag').each do |link|
32       (@my_tag_links[link.head_uuid] ||= []) << link
33     end
34
35     @my_pipelines = PipelineInstance.
36       limit(10).
37       order('created_at desc').
38       where(created_by: current_user.uuid)
39
40
41     # A Tutorial is a Link which has link_class "resources" and name
42     # "wants", and is owned by the Tutorials Group (i.e., named
43     # "Arvados Tutorials" and owned by the system user).
44     @tutorial_group = Group.where(owner_uuid: User.system.uuid,
45                                   name: 'Arvados Tutorials').first
46     if @tutorial_group
47       @tutorial_links = Link.where(tail_uuid: @tutorial_group.uuid,
48                                    link_class: 'resources',
49                                    name: 'wants')
50     else
51       @tutorial_links = []
52     end
53     @tutorial_complete = {
54       'Run a job' => @my_last_job
55     }
56     respond_to do |f|
57       f.js { render template: 'users/home.js' }
58       f.html { render template: 'users/home' }
59     end
60   end
61 end