mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Fetch the list of keys from references index.
This commit is contained in:
parent
c9db11edbe
commit
8c9c476dd7
4 changed files with 50 additions and 4 deletions
|
@ -27,5 +27,14 @@ module.exports = ReferencesSearchController =
|
|||
|
||||
res.send 200
|
||||
|
||||
getKeys: (req, res) ->
|
||||
project_id = req.params.Project_id
|
||||
logger.log {project_id}, "getting project references keys"
|
||||
ReferencesSearchHandler.getKeys project_id, (err, data) ->
|
||||
if err
|
||||
logger.err {err, project_id}, "error getting references keys"
|
||||
return res.send 500
|
||||
return res.json data
|
||||
|
||||
_buildDocUrl: (project_id, doc_id) ->
|
||||
"#{settings.apis.web.url}/project/#{project_id}/doc/#{doc_id}"
|
||||
|
|
|
@ -24,3 +24,19 @@ module.exports = ReferencesSearchHandler =
|
|||
err = new Error("references api responded with non-success code: #{res.statusCode}")
|
||||
logger.log {err, project_id, file_url}, "error updating references"
|
||||
return callback(err)
|
||||
|
||||
getKeys: (project_id, callback = (err, result)->) ->
|
||||
logger.log {project_id}, "getting keys from remote references api"
|
||||
url = "#{settings.apis.references.url}/project/#{project_id}/keys"
|
||||
request.get {
|
||||
url: url
|
||||
json: true
|
||||
}, (err, res, result) ->
|
||||
if err
|
||||
return callback(err)
|
||||
if 200 <= res.statusCode < 300
|
||||
return callback(null, result)
|
||||
else
|
||||
err = new Error("references api responded with non-success code: #{res.statusCode}")
|
||||
logger.log {err, project_id, file_url}, "error getting references keys"
|
||||
return callback(err)
|
||||
|
|
|
@ -172,6 +172,7 @@ module.exports = class Router
|
|||
webRouter.get /learn(\/.*)?/, WikiController.getPage
|
||||
|
||||
webRouter.post "/project/:Project_id/references", SecurityManager.requestCanAccessProject, ReferencesSearchController.indexFile
|
||||
webRouter.get "/project/:Project_id/references/keys", SecurityManager.requestCanAccessProject, ReferencesSearchController.getKeys
|
||||
|
||||
#Admin Stuff
|
||||
webRouter.get '/admin', SecurityManager.requestIsAdmin, AdminController.index
|
||||
|
|
|
@ -14,7 +14,27 @@ define [
|
|||
|
||||
indexReferences: (doc_id) ->
|
||||
console.log ">> doc id #{doc_id}"
|
||||
$.post("/project/#{@$scope.project_id}/references", {
|
||||
$.post(
|
||||
"/project/#{@$scope.project_id}/references",
|
||||
{
|
||||
docId: doc_id,
|
||||
_csrf: window.csrfToken
|
||||
}, (data) => console.log(data))
|
||||
},
|
||||
(data) =>
|
||||
console.log(data)
|
||||
setTimeout(
|
||||
( () -> @getReferenceKeys() ).bind(this),
|
||||
100
|
||||
)
|
||||
)
|
||||
|
||||
getReferenceKeys: () ->
|
||||
$.get(
|
||||
"/project/#{@$scope.project_id}/references/keys",
|
||||
{
|
||||
_csrf: window.csrfToken
|
||||
},
|
||||
(data) =>
|
||||
console.log ">> got keys"
|
||||
console.log(data)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue