diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-02-12 13:34:56 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-02-12 13:34:56 -0500 |
commit | 991f7426e8ec2a566ad82043b22ce844a5a1cfa1 (patch) | |
tree | a0ff32313ad511ebdd9ea71180c86aa5b0002204 /assets/js/components | |
parent | a172e3ad8d25e9b77616107ce8a622175ab0d698 (diff) |
Improve error reporting when file upload is not configured properly
Diffstat (limited to 'assets/js/components')
-rw-r--r-- | assets/js/components/file-upload.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/assets/js/components/file-upload.js b/assets/js/components/file-upload.js index f4445a44..ccc57ad7 100644 --- a/assets/js/components/file-upload.js +++ b/assets/js/components/file-upload.js @@ -19,11 +19,17 @@ KB.component('file-upload', function (containerElement, options) { KB.find('#file-item-' + currentFileIndex).add(errorElement); } + function onServerError(response) { + var errorElement = KB.dom('div').addClass('file-error').text(response.message).build(); + KB.find('#file-item-' + currentFileIndex).add(errorElement); + KB.trigger('modal.stop'); + } + function onComplete() { currentFileIndex++; if (currentFileIndex < files.length) { - KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError); + KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError, onServerError); } else { KB.trigger('modal.stop'); KB.trigger('modal.hide'); @@ -81,7 +87,7 @@ KB.component('file-upload', function (containerElement, options) { function uploadFiles() { if (files.length > 0) { - KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError); + KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError, onServerError); } } |