mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-25 11:14:05 +00:00
setProgress tweaking
This commit is contained in:
parent
0843c48549
commit
d81f8d8c1a
4 changed files with 36 additions and 29 deletions
|
|
@ -19,15 +19,15 @@ export default class Plugin {
|
|||
setProgress(percentage, current, total) {
|
||||
var finalPercentage = percentage;
|
||||
|
||||
if (current !== undefined && total !== undefined) {
|
||||
var percentageOfTotal = (percentage / total);
|
||||
finalPercentage = percentageOfTotal;
|
||||
if (current > 0) {
|
||||
finalPercentage = percentage + (100/total*current);
|
||||
} else {
|
||||
finalPercentage = (current * percentage);
|
||||
}
|
||||
}
|
||||
// if (current !== undefined && total !== undefined) {
|
||||
// var percentageOfTotal = (percentage / total);
|
||||
// // finalPercentage = percentageOfTotal;
|
||||
// if (current > 1) {
|
||||
// finalPercentage = percentage + (100 / (total * current));
|
||||
// } else {
|
||||
// finalPercentage = percentage;
|
||||
// }
|
||||
// }
|
||||
|
||||
this.core.setProgress(this, finalPercentage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,12 @@ export default class Tus10 extends Plugin {
|
|||
|
||||
this.setProgress(0);
|
||||
// var uploaded = [];
|
||||
var uploaders = [];
|
||||
for (var i in files) {
|
||||
var file = files[i];
|
||||
uploaders.push(this.upload(file, i, files.length));
|
||||
const uploaders = [];
|
||||
for (let i in files) {
|
||||
const file = files[i];
|
||||
const current = parseInt(i) + 1;
|
||||
const total = files.length;
|
||||
uploaders.push(this.upload(file, current, total));
|
||||
}
|
||||
|
||||
return Promise.all(uploaders);
|
||||
|
|
@ -42,7 +44,7 @@ export default class Tus10 extends Plugin {
|
|||
* @returns {Promise}
|
||||
*/
|
||||
upload(file, current, total) {
|
||||
console.log(current, 'of', total);
|
||||
console.log(`uploading ${current} of ${total}`);
|
||||
// Create a new tus upload
|
||||
const self = this;
|
||||
const upload = new tus.Upload(file, {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
# Uppy versions, auto updated by update.js
|
||||
uppy_version: 0.0.1
|
||||
|
||||
uppy_dev_size: "87.23"
|
||||
uppy_min_size: "87.23"
|
||||
uppy_gz_size: "87.23"
|
||||
uppy_dev_size: "87.22"
|
||||
uppy_min_size: "87.22"
|
||||
uppy_gz_size: "87.22"
|
||||
|
||||
# Theme
|
||||
google_analytics: UA-63083-12
|
||||
|
|
|
|||
|
|
@ -2285,7 +2285,10 @@ en_US.pluralize = function (n) {
|
|||
return 1;
|
||||
};
|
||||
|
||||
Uppy.locale.en_US = en_US;
|
||||
if (typeof Uppy !== 'undefined') {
|
||||
Uppy.locale.en_US = en_US;
|
||||
}
|
||||
|
||||
exports['default'] = en_US;
|
||||
module.exports = exports['default'];
|
||||
|
||||
|
|
@ -2855,15 +2858,15 @@ var Plugin = (function () {
|
|||
value: function setProgress(percentage, current, total) {
|
||||
var finalPercentage = percentage;
|
||||
|
||||
if (current !== undefined && total !== undefined) {
|
||||
var percentageOfTotal = percentage / total;
|
||||
finalPercentage = percentageOfTotal;
|
||||
if (current > 0) {
|
||||
finalPercentage = percentage + 100 / total * current;
|
||||
} else {
|
||||
finalPercentage = current * percentage;
|
||||
}
|
||||
}
|
||||
// if (current !== undefined && total !== undefined) {
|
||||
// var percentageOfTotal = (percentage / total);
|
||||
// // finalPercentage = percentageOfTotal;
|
||||
// if (current > 1) {
|
||||
// finalPercentage = percentage + (100 / (total * current));
|
||||
// } else {
|
||||
// finalPercentage = percentage;
|
||||
// }
|
||||
// }
|
||||
|
||||
this.core.setProgress(this, finalPercentage);
|
||||
}
|
||||
|
|
@ -2996,7 +2999,9 @@ var Tus10 = (function (_Plugin) {
|
|||
var uploaders = [];
|
||||
for (var i in files) {
|
||||
var file = files[i];
|
||||
uploaders.push(this.upload(file, i, files.length));
|
||||
var current = parseInt(i) + 1;
|
||||
var total = files.length;
|
||||
uploaders.push(this.upload(file, current, total));
|
||||
}
|
||||
|
||||
return Promise.all(uploaders);
|
||||
|
|
@ -3013,7 +3018,7 @@ var Tus10 = (function (_Plugin) {
|
|||
}, {
|
||||
key: 'upload',
|
||||
value: function upload(file, current, total) {
|
||||
console.log(current, 'of', total);
|
||||
console.log('uploading ' + current + ' of ' + total);
|
||||
// Create a new tus upload
|
||||
var self = this;
|
||||
var upload = new _tusJsClient2['default'].Upload(file, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue