Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NICPS-707: Progress bar during the upload in briefcase. #559

Open
wants to merge 1 commit into
base: snickers
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion WebRoot/js/zimbraMail/share/view/dialog/ZmUploadDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ ZmUploadDialog.prototype._uploadFolder;
ZmUploadDialog.prototype._uploadCallback;

ZmUploadDialog.prototype._extensions;
var uploadedFileObj = [];

// Public methods
/**
Expand Down Expand Up @@ -267,6 +268,14 @@ ZmUploadDialog.prototype._upload = function(){
var errorFilenames;
var newError;
this.setFileExtensions();

try {
var briefcaseProgressDiv= document.getElementById("briefcase_progress_div");
if(briefcaseProgressDiv) {
briefcaseProgressDiv.style.display = "";
briefcaseProgressDiv.innerHTML = "";
}
} catch(err) {}

var setLinkTitleText = (function(){
if (this._showLinkTitleText) {
Expand Down Expand Up @@ -362,7 +371,10 @@ ZmUploadDialog.prototype._upload = function(){
errors.push(newError);
} else {
uploadFiles.push({ name: file.name, fullname: file.name, notes: notes });
}
try {
this._initBriefProgressSpan(file.name, uploadedFileObj);
} catch(err) {}
}
if (((j + 1) === files.length)) {
setLinkTitleText();
}
Expand Down Expand Up @@ -393,6 +405,26 @@ ZmUploadDialog.prototype._upload = function(){
}
};

ZmUploadDialog.prototype._initBriefProgressSpan =
function(fileName, uploadedFileObj) {
try {
var briefcaseProgressDiv= document.getElementById("briefcase_progress_div");
if(briefcaseProgressDiv) {
var firstBubble = briefcaseProgressDiv.getElementsByTagName("span")[0];
if (firstBubble) {
var tempBubbleWrapper = document.createElement("span");
tempBubbleWrapper.innerHTML = AjxTemplate.expand("mail.Message#MailAttachmentBubble", {fileName: fileName});
var newBubble = tempBubbleWrapper.firstChild;
firstBubble.parentNode.insertBefore(newBubble, firstBubble);
} else {
briefcaseProgressDiv.innerHTML = AjxTemplate.expand("mail.Message#UploadProgressContainer", {fileName: fileName});
}
this._loadingSpan = briefcaseProgressDiv.getElementsByTagName("span")[0];
uploadedFileObj.push(this._loadingSpan);
}
} catch(err) {}
};

ZmUploadDialog.prototype._uploadFileProgress =
function(uploadButton, params, progress) {
if (!uploadButton || !params || !progress.lengthComputable || !params.totalSize) return;
Expand All @@ -413,6 +445,13 @@ ZmUploadDialog.prototype._uploadFileProgress =

var tooltip = AjxMessageFormat.format(ZmMsg.uploadPercentComplete, [ Math.round(fractionUploaded * 100) ] )
uploadButton.setToolTipContent(tooltip, true);

try {
for(var cnt=0; cnt<uploadedFileObj.length;cnt++) {
var finishedSpan = uploadedFileObj[cnt].childNodes[0];
finishedSpan.style.width = ((Math.round(fractionUploaded * 100))-10) + "%";
}
} catch(err) {}
};

ZmUploadDialog.prototype._enableUpload = function(uploadButton) {
Expand All @@ -421,6 +460,11 @@ ZmUploadDialog.prototype._enableUpload = function(uploadButton) {
ZmToolBar._setButtonStyle(uploadButton, null, ZmMsg.uploadNewFile, null);
uploadButton.setToolTipContent(ZmMsg.uploadNewFile, true);
this._inprogress = false;
try {
if(document.getElementById("briefcase_progress_div")) {
document.getElementById("briefcase_progress_div").style.display = "none";
}
} catch(err) {}
};

ZmUploadDialog.prototype._finishUpload = function(uploadButton, docFiles, uploadFolder) {
Expand Down