Commit 1d601616a33aaa95e2ac7b21ff041b4a840df33c
1 parent
60bf502b
Exists in
master
and in
4 other branches
Pagination and better perfomance for projects page.
Showing
6 changed files
with
42 additions
and
19 deletions
Show diff stats
app/assets/stylesheets/common.scss
app/assets/stylesheets/main.scss
| ... | ... | @@ -104,6 +104,11 @@ $hover: #FDF5D9; |
| 104 | 104 | @import "sections/issues.scss"; |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | + * Styles related to projects | |
| 108 | + */ | |
| 109 | +@import "sections/projects.scss"; | |
| 110 | + | |
| 111 | +/** | |
| 107 | 112 | * This scss file redefine chozen selectbox styles for |
| 108 | 113 | * project Branch/Tag select element |
| 109 | 114 | */ | ... | ... |
app/controllers/commits_controller.rb
| ... | ... | @@ -43,8 +43,8 @@ class CommitsController < ApplicationController |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | 45 | def compare |
| 46 | - first = project.commit(params[:to]) | |
| 47 | - last = project.commit(params[:from]) | |
| 46 | + first = project.commit(params[:to].try(:strip)) | |
| 47 | + last = project.commit(params[:from].try(:strip)) | |
| 48 | 48 | |
| 49 | 49 | @diffs = [] |
| 50 | 50 | @commits = [] | ... | ... |
app/controllers/projects_controller.rb
| ... | ... | @@ -11,9 +11,9 @@ class ProjectsController < ApplicationController |
| 11 | 11 | before_filter :require_non_empty_project, :only => [:blob, :tree, :graph] |
| 12 | 12 | |
| 13 | 13 | def index |
| 14 | - @projects = current_user.projects | |
| 15 | - @projects = @projects.select(&:last_activity_date).sort_by(&:last_activity_date).reverse | |
| 16 | - @events = Event.where(:project_id => @projects.map(&:id)).recent.limit(20) | |
| 14 | + @projects = current_user.projects.includes(:events).order("events.created_at DESC") | |
| 15 | + @projects = @projects.page(params[:page]).per(40) | |
| 16 | + @events = Event.where(:project_id => current_user.projects.map(&:id)).recent.limit(20) | |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | def new | ... | ... |
app/views/projects/index.html.haml
| 1 | 1 | - if @projects.any? |
| 2 | - .row | |
| 3 | - .span8 | |
| 2 | + .projects | |
| 3 | + .activities.span8 | |
| 4 | 4 | - if current_user.require_ssh_key? |
| 5 | 5 | .alert.alert-error.padded |
| 6 | 6 | %span |
| ... | ... | @@ -14,24 +14,24 @@ |
| 14 | 14 | - else |
| 15 | 15 | .padded |
| 16 | 16 | %strong.cgray Projects activity will be displayed here |
| 17 | - .span4.right | |
| 18 | - %div.leftbar.ui-box | |
| 17 | + .side | |
| 18 | + .projects_box | |
| 19 | 19 | %h5 |
| 20 | 20 | Projects |
| 21 | 21 | %small |
| 22 | - (#{@projects.count}) | |
| 22 | + (#{@projects.total_count}) | |
| 23 | 23 | - if current_user.can_create_project? |
| 24 | 24 | %span.right |
| 25 | 25 | = link_to new_project_path, :class => "btn very_small info" do |
| 26 | 26 | New Project |
| 27 | - .content_list | |
| 28 | - - @projects.each do |project| | |
| 29 | - = link_to project_path(project), :class => dom_class(project) do | |
| 30 | - %h4 | |
| 31 | - %span.ico.project | |
| 32 | - = truncate(project.name, :length => 25) | |
| 33 | - %span.right | |
| 34 | - → | |
| 27 | + - @projects.each do |project| | |
| 28 | + = link_to project_path(project), :class => dom_class(project) do | |
| 29 | + %h4 | |
| 30 | + %span.ico.project | |
| 31 | + = truncate(project.name, :length => 25) | |
| 32 | + %span.right | |
| 33 | + → | |
| 34 | + .bottom= paginate @projects, :theme => "gitlab" | |
| 35 | 35 | |
| 36 | 36 | - else |
| 37 | 37 | %h3 Nothing here | ... | ... |