Commit 1297d5bf authored by Marin Jankovski's avatar Marin Jankovski

Add projects search query for api and js api.

parent 859628ed
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
ldap_groups_path: "/api/:version/ldap/:provider/groups.json" ldap_groups_path: "/api/:version/ldap/:provider/groups.json"
namespaces_path: "/api/:version/namespaces.json" namespaces_path: "/api/:version/namespaces.json"
project_users_path: "/api/:version/projects/:id/users.json" project_users_path: "/api/:version/projects/:id/users.json"
projects_path: "/api/:version/projects.json"
# Get 20 (depends on api) recent notes # Get 20 (depends on api) recent notes
# and sort the ascending from oldest to newest # and sort the ascending from oldest to newest
...@@ -132,3 +133,17 @@ ...@@ -132,3 +133,17 @@
dataType: "json" dataType: "json"
).done (groups) -> ).done (groups) ->
callback(groups) callback(groups)
# Return projects list. Filtered by query
projects: (query, callback) ->
project_url = Api.buildUrl(Api.projects_path)
project_query = $.ajax(
url: project_url
data:
private_token: gon.api_token
search: query
per_page: 20
dataType: "json"
).done (projects) ->
callback(projects)
...@@ -28,6 +28,10 @@ module API ...@@ -28,6 +28,10 @@ module API
@projects = @projects.where(archived: parse_boolean(params[:archived])) @projects = @projects.where(archived: parse_boolean(params[:archived]))
end end
if params[:search].present?
@projects = @projects.search(params[:search])
end
@projects = paginate @projects @projects = paginate @projects
present @projects, with: Entities::Project present @projects, with: Entities::Project
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment