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

Commit 705de6b

Browse files
author
Barry de Graaff
committed
Rewrite upload dialog in application tab to remove legacy code,
- fixes problems in upload feature on some multi server environments.
1 parent e38c7df commit 705de6b

File tree

4 files changed

+66
-251
lines changed

4 files changed

+66
-251
lines changed

zimlet/OwnCloudApp.js

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,17 +618,76 @@ OwnCloudApp.prototype.extraBtnLsnr = function() {
618618
}
619619
};
620620

621+
OwnCloudApp.prototype.NewUploadToDavDialog = function() {
622+
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
623+
624+
zimletInstance._uploadDialog = new ZmDialog({
625+
title: ZmMsg.uploadDocs,
626+
parent: zimletInstance.getShell(),
627+
standardButtons: [DwtDialog.OK_BUTTON, DwtDialog.CANCEL_BUTTON],
628+
disposeOnPopDown: true
629+
});
630+
var html = "<div style='width:300px; height: 75px;'>" +
631+
"<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>" +
632+
"</div>";
633+
634+
zimletInstance._uploadDialog.setContent(html);
635+
zimletInstance._uploadDialog.setButtonListener(DwtDialog.OK_BUTTON, new AjxListener(zimletInstance, OwnCloudApp.prototype.NewUploadToDavDialogOKBtn));
636+
zimletInstance._uploadDialog.setButtonListener(DwtDialog.CANCEL_BUTTON, new AjxListener(zimletInstance, OwnCloudApp.prototype.NewUploadToDavDialogCancelBtn));
637+
zimletInstance._uploadDialog._tabGroup.addMember(document.getElementById(zimletInstance._uploadDialog._button[1].__internalId));
638+
zimletInstance._uploadDialog._tabGroup.addMember(document.getElementById(zimletInstance._uploadDialog._button[2].__internalId));
639+
zimletInstance._uploadDialog._baseTabGroupSize = 2;
640+
zimletInstance._uploadDialog.popup();
641+
};
642+
643+
OwnCloudApp.prototype.NewUploadToDavDialogCancelBtn = function() {
644+
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
645+
zimletInstance._uploadDialog.popdown();
646+
};
647+
648+
OwnCloudApp.prototype.NewUploadToDavDialogOKBtn = function() {
649+
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
650+
if(!zimletInstance._appView._currentPath || zimletInstance._appView._currentPath=='/')
651+
{
652+
zimletInstance._appView._currentPath = tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_server_path']+'/';
653+
}
654+
655+
var formData = new FormData(document.getElementById("ownCloudZimletUploadFiles"));
656+
zimletInstance._uploadDialog._button[2].setEnabled(false);
657+
zimletInstance._uploadDialog._button[1].setText(ZmMsg.hide);
658+
zimletInstance._uploadDialog.setContent("<div id=\"ownCloudZimletUploadFilesProgress\" style=\"width:300px; text-align:center;\"><img src=\""+zimletInstance.getResource("progressround.gif")+"\"></div>");
659+
660+
var xhr = new XMLHttpRequest();
661+
xhr.open("POST", "/service/extension/dav_upload/?path=" + zimletInstance._appView._currentPath, true);
662+
xhr.onload = function(event){
663+
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
664+
console.log("Success, server responded with: " + event.target.response);
665+
OwnCloudApp.prototype.refreshViewPropfind();
666+
zimletInstance._uploadDialog.popdown();
667+
};
668+
xhr.onerror = function(event){
669+
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
670+
console.log("onerror, server responded with: " + event.target.response);
671+
OwnCloudApp.prototype.refreshViewPropfind();
672+
zimletInstance._uploadDialog.popdown();
673+
};
674+
xhr.onabort = function(event){
675+
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
676+
console.log("onabort, server responded with: " + event.target.response);
677+
OwnCloudApp.prototype.refreshViewPropfind();
678+
zimletInstance._uploadDialog.popdown();
679+
};
680+
681+
xhr.send(formData);
682+
};
683+
621684
OwnCloudApp.prototype._uploadBtnLsnr = function(ev) {
622685
var zimletInstance = appCtxt._zimletMgr.getZimletByName('tk_barrydegraaff_owncloud_zimlet').handlerObject;
623686
if(!zimletInstance._appView._currentPath || zimletInstance._appView._currentPath=='/')
624687
{
625688
zimletInstance._appView._currentPath = tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_server_path']+'/';
626689
}
627-
var dialog = new UploadToDavDialog(appCtxt.getShell());
628-
dialog.popup(
629-
zimletInstance._appView._currentPath,
630-
new AjxCallback(this, this.refreshViewPropfind)
631-
);
690+
OwnCloudApp.prototype.NewUploadToDavDialog();
632691
};
633692

634693
OwnCloudApp.prototype.refreshViewPropfind = function() {

zimlet/UploadToDavDialog.js

Lines changed: 0 additions & 243 deletions
This file was deleted.

zimlet/tk_barrydegraaff_owncloud_zimlet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ ownCloudZimlet.prototype.uploadFilesFromForm = function (files , response) {
738738
var path = zimletInstance.OwnCloudFolderPicker.selectedDavResource;
739739
}
740740
var progressId = listProgressBar[fileName];
741-
var putUrl = UploadToDavDialog.UPLOAD_URL + "?path=" + path;
741+
var putUrl = "/service/extension/dav_upload/?path=" + path;
742742

743743
function progressFunction(id, evt) {
744744
var progressBar = document.getElementById(id);

zimlet/tk_barrydegraaff_owncloud_zimlet.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
2323
2424
-->
2525
<zimlet name="tk_barrydegraaff_owncloud_zimlet"
26-
version="1.1.4"
26+
version="1.1.5"
2727
target="main compose-window view-window"
2828
label="WebDAV"
2929
description="Attach from and save to WebDAV">
@@ -36,7 +36,6 @@ along with this program. If not, see http://www.gnu.org/licenses/.
3636
<include>OwnCloudListView.js</include>
3737
<include>OwnCloudTabView.js</include>
3838
<include>OwnCloudTreeController.js</include>
39-
<include>UploadToDavDialog.js</include>
4039
<include>tk_barrydegraaff_owncloud_zimlet.js</include>
4140
<include>mime.js</include>
4241
<include>ZmOwnCloudController.js</include>

0 commit comments

Comments
 (0)