Skip to content

Commit

Permalink
Fix a typo in subprogress bar and allow a simple mode
Browse files Browse the repository at this point in the history
  • Loading branch information
william-gr committed Jun 28, 2013
1 parent 79721c2 commit 51c6b2c
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions gui/freeadmin/static/lib/js/freeadmin/Progress.js
@@ -1,6 +1,7 @@
define([
"dojo/_base/declare",
"dojo/dom-attr",
"dojo/dom-style",
"dojo/request/xhr",
"dijit/_Widget",
"dijit/_TemplatedMixin",
Expand All @@ -14,6 +15,7 @@ define([
], function(
declare,
domAttr,
domStyle,
xhr,
_Widget,
_Templated,
Expand All @@ -34,6 +36,7 @@ define([
_iter: 0,
name : "",
fileUpload: false,
mode: "advanced",
poolUrl: "",
steps: "",
postCreate : function() {
Expand All @@ -51,6 +54,13 @@ define([
indeterminate: true
}, this.dapSubProgress);

if(this.mode == "simple") {
domStyle(this.dapMain, "display", "none");
domStyle(this.dapSubLabel, "display", "none");
domStyle(this.dapDetails, "display", "none");
domStyle(this.dapETA, "display", "none");
}

this.inherited(arguments);

},
Expand All @@ -72,11 +82,13 @@ define([
var obj = eval(data);
if(obj.state == 'uploading') {
var perc = Math.ceil((obj.received / obj.size)*100);
console.log(perc);
if(perc == 100) {
me._subProgressr.update({'indeterminate': true});
me._subProgress.update({'indeterminate': true});
me._masterProgress(perc);
if(me._numSteps == 1)
if(me._numSteps == 1) {
return;
}
me._curStep += 1;
setTimeout(function() {
me.update();
Expand All @@ -101,23 +113,26 @@ define([
});
me._iter += 1;
} else {
console.log("next", me.poolUrl);
xhr.get(me.poolUrl, {
headers: {"X-Progress-ID": me.uuid},
handleAs: "json"
}).then(function(data) {
me._curStep = data.step;
if(perc == 100) {
if(data.step) {
me._curStep = data.step;
}
if(data.percent == 100) {
me._subProgressr.update({'indeterminate': true});
me._masterProgress(perc);
me._masterProgress(data.percent);
if(me._curStep == me._numSteps)
return;
} else {
me._subProgress.update({
maximum: 100,
progress: perc,
progress: data.percent,
indeterminate: false
});
me._masterProgress(perc);
me._masterProgress(data.percent);
}
setTimeout(function() {
me.update();
Expand Down

0 comments on commit 51c6b2c

Please sign in to comment.