Commit c94159ab089fe964263643ffc7e881ba8cac3f23
1 parent
219ac189
Exists in
master
and in
4 other branches
improved dashboard
Showing
6 changed files
with
62 additions
and
49 deletions
Show diff stats
app/assets/stylesheets/common.scss
... | ... | @@ -615,6 +615,7 @@ p.time { |
615 | 615 | margin:auto; |
616 | 616 | |
617 | 617 | .wll { |
618 | + padding:5px; | |
618 | 619 | border:none; |
619 | 620 | &:hover { |
620 | 621 | background:none; |
... | ... | @@ -623,12 +624,19 @@ p.time { |
623 | 624 | h4 { |
624 | 625 | color:#666; |
625 | 626 | } |
627 | + &.event_feed { | |
628 | + min-height:40px; | |
629 | + border-bottom:1px solid #eee; | |
630 | + .avatar { | |
631 | + width:32px; | |
632 | + } | |
633 | + ul { | |
634 | + margin-left:50px; | |
635 | + .avatar { | |
636 | + width:24px; | |
637 | + } | |
638 | + } | |
639 | + } | |
626 | 640 | } |
627 | 641 | } |
628 | 642 | } |
629 | - | |
630 | -.event_feed { | |
631 | - ul { | |
632 | - margin-left:50px; | |
633 | - } | |
634 | -} | ... | ... |
app/controllers/dashboard_controller.rb
... | ... | @@ -4,12 +4,12 @@ class DashboardController < ApplicationController |
4 | 4 | def index |
5 | 5 | @projects = current_user.projects.all |
6 | 6 | |
7 | - @active_projects = @projects.select(&:repo_exists?).select(&:last_activity_date_cached).sort_by(&:last_activity_date_cached).reverse | |
7 | + @active_projects = @projects.select(&:last_activity_date).sort_by(&:last_activity_date).reverse | |
8 | 8 | |
9 | - @merge_requests = MergeRequest.where("author_id = :id or assignee_id = :id", :id => current_user.id).opened.order("created_at DESC").limit(10) | |
9 | + @merge_requests = MergeRequest.where("author_id = :id or assignee_id = :id", :id => current_user.id).opened.order("created_at DESC").limit(5) | |
10 | 10 | |
11 | 11 | @user = current_user |
12 | - @issues = current_user.assigned_issues.opened.order("created_at DESC").limit(10) | |
12 | + @issues = current_user.assigned_issues.opened.order("created_at DESC").limit(5) | |
13 | 13 | @issues = @issues.includes(:author, :project) |
14 | 14 | |
15 | 15 | @events = Event.where(:project_id => @projects.map(&:id)).recent.limit(20) | ... | ... |
app/models/project.rb
... | ... | @@ -277,31 +277,21 @@ class Project < ActiveRecord::Base |
277 | 277 | end |
278 | 278 | |
279 | 279 | def last_activity |
280 | - updates(1).first | |
280 | + events.last | |
281 | 281 | rescue |
282 | 282 | nil |
283 | 283 | end |
284 | 284 | |
285 | 285 | def last_activity_date |
286 | - last_activity.try(:created_at) | |
287 | - end | |
288 | - | |
289 | - def last_activity_date_cached(expire = 1.hour) | |
290 | - activity_date_key = "project_#{id}_activity_date" | |
291 | - | |
292 | - cached_activities = Rails.cache.read(activity_date_key) | |
293 | - if cached_activities | |
294 | - activity_date = if cached_activities == "Never" | |
295 | - nil | |
296 | - else | |
297 | - cached_activities | |
298 | - end | |
286 | + if events.last | |
287 | + events.last.created_at | |
299 | 288 | else |
300 | - activity_date = last_activity_date | |
301 | - Rails.cache.write(activity_date_key, activity_date || "Never", :expires_in => expire) | |
289 | + updated_at | |
302 | 290 | end |
291 | + end | |
303 | 292 | |
304 | - activity_date | |
293 | + def last_activity_date_cached(expire = 1.hour) | |
294 | + last_activity_date | |
305 | 295 | end |
306 | 296 | |
307 | 297 | # Get project updates from cache | ... | ... |
app/views/dashboard/_events_feed.html.haml
1 | -- @events.each do |event| | |
2 | - .wll.event_feed | |
3 | - - if event.push? | |
4 | - - if event.new_branch? | |
5 | - User pushed new branch | |
6 | - - else | |
7 | - = image_tag gravatar_icon(event.pusher_email), :class => "avatar" | |
8 | - #{event.pusher_name} pushed to | |
9 | - = link_to project_commits_path(event.project, :ref => event.branch_name) do | |
10 | - %strong= event.branch_name | |
11 | - %span.cgray | |
12 | - = time_ago_in_words(event.created_at) | |
13 | - ago. | |
14 | - - if event.commits.count > 1 | |
15 | - = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do | |
16 | - Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]} | |
17 | - - @project = event.project | |
18 | - %ul.unstyled | |
19 | - = render event.commits | |
1 | += render @events | |
2 | + | ... | ... |
app/views/dashboard/index.html.haml
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | |
9 | 9 | %div.dashboard_category |
10 | 10 | %h3 |
11 | - Projects | |
11 | + = link_to "Projects" , "#projects", :id => "projects" | |
12 | 12 | %small |
13 | 13 | ( most recent ) |
14 | 14 | |
... | ... | @@ -34,7 +34,8 @@ |
34 | 34 | - unless @merge_requests.blank? |
35 | 35 | %div.dashboard_category |
36 | 36 | %h3 |
37 | - Merge Requests | |
37 | + = link_to "Merge Requests" , "#merge_requests", :id => "merge_requests" | |
38 | + | |
38 | 39 | %small ( authored or assigned to you ) |
39 | 40 | %strong.right |
40 | 41 | = link_to dashboard_merge_requests_path do |
... | ... | @@ -46,7 +47,7 @@ |
46 | 47 | - unless @issues.blank? |
47 | 48 | %div.dashboard_category |
48 | 49 | %h3 |
49 | - Issues | |
50 | + = link_to "Issues" , "#issues", :id => "issues" | |
50 | 51 | %small ( assigned to you ) |
51 | 52 | %strong.right |
52 | 53 | = link_to dashboard_merge_requests_path do |
... | ... | @@ -58,7 +59,7 @@ |
58 | 59 | - unless @events.blank? |
59 | 60 | %div.dashboard_category |
60 | 61 | %h3 |
61 | - Activities | |
62 | + = link_to "Activities" , "#activities", :id => "activities" | |
62 | 63 | |
63 | 64 | %hr |
64 | 65 | .row | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +.wll.event_feed | |
2 | + - if event.push? | |
3 | + - if event.new_branch? | |
4 | + = image_tag gravatar_icon(event.pusher_email), :class => "avatar" | |
5 | + %strong #{event.pusher_name} | |
6 | + pushed new branch | |
7 | + = link_to project_commits_path(event.project, :ref => event.branch_name) do | |
8 | + %strong= event.branch_name | |
9 | + at | |
10 | + %strong= link_to event.project.name, event.project | |
11 | + %span.cgray | |
12 | + = time_ago_in_words(event.created_at) | |
13 | + ago. | |
14 | + - else | |
15 | + = image_tag gravatar_icon(event.pusher_email), :class => "avatar" | |
16 | + %strong #{event.pusher_name} | |
17 | + pushed to | |
18 | + = link_to project_commits_path(event.project, :ref => event.branch_name) do | |
19 | + %strong= event.branch_name | |
20 | + at | |
21 | + %strong= link_to event.project.name, event.project | |
22 | + %span.cgray | |
23 | + = time_ago_in_words(event.created_at) | |
24 | + ago. | |
25 | + - if event.commits.count > 1 | |
26 | + = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do | |
27 | + Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]} | |
28 | + - @project = event.project | |
29 | + %ul.unstyled | |
30 | + = render event.commits | |
31 | + | ... | ... |