mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
added max of 20 files which can be uploaded at same time to client
This commit is contained in:
parent
69734c20c0
commit
a6aea41fb1
3 changed files with 21 additions and 2 deletions
|
@ -354,6 +354,9 @@ script(type='text/ng-template', id='newFolderModalTemplate')
|
|||
script(type="text/ng-template", id="uploadFileModalTemplate")
|
||||
.modal-header
|
||||
h3 #{translate("upload_files")}
|
||||
span
|
||||
.alert.alert-warning.small(ng-if="tooManyFiles") #{translate("maximum_files_uploaded_together", {max:"{{max_files}}"})}
|
||||
|
||||
.modal-body(
|
||||
fine-upload
|
||||
endpoint="/project/{{ project_id }}/upload"
|
||||
|
@ -365,6 +368,7 @@ script(type="text/ng-template", id="uploadFileModalTemplate")
|
|||
multiple="true"
|
||||
on-complete-callback="onComplete"
|
||||
on-upload-callback="onUpload"
|
||||
on-validate-batch="onValidateBatch"
|
||||
params="{'folder_id': parent_folder_id}"
|
||||
)
|
||||
span #{translate("upload_files")}
|
||||
|
|
|
@ -14,6 +14,7 @@ define [
|
|||
allowedExtensions: "="
|
||||
onCompleteCallback: "="
|
||||
onUploadCallback: "="
|
||||
onValidateBatch: "="
|
||||
params: "="
|
||||
}
|
||||
link: (scope, element, attrs) ->
|
||||
|
@ -33,10 +34,11 @@ define [
|
|||
|
||||
onComplete = scope.onCompleteCallback or () ->
|
||||
onUpload = scope.onUploadCallback or () ->
|
||||
onValidateBatch = scope.onValidateBatch or () ->
|
||||
params = scope.params or {}
|
||||
params._csrf = window.csrfToken
|
||||
|
||||
new qq.FineUploader
|
||||
q = new qq.FineUploader
|
||||
element: element[0]
|
||||
multiple: multiple
|
||||
disabledCancelForFormUploads: true
|
||||
|
@ -49,6 +51,7 @@ define [
|
|||
callbacks:
|
||||
onComplete: onComplete
|
||||
onUpload: onUpload
|
||||
onValidateBatch: onValidateBatch
|
||||
text: text
|
||||
template: """
|
||||
<div class="qq-uploader">
|
||||
|
@ -63,4 +66,5 @@ define [
|
|||
<ul class="qq-upload-list"></ul>
|
||||
</div>
|
||||
"""
|
||||
return q
|
||||
}
|
|
@ -102,11 +102,12 @@ define [
|
|||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder",
|
||||
($scope, ide, $modalInstance, $timeout, parent_folder) ->
|
||||
$scope.parent_folder_id = parent_folder?.id
|
||||
|
||||
$scope.tooManyFiles = false
|
||||
uploadCount = 0
|
||||
$scope.onUpload = () ->
|
||||
uploadCount++
|
||||
|
||||
$scope.max_files = 20
|
||||
$scope.onComplete = (error, name, response) ->
|
||||
$timeout (() ->
|
||||
uploadCount--
|
||||
|
@ -114,6 +115,16 @@ define [
|
|||
$modalInstance.close("done")
|
||||
), 250
|
||||
|
||||
$scope.onValidateBatch = (files)->
|
||||
if files.length > $scope.max_files
|
||||
$timeout (() ->
|
||||
$scope.tooManyFiles = true
|
||||
), 1
|
||||
return false
|
||||
else
|
||||
return true
|
||||
|
||||
|
||||
$scope.cancel = () ->
|
||||
$modalInstance.dismiss('cancel')
|
||||
]
|
Loading…
Reference in a new issue