mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 10:32:19 -05:00
Update labels when docs are uploaded or removed
This commit is contained in:
parent
feb1d87de1
commit
ff7955dfdb
6 changed files with 20 additions and 27 deletions
|
@ -20,7 +20,7 @@ module.exports = LabelsController =
|
||||||
if err?
|
if err?
|
||||||
logger.err {project_id, doc_id, err}, "[LabelsController] error getting labels from doc"
|
logger.err {project_id, doc_id, err}, "[LabelsController] error getting labels from doc"
|
||||||
return next(err)
|
return next(err)
|
||||||
EditorRealTimeController.emitToRoom project_id, 'doc:labels:updated', {
|
EditorRealTimeController.emitToRoom project_id, 'docLabelsUpdated', {
|
||||||
docId: doc_id, labels: docLabels
|
docId: doc_id, labels: docLabels
|
||||||
}
|
}
|
||||||
res.json {projectId: project_id, docId: doc_id, labels: docLabels}
|
res.json {projectId: project_id, docId: doc_id, labels: docLabels}
|
||||||
|
|
|
@ -51,3 +51,4 @@ module.exports = ProjectUploadController =
|
||||||
project_id: project_id, file_path: path, file_name: name, folder_id: folder_id
|
project_id: project_id, file_path: path, file_name: name, folder_id: folder_id
|
||||||
"uploaded file"
|
"uploaded file"
|
||||||
res.send success: true, entity_id: entity?._id
|
res.send success: true, entity_id: entity?._id
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ define [
|
||||||
# User can append ?ft=somefeature to url to activate a feature toggle
|
# User can append ?ft=somefeature to url to activate a feature toggle
|
||||||
ide.featureToggle = location?.search?.match(/^\?ft=(\w+)$/)?[1]
|
ide.featureToggle = location?.search?.match(/^\?ft=(\w+)$/)?[1]
|
||||||
|
|
||||||
ide.socket.on 'doc:labels:updated', (data) ->
|
ide.socket.on 'docLabelsUpdated', (data) ->
|
||||||
$scope.$broadcast 'doc:labels:updated', data
|
$scope.$broadcast 'doc:labels:updated', data
|
||||||
|
|
||||||
angular.bootstrap(document.body, ["SharelatexApp"])
|
angular.bootstrap(document.body, ["SharelatexApp"])
|
||||||
|
|
|
@ -27,6 +27,13 @@ define [
|
||||||
if data.docId and data.labels
|
if data.docId and data.labels
|
||||||
@state.documents[data.docId] = data.labels
|
@state.documents[data.docId] = data.labels
|
||||||
|
|
||||||
|
@$scope.$on 'entity:deleted', (e, entity) =>
|
||||||
|
if entity.type == 'doc'
|
||||||
|
delete @state.documents[entity.id]
|
||||||
|
|
||||||
|
@$scope.$on 'file:upload:complete', (e, entityId) =>
|
||||||
|
@loadDocLabelsFromServer(entityId)
|
||||||
|
|
||||||
onChange = (change) =>
|
onChange = (change) =>
|
||||||
if change.remote
|
if change.remote
|
||||||
return
|
return
|
||||||
|
@ -66,34 +73,17 @@ define [
|
||||||
)
|
)
|
||||||
|
|
||||||
loadCurrentDocLabelsFromServer: () ->
|
loadCurrentDocLabelsFromServer: () ->
|
||||||
|
currentDocId = @$scope.docId
|
||||||
|
@loadDocLabelsFromServer(currentDocId)
|
||||||
|
|
||||||
|
loadDocLabelsFromServer: (docId) ->
|
||||||
$.get(
|
$.get(
|
||||||
"/project/#{window.project_id}/#{@$scope.docId}/labels"
|
"/project/#{window.project_id}/#{docId}/labels"
|
||||||
, (data) =>
|
, (data) =>
|
||||||
if data.docId and data.labels
|
if data.docId and data.labels
|
||||||
@state.documents[data.docId] = data.labels
|
@state.documents[data.docId] = data.labels
|
||||||
)
|
)
|
||||||
|
|
||||||
# loadLabelsFromOpenDoc: () ->
|
|
||||||
# docId = @$scope.docId
|
|
||||||
# docText = @editor.getValue()
|
|
||||||
# labels = []
|
|
||||||
# re = /\\label\{([^\}\n\\]{0,80})\}/g
|
|
||||||
# while (labelMatch = re.exec(docText)) and labels.length < 1000
|
|
||||||
# if labelMatch[1]
|
|
||||||
# labels.push(labelMatch[1])
|
|
||||||
# @state.documents[docId] = labels
|
|
||||||
|
|
||||||
# scheduleLoadLabelsFromOpenDoc: () ->
|
|
||||||
# # De-bounce loading labels with a timeout
|
|
||||||
# if @loadLabelsTimeout
|
|
||||||
# clearTimeout(@loadLabelsTimeout)
|
|
||||||
# @loadLabelsTimeout = setTimeout(
|
|
||||||
# () =>
|
|
||||||
# @loadLabelsFromOpenDoc()
|
|
||||||
# , 1000
|
|
||||||
# , this
|
|
||||||
# )
|
|
||||||
|
|
||||||
scheduleLoadCurrentDocLabelsFromServer: () ->
|
scheduleLoadCurrentDocLabelsFromServer: () ->
|
||||||
# De-bounce loading labels with a timeout
|
# De-bounce loading labels with a timeout
|
||||||
if @loadLabelsTimeout
|
if @loadLabelsTimeout
|
||||||
|
|
|
@ -71,7 +71,7 @@ define [
|
||||||
@$scope.$apply () =>
|
@$scope.$apply () =>
|
||||||
@_deleteEntityFromScope entity
|
@_deleteEntityFromScope entity
|
||||||
@recalculateDocList()
|
@recalculateDocList()
|
||||||
@$scope.$emit "entity:deleted", entity
|
@$scope.$broadcast "entity:deleted", entity
|
||||||
|
|
||||||
@ide.socket.on "reciveEntityMove", (entity_id, folder_id) =>
|
@ide.socket.on "reciveEntityMove", (entity_id, folder_id) =>
|
||||||
entity = @findEntityById(entity_id)
|
entity = @findEntityById(entity_id)
|
||||||
|
|
|
@ -107,8 +107,8 @@ define [
|
||||||
]
|
]
|
||||||
|
|
||||||
App.controller "UploadFileModalController", [
|
App.controller "UploadFileModalController", [
|
||||||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder", "$window"
|
"$scope", "$rootScope", "ide", "$modalInstance", "$timeout", "parent_folder", "$window"
|
||||||
($scope, ide, $modalInstance, $timeout, parent_folder, $window) ->
|
($scope, $rootScope, ide, $modalInstance, $timeout, parent_folder, $window) ->
|
||||||
$scope.parent_folder_id = parent_folder?.id
|
$scope.parent_folder_id = parent_folder?.id
|
||||||
$scope.tooManyFiles = false
|
$scope.tooManyFiles = false
|
||||||
$scope.rateLimitHit = false
|
$scope.rateLimitHit = false
|
||||||
|
@ -134,6 +134,8 @@ define [
|
||||||
$scope.onComplete = (error, name, response) ->
|
$scope.onComplete = (error, name, response) ->
|
||||||
$timeout (() ->
|
$timeout (() ->
|
||||||
uploadCount--
|
uploadCount--
|
||||||
|
if response.success
|
||||||
|
$rootScope.$broadcast 'file:upload:complete', response.entity_id
|
||||||
if uploadCount == 0 and response? and response.success
|
if uploadCount == 0 and response? and response.success
|
||||||
$modalInstance.close("done")
|
$modalInstance.close("done")
|
||||||
), 250
|
), 250
|
||||||
|
|
Loading…
Reference in a new issue