Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Rewrite upload dialog in application tab to remove legacy code,
Browse files Browse the repository at this point in the history
- fixes problems in upload feature on some multi server environments.
  • Loading branch information
Barry de Graaff committed May 2, 2019
1 parent e38c7df commit 705de6b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 251 deletions.
69 changes: 64 additions & 5 deletions zimlet/OwnCloudApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,17 +618,76 @@ OwnCloudApp.prototype.extraBtnLsnr = function() {
}
};

OwnCloudApp.prototype.NewUploadToDavDialog = function() {
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;

zimletInstance._uploadDialog = new ZmDialog({
title: ZmMsg.uploadDocs,
parent: zimletInstance.getShell(),
standardButtons: [DwtDialog.OK_BUTTON, DwtDialog.CANCEL_BUTTON],
disposeOnPopDown: true
});
var html = "<div style='width:300px; height: 75px;'>" +
"<form accept-charset=\"utf-8\" method=\"POST\" id=\"ownCloudZimletUploadFiles\" enctype=\"multipart/form-data\"><table role=\"presentation\" class=\"ZPropertySheet\" cellspacing=\"6\"><tbody><tr><td>File:</td><td><input type=\"file\" multiple=\"\" name=\"uploadFile\" size=\"30\"><input type=\"hidden\" name=\"password\" value=\""+tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_password']+"\"></td><td colspan=\"3\">&nbsp;</td></tr></tbody></table></form>" +
"</div>";

zimletInstance._uploadDialog.setContent(html);
zimletInstance._uploadDialog.setButtonListener(DwtDialog.OK_BUTTON, new AjxListener(zimletInstance, OwnCloudApp.prototype.NewUploadToDavDialogOKBtn));
zimletInstance._uploadDialog.setButtonListener(DwtDialog.CANCEL_BUTTON, new AjxListener(zimletInstance, OwnCloudApp.prototype.NewUploadToDavDialogCancelBtn));
zimletInstance._uploadDialog._tabGroup.addMember(document.getElementById(zimletInstance._uploadDialog._button[1].__internalId));
zimletInstance._uploadDialog._tabGroup.addMember(document.getElementById(zimletInstance._uploadDialog._button[2].__internalId));
zimletInstance._uploadDialog._baseTabGroupSize = 2;
zimletInstance._uploadDialog.popup();
};

OwnCloudApp.prototype.NewUploadToDavDialogCancelBtn = function() {
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
zimletInstance._uploadDialog.popdown();
};

OwnCloudApp.prototype.NewUploadToDavDialogOKBtn = function() {
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
if(!zimletInstance._appView._currentPath || zimletInstance._appView._currentPath=='/')
{
zimletInstance._appView._currentPath = tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_server_path']+'/';
}

var formData = new FormData(document.getElementById("ownCloudZimletUploadFiles"));
zimletInstance._uploadDialog._button[2].setEnabled(false);
zimletInstance._uploadDialog._button[1].setText(ZmMsg.hide);
zimletInstance._uploadDialog.setContent("<div id=\"ownCloudZimletUploadFilesProgress\" style=\"width:300px; text-align:center;\"><img src=\""+zimletInstance.getResource("progressround.gif")+"\"></div>");

var xhr = new XMLHttpRequest();
xhr.open("POST", "/service/extension/dav_upload/?path=" + zimletInstance._appView._currentPath, true);
xhr.onload = function(event){
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
console.log("Success, server responded with: " + event.target.response);
OwnCloudApp.prototype.refreshViewPropfind();
zimletInstance._uploadDialog.popdown();
};
xhr.onerror = function(event){
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
console.log("onerror, server responded with: " + event.target.response);
OwnCloudApp.prototype.refreshViewPropfind();
zimletInstance._uploadDialog.popdown();
};
xhr.onabort = function(event){
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
console.log("onabort, server responded with: " + event.target.response);
OwnCloudApp.prototype.refreshViewPropfind();
zimletInstance._uploadDialog.popdown();
};

xhr.send(formData);
};

OwnCloudApp.prototype._uploadBtnLsnr = function(ev) {
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
if(!zimletInstance._appView._currentPath || zimletInstance._appView._currentPath=='/')
{
zimletInstance._appView._currentPath = tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_server_path']+'/';
}
var dialog = new UploadToDavDialog(appCtxt.getShell());
dialog.popup(
zimletInstance._appView._currentPath,
new AjxCallback(this, this.refreshViewPropfind)
);
OwnCloudApp.prototype.NewUploadToDavDialog();
};

OwnCloudApp.prototype.refreshViewPropfind = function() {
Expand Down
243 changes: 0 additions & 243 deletions zimlet/UploadToDavDialog.js

This file was deleted.

2 changes: 1 addition & 1 deletion zimlet/tk_barrydegraaff_owncloud_zimlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ ownCloudZimlet.prototype.uploadFilesFromForm = function (files , response) {
var path = zimletInstance.OwnCloudFolderPicker.selectedDavResource;
}
var progressId = listProgressBar[fileName];
var putUrl = UploadToDavDialog.UPLOAD_URL + "?path=" + path;
var putUrl = "/service/extension/dav_upload/?path=" + path;

function progressFunction(id, evt) {
var progressBar = document.getElementById(id);
Expand Down
3 changes: 1 addition & 2 deletions zimlet/tk_barrydegraaff_owncloud_zimlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
-->
<zimlet name="tk_barrydegraaff_owncloud_zimlet"
version="1.1.4"
version="1.1.5"
target="main compose-window view-window"
label="WebDAV"
description="Attach from and save to WebDAV">
Expand All @@ -36,7 +36,6 @@ along with this program. If not, see http://www.gnu.org/licenses/.
<include>OwnCloudListView.js</include>
<include>OwnCloudTabView.js</include>
<include>OwnCloudTreeController.js</include>
<include>UploadToDavDialog.js</include>
<include>tk_barrydegraaff_owncloud_zimlet.js</include>
<include>mime.js</include>
<include>ZmOwnCloudController.js</include>
Expand Down

0 comments on commit 705de6b

Please sign in to comment.