Merge pull request #4545 from individual-it/access-control-3726
show error message when "files-drop" upload fails
This commit is contained in:
commit
4e4bc17ff5
1 changed files with 19 additions and 10 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue