r77098 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77097‎ | r77098 | r77099 >
Date:05:57, 22 November 2010
Author:neilk
Status:deferred
Tags:
Comment:
group progress bar correctly tracks successful / unsuccessful uploads
Modified paths:
  • /trunk/extensions/UploadWizard/resources/combined.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/combined.min.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.GroupProgressBar.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.GroupProgressBar.js
@@ -1,7 +1,7 @@
22 /**
33 * this is a progress bar for monitoring multiple objects, giving summary view
44 */
5 -mw.GroupProgressBar = function( selector, text, uploads, endStates, progressProperty, weightProperty ) {
 5+mw.GroupProgressBar = function( selector, text, uploads, successStates, errorStates, progressProperty, weightProperty ) {
66 var _this = this;
77
88 // XXX need to figure out a way to put text inside bar
@@ -21,7 +21,8 @@
2222 _this.$selector.find( '.mwe-upwiz-progress-bar' ).progressbar( { value : 0 } );
2323
2424 _this.uploads = uploads;
25 - _this.endStates = endStates;
 25+ _this.successStates = successStates;
 26+ _this.errorStates = errorStates;
2627 _this.progressProperty = progressProperty;
2728 _this.weightProperty = weightProperty;
2829 _this.beginTime = undefined;
@@ -31,7 +32,7 @@
3233 mw.GroupProgressBar.prototype = {
3334
3435 /**
35 - * Show the progress bar with a slideout motion
 36+ * Show the progress bar
3637 */
3738 showBar: function() {
3839 this.$selector.find( '.mwe-upwiz-progress-bar-etr' ).fadeIn( 200 );
@@ -53,12 +54,16 @@
5455
5556 var displayer = function() {
5657 var fraction = 0.0;
57 - var endStateCount = 0;
 58+ var successStateCount = 0;
 59+ var errorStateCount = 0;
5860 var hasData = false;
5961 $j.each( _this.uploads, function( i, upload ) {
60 - if ( $j.inArray( upload.state, _this.endStates ) !== -1 ) {
61 - endStateCount++;
 62+ if ( $j.inArray( upload.state, _this.successStates ) !== -1 ) {
 63+ successStateCount++;
6264 }
 65+ if ( $j.inArray( upload.state, _this.errorStates ) !== -1 ) {
 66+ errorStateCount++;
 67+ }
6368 if (upload[_this.progressProperty] !== undefined) {
6469 fraction += upload[_this.progressProperty] * ( upload[_this.weightProperty] / totalWeight );
6570 if (upload[_this.progressProperty] > 0 ) {
@@ -66,7 +71,7 @@
6772 }
6873 }
6974 } );
70 - //mw.log( 'hasdata:' + hasData + ' endstatecount:' + endStateCount );
 75+
7176 // sometimes, the first data we have just tells us that it's over. So only show the bar
7277 // if we have good data AND the fraction is less than 1.
7378 if ( hasData && fraction < 1.0 ) {
@@ -76,14 +81,13 @@
7782 }
7883 _this.showProgress( fraction );
7984 }
80 - _this.showCount( endStateCount );
 85+ _this.showCount( successStateCount );
8186
82 - if ( endStateCount < _this.uploads.length ) {
 87+ if ( successStateCount + errorStateCount < _this.uploads.length ) {
8388 setTimeout( displayer, 200 );
8489 } else {
8590 _this.showProgress( 1.0 );
86 - // not necessary to hide bar since we're going to the next step.
87 - /* setTimeout( function() { _this.hideBar(); }, 500 ); */
 91+ setTimeout( function() { _this.hideBar(); }, 500 );
8892 }
8993 };
9094 displayer();
Index: trunk/extensions/UploadWizard/resources/combined.js
@@ -8352,7 +8352,7 @@
83538353 /**
83548354 * this is a progress bar for monitoring multiple objects, giving summary view
83558355 */
8356 -mw.GroupProgressBar = function( selector, text, uploads, endStates, progressProperty, weightProperty ) {
 8356+mw.GroupProgressBar = function( selector, text, uploads, successStates, errorStates, progressProperty, weightProperty ) {
83578357 var _this = this;
83588358
83598359 // XXX need to figure out a way to put text inside bar
@@ -8372,7 +8372,8 @@
83738373 _this.$selector.find( '.mwe-upwiz-progress-bar' ).progressbar( { value : 0 } );
83748374
83758375 _this.uploads = uploads;
8376 - _this.endStates = endStates;
 8376+ _this.successStates = successStates;
 8377+ _this.errorStates = errorStates;
83778378 _this.progressProperty = progressProperty;
83788379 _this.weightProperty = weightProperty;
83798380 _this.beginTime = undefined;
@@ -8404,12 +8405,16 @@
84058406
84068407 var displayer = function() {
84078408 var fraction = 0.0;
8408 - var endStateCount = 0;
 8409+ var successStateCount = 0;
 8410+ var errorStateCount = 0;
84098411 var hasData = false;
84108412 $j.each( _this.uploads, function( i, upload ) {
8411 - if ( $j.inArray( upload.state, _this.endStates ) !== -1 ) {
8412 - endStateCount++;
 8413+ if ( $j.inArray( upload.state, _this.successStates ) !== -1 ) {
 8414+ successStateCount++;
84138415 }
 8416+ if ( $j.inArray( upload.state, _this.errorStates ) !== -1 ) {
 8417+ errorStateCount++;
 8418+ }
84148419 if (upload[_this.progressProperty] !== undefined) {
84158420 fraction += upload[_this.progressProperty] * ( upload[_this.weightProperty] / totalWeight );
84168421 if (upload[_this.progressProperty] > 0 ) {
@@ -8417,7 +8422,7 @@
84188423 }
84198424 }
84208425 } );
8421 - //mw.log( 'hasdata:' + hasData + ' endstatecount:' + endStateCount );
 8426+
84228427 // sometimes, the first data we have just tells us that it's over. So only show the bar
84238428 // if we have good data AND the fraction is less than 1.
84248429 if ( hasData && fraction < 1.0 ) {
@@ -8427,14 +8432,13 @@
84288433 }
84298434 _this.showProgress( fraction );
84308435 }
8431 - _this.showCount( endStateCount );
 8436+ _this.showCount( successStateCount );
84328437
8433 - if ( endStateCount < _this.uploads.length ) {
 8438+ if ( successStateCount + errorStateCount < _this.uploads.length ) {
84348439 setTimeout( displayer, 200 );
84358440 } else {
84368441 _this.showProgress( 1.0 );
8437 - // not necessary to hide bar since we're going to the next step.
8438 - /* setTimeout( function() { _this.hideBar(); }, 500 ); */
 8442+ setTimeout( function() { _this.hideBar(); }, 500 );
84398443 }
84408444 };
84418445 displayer();
@@ -10994,8 +10998,9 @@
1099510999
1099611000 var progressBar = new mw.GroupProgressBar( '#mwe-upwiz-progress',
1099711001 gM( 'mwe-upwiz-uploading' ),
10998 - _this.uploads,
10999 - [ 'stashed' ],
 11002+ _this.uploads,
 11003+ [ 'stashed' ],
 11004+ [ 'error' ],
1100011005 'transportProgress',
1100111006 'transportWeight' );
1100211007 progressBar.start();
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -1878,8 +1878,9 @@
18791879
18801880 var progressBar = new mw.GroupProgressBar( '#mwe-upwiz-progress',
18811881 gM( 'mwe-upwiz-uploading' ),
1882 - _this.uploads,
1883 - [ 'stashed' ],
 1882+ _this.uploads,
 1883+ [ 'stashed' ],
 1884+ [ 'error' ],
18841885 'transportProgress',
18851886 'transportWeight' );
18861887 progressBar.start();
Index: trunk/extensions/UploadWizard/resources/combined.min.js
@@ -8352,7 +8352,7 @@
83538353
83548354
83558355
8356 -mw.GroupProgressBar=function(selector,text,uploads,endStates,progressProperty,weightProperty){
 8356+mw.GroupProgressBar=function(selector,text,uploads,successStates,errorStates,progressProperty,weightProperty){
83578357 var _this=this;
83588358
83598359
@@ -8372,7 +8372,8 @@
83738373 _this.$selector.find('.mwe-upwiz-progress-bar').progressbar({value:0});
83748374
83758375 _this.uploads=uploads;
8376 -_this.endStates=endStates;
 8376+_this.successStates=successStates;
 8377+_this.errorStates=errorStates;
83778378 _this.progressProperty=progressProperty;
83788379 _this.weightProperty=weightProperty;
83798380 _this.beginTime=undefined;
@@ -8404,12 +8405,16 @@
84058406
84068407 var displayer=function(){
84078408 var fraction=0.0;
8408 -var endStateCount=0;
 8409+var successStateCount=0;
 8410+var errorStateCount=0;
84098411 var hasData=false;
84108412 $j.each(_this.uploads,function(i,upload){
8411 -if($j.inArray(upload.state,_this.endStates)!==-1){
8412 -endStateCount++;
 8413+if($j.inArray(upload.state,_this.successStates)!==-1){
 8414+successStateCount++;
84138415 }
 8416+if($j.inArray(upload.state,_this.errorStates)!==-1){
 8417+errorStateCount++;
 8418+}
84148419 if(upload[_this.progressProperty]!==undefined){
84158420 fraction+=upload[_this.progressProperty]*(upload[_this.weightProperty]/totalWeight);
84168421 if(upload[_this.progressProperty]>0){
@@ -8427,14 +8432,13 @@
84288433 }
84298434 _this.showProgress(fraction);
84308435 }
8431 -_this.showCount(endStateCount);
 8436+_this.showCount(successStateCount);
84328437
8433 -if(endStateCount<_this.uploads.length){
 8438+if(successStateCount+errorStateCount<_this.uploads.length){
84348439 setTimeout(displayer,200);
84358440 }else{
84368441 _this.showProgress(1.0);
8437 -
8438 -
 8442+setTimeout(function(){_this.hideBar();},500);
84398443 }
84408444 };
84418445 displayer();
@@ -10996,6 +11000,7 @@
1099711001 gM('mwe-upwiz-uploading'),
1099811002 _this.uploads,
1099911003 ['stashed'],
 11004+['error'],
1100011005 'transportProgress',
1100111006 'transportWeight');
1100211007 progressBar.start();

Status & tagging log