mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add an endpoint to get users projects as json
This commit is contained in:
parent
87fb226c3e
commit
4925bfe536
3 changed files with 23 additions and 1 deletions
|
@ -138,6 +138,19 @@ module.exports = ProjectController =
|
||||||
return next(err) if err?
|
return next(err) if err?
|
||||||
res.sendStatus 200
|
res.sendStatus 200
|
||||||
|
|
||||||
|
projectsJson: (req, res, next) ->
|
||||||
|
user_id = AuthenticationController.getLoggedInUserId(req)
|
||||||
|
|
||||||
|
ProjectGetter.findAllUsersProjects user_id,
|
||||||
|
'name lastUpdated publicAccesLevel archived owner_ref tokens', (err, projects) ->
|
||||||
|
return next(err) if err?
|
||||||
|
projects = ProjectController._buildProjectList(projects)
|
||||||
|
.filter((p) -> !p.archived)
|
||||||
|
.filter((p) -> !p.isV1Project)
|
||||||
|
.map((p) -> {_id: p.id, name: p.name, accessLevel: p.accessLevel})
|
||||||
|
|
||||||
|
res.json({projects: projects})
|
||||||
|
|
||||||
projectListPage: (req, res, next)->
|
projectListPage: (req, res, next)->
|
||||||
timer = new metrics.Timer("project-list")
|
timer = new metrics.Timer("project-list")
|
||||||
user_id = AuthenticationController.getLoggedInUserId(req)
|
user_id = AuthenticationController.getLoggedInUserId(req)
|
||||||
|
|
|
@ -118,6 +118,7 @@ module.exports = class Router
|
||||||
webRouter.get '/user/personal_info', AuthenticationController.requireLogin(), UserInfoController.getLoggedInUsersPersonalInfo
|
webRouter.get '/user/personal_info', AuthenticationController.requireLogin(), UserInfoController.getLoggedInUsersPersonalInfo
|
||||||
privateApiRouter.get '/user/:user_id/personal_info', AuthenticationController.httpAuth, UserInfoController.getPersonalInfo
|
privateApiRouter.get '/user/:user_id/personal_info', AuthenticationController.httpAuth, UserInfoController.getPersonalInfo
|
||||||
|
|
||||||
|
webRouter.get '/user/projects', AuthenticationController.requireLogin(), ProjectController.projectsJson
|
||||||
webRouter.get '/project', AuthenticationController.requireLogin(), ProjectController.projectListPage
|
webRouter.get '/project', AuthenticationController.requireLogin(), ProjectController.projectListPage
|
||||||
webRouter.post '/project/new', AuthenticationController.requireLogin(), ProjectController.newProject
|
webRouter.post '/project/new', AuthenticationController.requireLogin(), ProjectController.newProject
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,9 @@ define [
|
||||||
$(document).on "click", =>
|
$(document).on "click", =>
|
||||||
@clearMultiSelectedEntities()
|
@clearMultiSelectedEntities()
|
||||||
@$scope.$digest()
|
@$scope.$digest()
|
||||||
window.doLinkedFileImportFromProject = (project, path, name) =>
|
|
||||||
|
# TODO: remove
|
||||||
|
window._doLinkedFileImportFromProject = (project, path, name) =>
|
||||||
parent_folder = @getCurrentFolder()
|
parent_folder = @getCurrentFolder()
|
||||||
@ide.$http.post "/project/#{@ide.project_id}/linked_file", {
|
@ide.$http.post "/project/#{@ide.project_id}/linked_file", {
|
||||||
name: name,
|
name: name,
|
||||||
|
@ -38,6 +40,12 @@ define [
|
||||||
_csrf: window.csrfToken
|
_csrf: window.csrfToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: remove
|
||||||
|
window._getProjects = () =>
|
||||||
|
@ide.$http.get "/user/projects", {
|
||||||
|
_csrf: window.csrfToken
|
||||||
|
}
|
||||||
|
|
||||||
_bindToSocketEvents: () ->
|
_bindToSocketEvents: () ->
|
||||||
@ide.socket.on "reciveNewDoc", (parent_folder_id, doc) =>
|
@ide.socket.on "reciveNewDoc", (parent_folder_id, doc) =>
|
||||||
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
||||||
|
|
Loading…
Reference in a new issue