Merge branch 'master' of git.clinicalfuture.com:arvados into 1692-redesign-dashboard
[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_api_token, :only => :welcome
4   around_filter :thread_with_optional_api_token, :only => :welcome
5
6   def welcome
7     if current_user
8       redirect_to home_user_path(current_user.uuid)
9     end
10   end
11
12   def home
13     @my_ssh_keys = AuthorizedKey.where(authorized_user_uuid: current_user.uuid)
14     # @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login')
15     # @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write')
16     @my_jobs = Job.
17       limit(10).
18       order('created_at desc').
19       where(created_by: current_user.uuid)
20
21     @my_collections = Collection.
22       limit(10).
23       order('created_at desc').
24       where(created_by: current_user.uuid)
25
26     @my_pipelines = PipelineInstance.
27       limit(10).
28       order('created_at desc').
29       where(created_by: current_user.uuid)
30
31
32     # A Tutorial is a Link which has link_class "resources" and name
33     # "wants", and is owned by the Tutorials Group (i.e., named
34     # "Arvados Tutorials" and owned by the system user).
35     @tutorial_group = Group.where(owner_uuid: User.system.uuid,
36                                   name: 'Arvados Tutorials').first
37     if @tutorial_group
38       @tutorial_links = Link.where(tail_uuid: @tutorial_group.uuid,
39                                    link_class: 'resources',
40                                    name: 'wants')
41     else
42       @tutorial_links = []
43     end
44     @tutorial_complete = {
45       'Run a job' => @my_last_job
46     }
47   end
48 end