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")
|
script(type="text/ng-template", id="uploadFileModalTemplate")
|
||||||
.modal-header
|
.modal-header
|
||||||
h3 #{translate("upload_files")}
|
h3 #{translate("upload_files")}
|
||||||
|
span
|
||||||
|
.alert.alert-warning.small(ng-if="tooManyFiles") #{translate("maximum_files_uploaded_together", {max:"{{max_files}}"})}
|
||||||
|
|
||||||
.modal-body(
|
.modal-body(
|
||||||
fine-upload
|
fine-upload
|
||||||
endpoint="/project/{{ project_id }}/upload"
|
endpoint="/project/{{ project_id }}/upload"
|
||||||
|
@ -365,6 +368,7 @@ script(type="text/ng-template", id="uploadFileModalTemplate")
|
||||||
multiple="true"
|
multiple="true"
|
||||||
on-complete-callback="onComplete"
|
on-complete-callback="onComplete"
|
||||||
on-upload-callback="onUpload"
|
on-upload-callback="onUpload"
|
||||||
|
on-validate-batch="onValidateBatch"
|
||||||
params="{'folder_id': parent_folder_id}"
|
params="{'folder_id': parent_folder_id}"
|
||||||
)
|
)
|
||||||
span #{translate("upload_files")}
|
span #{translate("upload_files")}
|
||||||
|
|
|
@ -14,6 +14,7 @@ define [
|
||||||
allowedExtensions: "="
|
allowedExtensions: "="
|
||||||
onCompleteCallback: "="
|
onCompleteCallback: "="
|
||||||
onUploadCallback: "="
|
onUploadCallback: "="
|
||||||
|
onValidateBatch: "="
|
||||||
params: "="
|
params: "="
|
||||||
}
|
}
|
||||||
link: (scope, element, attrs) ->
|
link: (scope, element, attrs) ->
|
||||||
|
@ -33,10 +34,11 @@ define [
|
||||||
|
|
||||||
onComplete = scope.onCompleteCallback or () ->
|
onComplete = scope.onCompleteCallback or () ->
|
||||||
onUpload = scope.onUploadCallback or () ->
|
onUpload = scope.onUploadCallback or () ->
|
||||||
|
onValidateBatch = scope.onValidateBatch or () ->
|
||||||
params = scope.params or {}
|
params = scope.params or {}
|
||||||
params._csrf = window.csrfToken
|
params._csrf = window.csrfToken
|
||||||
|
|
||||||
new qq.FineUploader
|
q = new qq.FineUploader
|
||||||
element: element[0]
|
element: element[0]
|
||||||
multiple: multiple
|
multiple: multiple
|
||||||
disabledCancelForFormUploads: true
|
disabledCancelForFormUploads: true
|
||||||
|
@ -49,6 +51,7 @@ define [
|
||||||
callbacks:
|
callbacks:
|
||||||
onComplete: onComplete
|
onComplete: onComplete
|
||||||
onUpload: onUpload
|
onUpload: onUpload
|
||||||
|
onValidateBatch: onValidateBatch
|
||||||
text: text
|
text: text
|
||||||
template: """
|
template: """
|
||||||
<div class="qq-uploader">
|
<div class="qq-uploader">
|
||||||
|
@ -63,4 +66,5 @@ define [
|
||||||
<ul class="qq-upload-list"></ul>
|
<ul class="qq-upload-list"></ul>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
return q
|
||||||
}
|
}
|
|
@ -102,11 +102,12 @@ define [
|
||||||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder",
|
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder",
|
||||||
($scope, ide, $modalInstance, $timeout, parent_folder) ->
|
($scope, ide, $modalInstance, $timeout, parent_folder) ->
|
||||||
$scope.parent_folder_id = parent_folder?.id
|
$scope.parent_folder_id = parent_folder?.id
|
||||||
|
$scope.tooManyFiles = false
|
||||||
uploadCount = 0
|
uploadCount = 0
|
||||||
$scope.onUpload = () ->
|
$scope.onUpload = () ->
|
||||||
uploadCount++
|
uploadCount++
|
||||||
|
|
||||||
|
$scope.max_files = 20
|
||||||
$scope.onComplete = (error, name, response) ->
|
$scope.onComplete = (error, name, response) ->
|
||||||
$timeout (() ->
|
$timeout (() ->
|
||||||
uploadCount--
|
uploadCount--
|
||||||
|
@ -114,6 +115,16 @@ define [
|
||||||
$modalInstance.close("done")
|
$modalInstance.close("done")
|
||||||
), 250
|
), 250
|
||||||
|
|
||||||
|
$scope.onValidateBatch = (files)->
|
||||||
|
if files.length > $scope.max_files
|
||||||
|
$timeout (() ->
|
||||||
|
$scope.tooManyFiles = true
|
||||||
|
), 1
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
$scope.cancel = () ->
|
$scope.cancel = () ->
|
||||||
$modalInstance.dismiss('cancel')
|
$modalInstance.dismiss('cancel')
|
||||||
]
|
]
|
Loading…
Reference in a new issue