diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-08-16 16:42:17 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-08-26 15:04:23 +0200 |
commit | eee7cbf5f2b285c33f08ac0139d3215ae45bd9eb (patch) | |
tree | 1aca1d4388d6cd1099f3968767ab3be34c71d4d5 /apps/files/js | |
parent | 60a5eb60593d504106df2937a86c761438ecad5e (diff) | |
download | nextcloud-server-eee7cbf5f2b285c33f08ac0139d3215ae45bd9eb.tar.gz nextcloud-server-eee7cbf5f2b285c33f08ac0139d3215ae45bd9eb.zip |
fix: Upload progress shows number of files to upload and current index
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/file-upload.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index a4058fd1ad5..61bd53eb35f 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -618,8 +618,10 @@ OC.Uploader.prototype = _.extend({ }); if (!self._uploading) { self.totalToUpload = 0; + self.totalUploadCount = 0; } self.totalToUpload += _.reduce(uploads, function(memo, upload) { return memo+upload.getFile().size; }, 0); + self.totalUploadCount += uploads.length; var semaphore = new OCA.Files.Semaphore(5); var promises = _.map(uploads, function(upload) { return semaphore.acquire().then(function(){ @@ -726,8 +728,9 @@ OC.Uploader.prototype = _.extend({ }, showUploadCancelMessage: _.debounce(function() { - OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'}); + OC.Notification.show(t('files', 'Upload cancelled.'), { timeout : 7000, type: 'error' }); }, 500), + /** * callback for the conflicts dialog */ @@ -1270,14 +1273,25 @@ OC.Uploader.prototype = _.extend({ smoothRemainingSeconds = bufferTotal / bufferSize; } - if (bufferIndex % 4 === 0) { + // the number of currently running uploads + const runningUploads = Object.keys(self._uploads).length; + + // Only show remaining time if enough buffer information is available and debounce to 1/4 + if (bufferFilled && bufferIndex % 4 === 0) { h = moment.duration(smoothRemainingSeconds, "seconds").humanize({m: 50, h: 50}); + if (self.totalUploadCount > 1) { + h = t('files', '{remainingTime} ({currentNumber}/{total})', { remainingTime: h, currentNumber: self.totalUploadCount - runningUploads + 1, total: self.totalUploadCount }); + } } - // wait for the buffer to be at least half filled, approximately takes 3s - if (!(smoothRemainingSeconds >= 0 && smoothRemainingSeconds < 14400) || (bufferFilled == false && bufferIndex < bufferSize/2)) { - // show "Uploading ..." for durations longer than 4 hours - h = t('files', 'Uploading …'); + // wait for the buffer to be filled and also show "Uploading ..." for durations longer than 4 hours + if (!bufferFilled || !(smoothRemainingSeconds >= 0 && smoothRemainingSeconds < 14400)) { + // Do not show file index when there is just one + if (self.totalUploadCount > 1) { + h = t('files', 'Uploading … ({currentNumber}/{total})', { currentNumber: self.totalUploadCount - runningUploads + 1, total: self.totalUploadCount }); + } else { + h = t('files', 'Uploading …'); + } } // smooth bitrate |