Fixes #2383: No error message on failed uploads
This commit is contained in:
parent
96f6376461
commit
cacfb4b909
2 changed files with 32 additions and 3 deletions
|
@ -239,6 +239,26 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
# hide cancel on 90%
|
||||
if parseInt(progress) >= 90
|
||||
@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')
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -57,6 +57,10 @@
|
|||
console.log('Event: upload onCompleted, data = ' + data);
|
||||
file = null;
|
||||
(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:
|
||||
xhr.onload = function (event) {
|
||||
console.log('Upload completed: ' + fileName);
|
||||
|
||||
// Reduce number of active uploads:
|
||||
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:
|
||||
if (manager.uploadsQueue.length) {
|
||||
|
|
Loading…
Reference in a new issue