Basic bulk accept support.

This commit is contained in:
Paulo Reis 2017-05-04 15:33:47 +01:00
parent 6662ec34ae
commit 19828d3c5b
3 changed files with 22 additions and 4 deletions

View file

@ -153,6 +153,25 @@ module.exports = DocumentUpdaterHandler =
logger.error {project_id, doc_id, change_id}, "doc updater returned a non-success status code: #{res.statusCode}"
callback new Error("doc updater returned a non-success status code: #{res.statusCode}")
bulkAcceptChanges: (project_id, doc_id, change_ids, callback = (error) ->) ->
timer = new metrics.Timer("bulk-accept-changes")
reqSettings =
url: "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/accept"
json:
change_ids: change_ids
logger.log {project_id, doc_id }, "bulk accepting #{ change_ids.length } changes"
request.post reqSettings, (error, res, body)->
timer.done()
if error?
logger.error {err:error, project_id, doc_id }, "error accepting #{ change_ids.length } changes in doc updater"
return callback(error)
if res.statusCode >= 200 and res.statusCode < 300
logger.log {project_id, doc_id }, "accepted #{ change_ids.length } changes in document updater"
return callback(null)
else
logger.error {project_id, doc_id }, "doc updater returned a non-success status code: #{res.statusCode}"
callback new Error("doc updater returned a non-success status code: #{res.statusCode}")
deleteThread: (project_id, doc_id, thread_id, callback = (error) ->) ->
timer = new metrics.Timer("delete-thread")
url = "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/comment/#{thread_id}"

View file

@ -32,9 +32,6 @@ define [
@$scope.$on "change:reject", (e, change_id) =>
@rejectChangeId(change_id)
@$scope.$on "change:bulk-accept", (e, change_ids) =>
@bulkAcceptChangeIds(change_ids)
@$scope.$on "change:bulk-reject", (e, change_ids) =>
@bulkRejectChangeIds(change_ids)

View file

@ -328,7 +328,9 @@ define [
event_tracking.sendMB "rp-change-rejected", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' }
$scope.bulkAccept = () ->
$scope.$broadcast "change:bulk-accept", $scope.reviewPanel.selectedEntryIds.slice()
entry_ids = $scope.reviewPanel.selectedEntryIds.slice()
$http.post "/project/#{$scope.project_id}/doc/#{$scope.editor.open_doc_id}/changes/accept", { change_ids: entry_ids, _csrf: window.csrfToken}
$scope.$broadcast "change:bulk-accept", entry_ids
$scope.reviewPanel.selectedEntryIds = []
event_tracking.sendMB "rp-bulk-accept", {
view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini',