summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-09-07 16:43:16 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-09-26 17:46:43 +0200
commit1ee3c31f855eb03a2a6ff8daf0740cb5d44bcf3d (patch)
treefa2e21b3b67d1ec05ecaf9713386270599fb4690 /apps
parentf6787944709f333c5cf9c9b72ed0388c30f16066 (diff)
downloadnextcloud-server-1ee3c31f855eb03a2a6ff8daf0740cb5d44bcf3d.tar.gz
nextcloud-server-1ee3c31f855eb03a2a6ff8daf0740cb5d44bcf3d.zip
Do not hide the progress bar while the chunked upload is being assembled
Large files are not uploaded in a single operation, but uploaded in several chunks; once all the chunks are uploaded then the server needs to assemble them to get the final file. Before, once the chunks were uploaded the progress bar was hidden. However, this was confusing for the users, as the file could still need some time to appear in the file list due to the assembling. Now once all the chunks are uploaded the text in the progress bar changes to inform the user that there are still some pending operations, and only when the file is finally assembled the progress bar is hidden. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/file-upload.js49
1 files changed, 48 insertions, 1 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index fac086c3da8..9c1e2df53a0 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -402,6 +402,13 @@ OC.Uploader.prototype = _.extend({
_uploads: {},
/**
+ * Count of upload done promises that have not finished yet.
+ *
+ * @type int
+ */
+ _pendingUploadDoneCount: 0,
+
+ /**
* List of directories known to exist.
*
* Key is the fullpath and value is boolean, true meaning that the directory
@@ -745,6 +752,27 @@ OC.Uploader.prototype = _.extend({
});
},
+ _updateProgressBarOnUploadStop: function() {
+ if (this._pendingUploadDoneCount === 0) {
+ // All the uploads ended and there is no pending operation, so hide
+ // the progress bar.
+ // Note that this happens here only with non-chunked uploads; if the
+ // upload was chunked then this will have been executed after all
+ // the uploads ended but before the upload done handler that reduces
+ // the pending operation count was executed.
+ this._hideProgressBar();
+
+ return;
+ }
+
+ $('#uploadprogressbar .label .mobile').text(t('core', '…'));
+ $('#uploadprogressbar .label .desktop').text(t('core', 'Processing files …'));
+
+ // Nothing is being uploaded at this point, and the pending operations
+ // can not be cancelled, so the cancel button should be hidden.
+ $('#uploadprogresswrapper .stop').fadeOut();
+ },
+
_showProgressBar: function() {
$('#uploadprogressbar').fadeIn();
this.$uploadEl.trigger(new $.Event('resized'));
@@ -1126,7 +1154,7 @@ OC.Uploader.prototype = _.extend({
self.log('progress handle fileuploadstop', e, data);
self.clear();
- self._hideProgressBar();
+ self._updateProgressBarOnUploadStop();
self.trigger('stop', e, data);
});
fileupload.on('fileuploadfail', function(e, data) {
@@ -1194,7 +1222,26 @@ OC.Uploader.prototype = _.extend({
});
fileupload.on('fileuploaddone', function(e, data) {
var upload = self.getUpload(data);
+
+ self._pendingUploadDoneCount++;
+
upload.done().then(function() {
+ self._pendingUploadDoneCount--;
+ if (Object.keys(self._uploads).length === 0 && self._pendingUploadDoneCount === 0) {
+ // All the uploads ended and there is no pending
+ // operation, so hide the progress bar.
+ // Note that this happens here only with chunked
+ // uploads; if the upload was non-chunked then this
+ // handler is immediately executed, before the
+ // jQuery upload done handler that removes the
+ // upload from the list, and thus at this point
+ // there is still at least one upload that has not
+ // ended (although the upload stop handler is always
+ // executed after all the uploads have ended, which
+ // hides the progress bar in that case).
+ self._hideProgressBar();
+ }
+
self.trigger('done', e, upload);
}).fail(function(status, response) {
var message = response.message;