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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
7522ac0b
Commit
7522ac0b
authored
Feb 03, 2016
by
Josh Frye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paginate + ajax filter dashboard projects
parent
87b61db7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
67 additions
and
46 deletions
+67
-46
app/assets/javascripts/projects_list.js.coffee
app/assets/javascripts/projects_list.js.coffee
+14
-12
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+3
-2
app/controllers/dashboard/projects_controller.rb
app/controllers/dashboard/projects_controller.rb
+12
-0
app/controllers/explore/projects_controller.rb
app/controllers/explore/projects_controller.rb
+6
-6
app/views/dashboard/_projects_head.html.haml
app/views/dashboard/_projects_head.html.haml
+7
-6
app/views/dashboard/projects/_projects.html.haml
app/views/dashboard/projects/_projects.html.haml
+4
-1
app/views/explore/projects/_projects.html.haml
app/views/explore/projects/_projects.html.haml
+2
-2
app/views/explore/projects/starred.html.haml
app/views/explore/projects/starred.html.haml
+2
-2
app/views/explore/projects/trending.html.haml
app/views/explore/projects/trending.html.haml
+1
-1
app/views/shared/projects/_list.html.haml
app/views/shared/projects/_list.html.haml
+16
-14
No files found.
app/assets/javascripts/projects_list.js.coffee
View file @
7522ac0b
...
@@ -11,16 +11,18 @@ class @ProjectsList
...
@@ -11,16 +11,18 @@ class @ProjectsList
uiBox
=
$
(
'div.projects-list-holder'
)
uiBox
=
$
(
'div.projects-list-holder'
)
filterSelector
=
$
(
this
).
data
(
'filter-selector'
)
||
'span.filter-title'
filterSelector
=
$
(
this
).
data
(
'filter-selector'
)
||
'span.filter-title'
if
terms
==
""
||
terms
==
undefined
$
(
'.projects-list-holder'
).
css
(
"opacity"
,
'0.5'
)
uiBox
.
find
(
"ul.projects-list li"
).
show
()
form
=
$
(
"#project-list-form"
)
else
project_filter_url
=
form
.
attr
(
'action'
)
+
'?'
+
form
.
serialize
()
uiBox
.
find
(
"ul.projects-list li"
).
each
(
index
)
->
$
.
ajax
name
=
$
(
this
).
find
(
filterSelector
).
text
()
type
:
"GET"
url
:
form
.
attr
(
'action'
)
if
name
.
toLowerCase
().
search
(
terms
.
toLowerCase
())
==
-
1
data
:
form
.
serialize
()
$
(
this
).
hide
()
complete
:
->
else
$
(
'.projects-list-holder'
).
css
(
"opacity"
,
'1.0'
)
$
(
this
).
show
()
success
:
(
data
)
->
$
(
'.projects-list-holder'
).
html
(
data
.
html
)
# Change url so if user reload a page - search results are saved
history
.
replaceState
{
page
:
project_filter_url
},
document
.
title
,
project_filter_url
dataType
:
"json"
uiBox
.
find
(
"ul.projects-list li.bottom"
).
hide
()
uiBox
.
find
(
"ul.projects-list li.bottom"
).
hide
()
app/controllers/application_controller.rb
View file @
7522ac0b
...
@@ -277,9 +277,10 @@ class ApplicationController < ActionController::Base
...
@@ -277,9 +277,10 @@ class ApplicationController < ActionController::Base
}
}
end
end
def
view_to_html_string
(
partial
)
def
view_to_html_string
(
partial
,
locals
=
nil
)
render_to_string
(
render_to_string
(
partial
,
partial:
partial
,
locals:
locals
,
layout:
false
,
layout:
false
,
formats:
[
:html
]
formats:
[
:html
]
)
)
...
...
app/controllers/dashboard/projects_controller.rb
View file @
7522ac0b
...
@@ -5,6 +5,13 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -5,6 +5,13 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
@projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
@projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
includes
(
:namespace
)
@projects
=
@projects
.
includes
(
:namespace
)
terms
=
params
[
'filter_projects'
]
if
terms
.
present?
@projects
=
@projects
.
search
(
terms
)
end
@projects
=
@projects
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@projects
=
@projects
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@last_push
=
current_user
.
recent_push
@last_push
=
current_user
.
recent_push
...
@@ -15,6 +22,11 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -15,6 +22,11 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
load_events
load_events
render
layout:
false
render
layout:
false
end
end
format
.
json
do
render
json:
{
html:
view_to_html_string
(
"dashboard/projects/projects"
,
locals:
{
projects:
@projects
})
}
end
end
end
end
end
...
...
app/controllers/explore/projects_controller.rb
View file @
7522ac0b
...
@@ -11,14 +11,14 @@ class Explore::ProjectsController < Explore::ApplicationController
...
@@ -11,14 +11,14 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
def
trending
def
trending
@
trending_
projects
=
TrendingProjectsFinder
.
new
.
execute
(
current_user
)
@projects
=
TrendingProjectsFinder
.
new
.
execute
(
current_user
)
@
trending_projects
=
@trending_
projects
.
non_archived
@
projects
=
@
projects
.
non_archived
@
trending_projects
=
@trending_
projects
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@
projects
=
@
projects
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
end
def
starred
def
starred
@
starred_
projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
@projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
@
starred_projects
=
@starred_
projects
.
reorder
(
'star_count DESC'
)
@
projects
=
@
projects
.
reorder
(
'star_count DESC'
)
@
starred_projects
=
@starred_
projects
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@
projects
=
@
projects
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
end
end
end
app/views/dashboard/_projects_head.html.haml
View file @
7522ac0b
...
@@ -13,9 +13,10 @@
...
@@ -13,9 +13,10 @@
Explore Projects
Explore Projects
.nav-controls
.nav-controls
=
search_field_tag
:filter_projects
,
nil
,
placeholder:
'Filter by name...'
,
class:
'projects-list-filter form-control hidden-xs input-short'
,
spellcheck:
false
=
form_tag
''
,
method: :get
,
class:
'project-list-form'
,
id:
'project-list-form'
do
|
f
|
=
render
'explore/projects/dropdown'
.append-right-10.hidden-xs.hidden-sm
-
if
current_user
.
can_create_project?
=
search_field_tag
:filter_projects
,
params
[
:filter_projects
],
placeholder:
'Filter by name...'
,
class:
'projects-list-filter form-control issue_search search-text-input'
,
spellcheck:
false
,
id:
'projects-list-filter'
=
link_to
new_project_path
,
class:
'btn btn-new'
do
-
if
current_user
.
can_create_project?
=
icon
(
'plus'
)
=
link_to
new_project_path
,
class:
'btn btn-new'
do
New Project
=
icon
(
'plus'
)
New Project
app/views/dashboard/projects/_projects.html.haml
View file @
7522ac0b
.projects-list-holder
.projects-list-holder
=
render
'shared/projects/list'
,
projects:
@projects
,
ci:
true
=
render
'shared/projects/list'
,
ci:
true
:javascript
new
ProjectsList
();
app/views/explore/projects/_projects.html.haml
View file @
7522ac0b
-
if
projects
.
any?
-
if
@
projects
.
any?
.public-projects
.public-projects
=
render
'shared/projects/list'
,
projects:
projects
=
render
'shared/projects/list'
-
else
-
else
.nothing-here-block
.nothing-here-block
No such projects
No such projects
app/views/explore/projects/starred.html.haml
View file @
7522ac0b
...
@@ -7,5 +7,5 @@
...
@@ -7,5 +7,5 @@
=
render
'explore/head'
=
render
'explore/head'
=
render
'explore/projects/nav'
=
render
'explore/projects/nav'
=
render
'projects'
,
projects:
@
starred_
projects
=
render
'projects'
,
projects:
@projects
=
paginate
@
starred_
projects
,
theme:
'gitlab'
=
paginate
@projects
,
theme:
'gitlab'
app/views/explore/projects/trending.html.haml
View file @
7522ac0b
...
@@ -7,4 +7,4 @@
...
@@ -7,4 +7,4 @@
=
render
'explore/head'
=
render
'explore/head'
=
render
'explore/projects/nav'
=
render
'explore/projects/nav'
=
render
'projects'
,
projects:
@
trending_
projects
=
render
'projects'
,
projects:
@projects
app/views/shared/projects/_list.html.haml
View file @
7522ac0b
...
@@ -8,18 +8,20 @@
...
@@ -8,18 +8,20 @@
-
show_last_commit_as_description
=
false
unless
local_assigns
[
:show_last_commit_as_description
]
==
true
-
show_last_commit_as_description
=
false
unless
local_assigns
[
:show_last_commit_as_description
]
==
true
%ul
.projects-list
%ul
.projects-list
-
projects
.
each_with_index
do
|
project
,
i
|
-
if
@projects
.
any?
-
css_class
=
(
i
>=
projects_limit
)
?
'hide'
:
nil
-
@projects
.
each_with_index
do
|
project
,
i
|
=
render
"shared/projects/project"
,
project:
project
,
skip_namespace:
skip_namespace
,
-
css_class
=
(
i
>=
projects_limit
)
?
'hide'
:
nil
avatar:
avatar
,
stars:
stars
,
css_class:
css_class
,
ci:
ci
,
use_creator_avatar:
use_creator_avatar
,
=
render
"shared/projects/project"
,
project:
project
,
skip_namespace:
skip_namespace
,
forks:
forks
,
show_last_commit_as_description:
show_last_commit_as_description
avatar:
avatar
,
stars:
stars
,
css_class:
css_class
,
ci:
ci
,
use_creator_avatar:
use_creator_avatar
,
forks:
forks
,
show_last_commit_as_description:
show_last_commit_as_description
-
if
projects
.
size
>
projects_limit
-
if
@projects
.
size
>
projects_limit
%li
.bottom.center
%li
.bottom.center
.light
.light
#{
projects_limit
}
of
#{
pluralize
(
projects
.
count
,
'project'
)
}
displayed.
#{
projects_limit
}
of
#{
pluralize
(
@projects
.
count
,
'project'
)
}
displayed.
=
link_to
'#'
,
class:
'js-expand'
do
=
link_to
'#'
,
class:
'js-expand'
do
Show all
Show all
=
paginate
@projects
,
theme:
"gitlab"
:javascript
-
else
new
ProjectsList
();
%h3
No projects found
%p
.slead
Try searching for a different project.
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