Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
485c5199
Commit
485c5199
authored
Oct 31, 2011
by
gitlabhq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user dashboard
parent
267bd606
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
4 deletions
+73
-4
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+1
-0
app/helpers/dashboard_helper.rb
app/helpers/dashboard_helper.rb
+7
-0
app/models/project.rb
app/models/project.rb
+23
-3
app/views/dashboard/index.html.haml
app/views/dashboard/index.html.haml
+36
-1
app/views/layouts/_head_panel.html.erb
app/views/layouts/_head_panel.html.erb
+1
-0
config/routes.rb
config/routes.rb
+1
-0
lib/commit_ext.rb
lib/commit_ext.rb
+4
-0
No files found.
app/controllers/dashboard_controller.rb
View file @
485c5199
class
DashboardController
<
ApplicationController
def
index
@projects
=
current_user
.
projects
.
all
@active_projects
=
@projects
.
select
(
&
:last_activity_date
).
sort_by
(
&
:last_activity_date
).
reverse
end
end
app/helpers/dashboard_helper.rb
View file @
485c5199
module
DashboardHelper
def
path_to_object
(
project
,
object
)
case
object
.
class
.
name
.
to_s
when
"Issue"
then
project_issues_path
(
project
,
project
.
issues
.
find
(
object
.
id
))
when
"Grit::Commit"
then
project_commit_path
(
project
,
project
.
repo
.
commits
(
object
.
id
).
first
)
else
"#"
end
end
end
app/models/project.rb
View file @
485c5199
...
...
@@ -119,6 +119,26 @@ class Project < ActiveRecord::Base
repo
rescue
false
end
def
last_activity
updates
(
1
).
first
rescue
nil
end
def
last_activity_date
last_activity
.
try
(
:created_at
)
end
def
updates
(
n
=
3
)
[
fresh_commits
(
n
),
issues
.
last
(
n
),
notes
.
fresh
.
limit
(
n
)
].
compact
.
flatten
.
sort
do
|
x
,
y
|
y
.
created_at
<=>
x
.
created_at
end
[
0
..
n
]
end
def
commit
(
commit_id
=
nil
)
if
commit_id
repo
.
commits
(
commit_id
).
first
...
...
@@ -131,16 +151,16 @@ class Project < ActiveRecord::Base
@heads
||=
repo
.
heads
end
def
fresh_commits
def
fresh_commits
(
n
=
10
)
commits
=
heads
.
map
do
|
h
|
repo
.
commits
(
h
.
name
,
10
)
repo
.
commits
(
h
.
name
,
n
)
end
.
flatten
.
uniq
{
|
c
|
c
.
id
}
commits
.
sort!
do
|
x
,
y
|
y
.
committed_date
<=>
x
.
committed_date
end
commits
[
0
..
10
]
commits
[
0
..
n
]
end
def
commits_since
(
date
)
...
...
app/views/dashboard/index.html.haml
View file @
485c5199
timeline
#dashboard-content
.dashboard-content.content
%aside
%h4
%a
.button-small.button-green
{
:href
=>
""
}
New Repository
Your Repositories
%ol
.project-list
-
@projects
.
each
do
|
project
|
%li
%a
{
:href
=>
"#"
}
%span
.arrow
→
%span
.project-name
=
project
.
name
%span
.time
%strong
Last activity:
=
project
.
last_activity_date
?
time_ago_in_words
(
project
.
last_activity_date
)
+
" ago"
:
"Never"
#news-feed
.news-feed
%h2
.icon
%span
>
Dashboard
-
@active_projects
.
each
do
|
project
|
.project-box.project-updates.ui-box.ui-box-small.ui-box-big
%h3
=
project
.
name
.data
-
project
.
updates
.
each
do
|
update
|
%a
.project-update
{
:href
=>
path_to_object
(
project
,
update
)}
%img
{
:src
=>
"http://placehold.it/40x40"
}
%span
.update-title
[
#{
update
.
class
.
name
}
] added a matcher that helps debugging matching problems
%span
.update-author
%strong
=
update
.
author
.
name
authored
=
time_ago_in_words
(
update
.
created_at
)
ago
%br
/ .project-update
/ .project-updates
/ #news-feed
/ #dashboard-content
app/views/layouts/_head_panel.html.erb
View file @
485c5199
...
...
@@ -10,6 +10,7 @@
</div>
<div
class=
"right"
>
<%=
link_to
truncate
(
@project
.
name
,
:length
=>
20
),
project_path
(
@project
),
:class
=>
"current button"
if
@project
&&
!
@project
.
new_record?
%>
<%=
link_to
'Dashboard'
,
dashboard_path
,
:class
=>
current_page?
(
dashboard_path
)
?
"current button"
:
"button"
%>
<%=
link_to
'Projects'
,
projects_path
,
:class
=>
current_page?
(
projects_path
)
?
"current button"
:
"button"
%>
<%=
link_to
(
'Admin'
,
admin_root_path
,
:class
=>
admin_namespace?
?
"current button"
:
"button"
)
if
current_user
.
is_admin?
%>
<%=
link_to
profile_path
,
:class
=>
((
controller
.
controller_name
==
"keys"
||
controller
.
controller_name
==
"profile"
)
?
"current button"
:
"button"
)
do
%>
...
...
config/routes.rb
View file @
485c5199
...
...
@@ -15,6 +15,7 @@ Gitlab::Application.routes.draw do
put
"profile/password"
,
:to
=>
"profile#password_update"
put
"profile/edit"
,
:to
=>
"profile#social_update"
get
"profile"
,
:to
=>
"profile#show"
get
"dashboard"
,
:to
=>
"dashboard#index"
#get "profile/:id", :to => "profile#show"
resources
:projects
,
:only
=>
[
:new
,
:create
,
:index
]
...
...
lib/commit_ext.rb
View file @
485c5199
...
...
@@ -8,4 +8,8 @@ module CommitExt
rescue
"-- invalid encoding for commit message"
end
def
created_at
committed_date
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment