summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-29 01:20:17 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-29 01:20:17 -0800
commit1f0e16569f1924ed967bff9f4f78bbee874251db (patch)
tree06c9c64dc37d6646cb467b8b854e0b557662d934 /app
parentc9f18d4587f16eb16b8b902d69576520c08b7f5a (diff)
downloadgitlab-ce-1f0e16569f1924ed967bff9f4f78bbee874251db.tar.gz
Load contribution calendar via AJAX
Diffstat (limited to 'app')
-rw-r--r--app/controllers/users_controller.rb31
-rw-r--r--app/views/users/calendar.html.haml (renamed from app/views/users/_calendar.html.haml)1
-rw-r--r--app/views/users/show.html.haml10
3 files changed, 29 insertions, 13 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9e5ea6cfa45..8c96f67a2a4 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,14 +1,7 @@
class UsersController < ApplicationController
- skip_before_filter :authenticate_user!, only: [:show, :activities]
layout :determine_layout
def show
- @user = User.find_by_username!(params[:username])
-
- unless current_user || @user.public_profile?
- return authenticate_user!
- end
-
# Projects user can view
visible_projects = ProjectsFinder.new.execute(current_user)
authorized_projects_ids = visible_projects.pluck(:id)
@@ -25,6 +18,15 @@ class UsersController < ApplicationController
@title = @user.name
+ respond_to do |format|
+ format.html
+ format.atom { render layout: false }
+ end
+ end
+
+ def calendar
+ visible_projects = ProjectsFinder.new.execute(current_user)
+
# Get user repositories and collect timestamps for commits
user_repositories = visible_projects.map(&:repository)
calendar = Gitlab::CommitsCalendar.new(user_repositories, @user)
@@ -32,10 +34,7 @@ class UsersController < ApplicationController
@starting_year = (Time.now - 1.year).strftime("%Y")
@starting_month = Date.today.strftime("%m").to_i
- respond_to do |format|
- format.html
- format.atom { render layout: false }
- end
+ render 'calendar', layout: false
end
def determine_layout
@@ -45,4 +44,14 @@ class UsersController < ApplicationController
'public_users'
end
end
+
+ private
+
+ def authenticate_user!
+ @user = User.find_by_username!(params[:username])
+
+ unless current_user || @user.public_profile?
+ return authenticate_user!
+ end
+ end
end
diff --git a/app/views/users/_calendar.html.haml b/app/views/users/calendar.html.haml
index b16a7305a32..727faf23679 100644
--- a/app/views/users/_calendar.html.haml
+++ b/app/views/users/calendar.html.haml
@@ -1,3 +1,4 @@
+%h4 Calendar:
#cal-heatmap.calendar
:javascript
new calendar(
diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml
index c248a280475..445f43cd500 100644
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -19,8 +19,9 @@
= render 'groups', groups: @groups
%hr
- %h4 Calendar:
- %div= render 'calendar'
+ .user-calendar
+ %h4.center.light
+ %i.fa.fa-spinner.fa-spin
%hr
%h4
User Activity:
@@ -36,3 +37,8 @@
= render 'profile', user: @user
- if @projects.present?
= render 'projects', projects: @projects
+
+
+:coffeescript
+ $ ->
+ $(".user-calendar").load("#{user_calendar_path}")