Fixes #2383: No error message on failed uploads

This commit is contained in:
Bola Ahmed Buari 2021-05-12 13:48:43 +00:00 committed by Thorsten Eckel
parent 96f6376461
commit cacfb4b909
2 changed files with 32 additions and 3 deletions

View file

@ -239,6 +239,26 @@ class App.TicketZoomArticleNew extends App.Controller
# hide cancel on 90% # hide cancel on 90%
if parseInt(progress) >= 90 if parseInt(progress) >= 90
@cancelContainer.addClass('hide') @cancelContainer.addClass('hide')
# Called when upload failed
onError: (message) =>
@attachmentPlaceholder.removeClass('hide')
@attachmentUpload.addClass('hide')
@$('.article-attachment input').val('')
if @callbackFileUploadStop
@callbackFileUploadStop()
new App.ControllerModal(
head: 'Upload Failed'
buttonCancel: 'Cancel'
buttonCancelClass: 'btn--danger'
buttonSubmit: false
message: message
shown: true
small: true
container: @el.closest('.content')
)
) )
) )

View file

@ -57,6 +57,10 @@
console.log('Event: upload onCompleted, data = ' + data); console.log('Event: upload onCompleted, data = ' + data);
file = null; file = null;
(self.eventHandlers.onCompleted || noop)(data); (self.eventHandlers.onCompleted || noop)(data);
},
onError: function (message) {
console.log('Event: upload error, message: ' + message);
(self.eventHandlers.onError || noop)(message);
} }
}; };
} }
@ -226,12 +230,17 @@
// Triggered when upload is completed: // Triggered when upload is completed:
xhr.onload = function (event) { xhr.onload = function (event) {
console.log('Upload completed: ' + fileName);
// Reduce number of active uploads: // Reduce number of active uploads:
manager.activeUploads -= 1; manager.activeUploads -= 1;
upload.events.onCompleted(event.target.responseText); // call the error callback when the status is not ok
if (xhr.status !== 200){
console.log('Upload failed: ' + fileName);
upload.events.onError(event.target.statusText);
} else {
console.log('Upload completed: ' + fileName);
upload.events.onCompleted(event.target.responseText);
}
// Check if there are any uploads left in a queue: // Check if there are any uploads left in a queue:
if (manager.uploadsQueue.length) { if (manager.uploadsQueue.length) {