1 class UsersController < ApplicationController
2 skip_before_filter :find_object_by_uuid, :only => [:welcome, :activity]
3 skip_around_filter :thread_with_mandatory_api_token, :only => :welcome
4 before_filter :ensure_current_user_is_admin, only: :sudo
8 params[:action] = 'home'
14 @breadcrumb_page_name = nil
20 pipeline_instances: {}
22 @spans = [['This week', Time.now.beginning_of_week, Time.now],
24 Time.now.beginning_of_week.advance(weeks:-1),
25 Time.now.beginning_of_week],
26 ['This month', Time.now.beginning_of_month, Time.now],
28 1.month.ago.beginning_of_month,
29 Time.now.beginning_of_month]]
30 @spans.each do |span, threshold_start, threshold_end|
31 @activity[:logins][span] = Log.
32 filter([[:event_type, '=', 'login'],
33 [:object_kind, '=', 'arvados#user'],
34 [:created_at, '>=', threshold_start],
35 [:created_at, '<', threshold_end]])
36 @activity[:jobs][span] = Job.
37 filter([[:created_at, '>=', threshold_start],
38 [:created_at, '<', threshold_end]])
39 @activity[:pipeline_instances][span] = PipelineInstance.
40 filter([[:created_at, '>=', threshold_start],
41 [:created_at, '<', threshold_end]])
42 @activity.each do |type, act|
45 @user_activity[u.uuid] ||= {}
46 @user_activity[u.uuid][span + ' ' + type.to_s] ||= 0
48 records.each do |record|
49 @user_activity[record.modified_by_user_uuid] ||= {}
50 @user_activity[record.modified_by_user_uuid][span + ' ' + type.to_s] ||= 0
51 @user_activity[record.modified_by_user_uuid][span + ' ' + type.to_s] += 1
55 @users = @users.sort_by do |a|
56 [-@user_activity[a.uuid].values.inject(:+), a.full_name]
61 if current_user.andand.is_admin
69 resp = $arvados_api_client.api(ApiClientAuthorization, '', {
70 api_client_authorization: {
71 owner_uuid: @object.uuid
74 redirect_to root_url(api_token: resp[:api_token])
78 @showallalerts = false
79 @my_ssh_keys = AuthorizedKey.where(authorized_user_uuid: current_user.uuid)
80 # @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login')
81 # @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write')
87 order('created_at desc').
88 where(created_by: current_user.uuid)
90 @my_collections = Collection.
92 order('created_at desc').
93 where(created_by: current_user.uuid)
95 Link.limit(1000).where(head_uuid: @my_collections.collect(&:uuid),
96 link_class: 'tag').each do |link|
97 (@my_tag_links[link.head_uuid] ||= []) << link
100 @my_pipelines = PipelineInstance.
102 order('created_at desc').
103 where(created_by: current_user.uuid)
106 # A Tutorial is a Link which has link_class "resources" and name
107 # "wants", and is owned by the Tutorials Group (i.e., named
108 # "Arvados Tutorials" and owned by the system user).
109 @tutorial_group = Group.where(owner_uuid: User.system.uuid,
110 name: 'Arvados Tutorials').first
112 @tutorial_links = Link.where(tail_uuid: @tutorial_group.uuid,
113 link_class: 'resources',
118 @tutorial_complete = {
119 'Run a job' => @my_last_job
122 f.js { render template: 'users/home.js' }
123 f.html { render template: 'users/home' }