diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2017-05-03 00:21:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-03 00:21:40 +0200 |
commit | 4e4bc17ff594d4d67acdde294b1d6be68b845f83 (patch) | |
tree | fc8672ca1e06175a242cf6d77127190e0d7369ed | |
parent | aa39f9b8fcba3c22725882acf13b7d264e8de071 (diff) | |
parent | f2f2e7b6fb6558c0976b7fdeafda2d8aa49850a3 (diff) | |
download | nextcloud-server-4e4bc17ff594d4d67acdde294b1d6be68b845f83.tar.gz nextcloud-server-4e4bc17ff594d4d67acdde294b1d6be68b845f83.zip |
Merge pull request #4545 from individual-it/access-control-3726
show error message when "files-drop" upload fails
-rw-r--r-- | apps/files_sharing/js/files_drop.js | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js index ddfcfcd3d8b..f1fc71c6ce2 100644 --- a/apps/files_sharing/js/files_drop.js +++ b/apps/files_sharing/js/files_drop.js @@ -72,34 +72,43 @@ return true; }, + setFileIcon: function (fileName,fileIcon) { + $('#public-upload ul li[data-name="' + fileName + '"]').html(fileIcon); + $('[data-toggle="tooltip"]').tooltip(); + }, + initialize: function () { $(document).bind('drop dragover', function (e) { // Prevent the default browser drop action: e.preventDefault(); }); var output = this.template(); + var fileName = undefined; $('#public-upload').fileupload({ type: 'PUT', dropZone: $('#public-upload'), sequentialUploads: true, add: function(e, data) { Drop.addFileToUpload(e, data); + fileName = escapeHTML(data.files[0].name); //we return true to keep trying to upload next file even //if addFileToUpload did not like the privious one return true; }, done: function(e, data) { // Created - if (data.jqXHR.status === 201) { - var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type); - $('#public-upload ul li[data-name="' + escapeHTML(data.files[0].name) + '"]').html('<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + escapeHTML(data.files[0].name)); - $('[data-toggle="tooltip"]').tooltip(); - } else { - var name = data.files[0].name; - OC.Notification.showTemporary(OC.L10N.translate('files_sharing', 'Could not upload "{filename}"', {filename: name})); - $('#public-upload ul li[data-name="' + escapeHTML(name) + '"]').html(output({isUploading: false, name: escapeHTML(name)})); - $('[data-toggle="tooltip"]').tooltip(); - } + var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type); + var fileIcon = '<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + fileName; + Drop.setFileIcon(fileName,fileIcon); + }, + fail: function(e, data, errorThrown) { + OC.Notification.showTemporary(OC.L10N.translate( + 'files_sharing', + 'Could not upload "{filename}"', + {filename: fileName} + )); + var fileIcon = output({isUploading: false, name: fileName}); + Drop.setFileIcon(fileName,fileIcon); }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); |