2013-03-20 15:55:25 -04:00
|
|
|
@Api =
|
|
|
|
users_path: "/api/:version/users.json"
|
|
|
|
user_path: "/api/:version/users/:id.json"
|
|
|
|
notes_path: "/api/:version/projects/:id/notes.json"
|
2013-11-15 08:25:09 -05:00
|
|
|
namespaces_path: "/api/:version/namespaces.json"
|
2014-02-13 09:08:26 -05:00
|
|
|
project_users_path: "/api/:version/projects/:id/users.json"
|
2013-03-20 15:55:25 -04:00
|
|
|
|
2013-10-01 08:15:28 -04:00
|
|
|
# Get 20 (depends on api) recent notes
|
2013-03-20 15:55:25 -04:00
|
|
|
# and sort the ascending from oldest to newest
|
|
|
|
notes: (project_id, callback) ->
|
|
|
|
url = Api.buildUrl(Api.notes_path)
|
|
|
|
url = url.replace(':id', project_id)
|
2013-10-01 08:15:28 -04:00
|
|
|
|
2013-03-20 15:55:25 -04:00
|
|
|
$.ajax(
|
|
|
|
url: url,
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
gfm: true
|
|
|
|
recent: true
|
|
|
|
dataType: "json"
|
|
|
|
).done (notes) ->
|
|
|
|
notes.sort (a, b) ->
|
|
|
|
return a.id - b.id
|
|
|
|
callback(notes)
|
|
|
|
|
|
|
|
user: (user_id, callback) ->
|
|
|
|
url = Api.buildUrl(Api.user_path)
|
|
|
|
url = url.replace(':id', user_id)
|
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
dataType: "json"
|
|
|
|
).done (user) ->
|
|
|
|
callback(user)
|
|
|
|
|
|
|
|
# Return users list. Filtered by query
|
|
|
|
# Only active users retrieved
|
|
|
|
users: (query, callback) ->
|
|
|
|
url = Api.buildUrl(Api.users_path)
|
2013-10-01 08:15:28 -04:00
|
|
|
|
2013-03-20 15:55:25 -04:00
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
active: true
|
|
|
|
dataType: "json"
|
|
|
|
).done (users) ->
|
|
|
|
callback(users)
|
|
|
|
|
2014-02-13 09:08:26 -05:00
|
|
|
# Return project users list. Filtered by query
|
|
|
|
# Only active users retrieved
|
|
|
|
projectUsers: (project_id, query, callback) ->
|
|
|
|
url = Api.buildUrl(Api.project_users_path)
|
|
|
|
url = url.replace(':id', project_id)
|
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
active: true
|
|
|
|
dataType: "json"
|
|
|
|
).done (users) ->
|
|
|
|
callback(users)
|
|
|
|
|
2013-11-15 08:25:09 -05:00
|
|
|
# Return namespaces list. Filtered by query
|
|
|
|
namespaces: (query, callback) ->
|
|
|
|
url = Api.buildUrl(Api.namespaces_path)
|
|
|
|
|
|
|
|
$.ajax(
|
|
|
|
url: url
|
|
|
|
data:
|
|
|
|
private_token: gon.api_token
|
|
|
|
search: query
|
|
|
|
per_page: 20
|
|
|
|
dataType: "json"
|
|
|
|
).done (namespaces) ->
|
|
|
|
callback(namespaces)
|
|
|
|
|
2013-03-20 15:55:25 -04:00
|
|
|
buildUrl: (url) ->
|
2013-06-12 23:44:25 -04:00
|
|
|
url = gon.relative_url_root + url if gon.relative_url_root?
|
2013-03-20 15:55:25 -04:00
|
|
|
return url.replace(':version', gon.api_version)
|