From b4ead5a2ebb428dd1ebd99f10aeaa7f8dfc03e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 25 Jun 2018 17:54:28 +0200 Subject: [PATCH] Display proper file upload errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- css/style.scss | 13 +++++-------- js/service/FileService.js | 15 +++++++++++++-- templates/part.card.php | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/css/style.scss b/css/style.scss index 757efa6bc..30e518921 100644 --- a/css/style.scss +++ b/css/style.scss @@ -911,14 +911,11 @@ input.input-inline { } } -#card-attachments { - ul { - margin: 5px; - } - - .details { - font-size: 8pt; - padding-left: 15px; +.card-attachments { + .error { + padding-left: 38px; + margin-bottom: 5px; + background-position: 10px; } } diff --git a/js/service/FileService.js b/js/service/FileService.js index f1b6eb629..1db2617ba 100644 --- a/js/service/FileService.js +++ b/js/service/FileService.js @@ -30,13 +30,17 @@ export default class FileService { this.cardservice = CardService; this.uploader.onAfterAddingFile = this.onAfterAddingFile.bind(this); this.uploader.onSuccessItem = this.onSuccessItem.bind(this); + this.uploader.onErrorItem = this.onErrorItem.bind(this); + + this.status = null; } runUpload (fileItem, attachmentId) { - fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment'); + this.status = null; + fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment?type=deck_file'); if (typeof attachmentId !== 'undefined') { - fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment/' + attachmentId); + fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment/' + attachmentId + '?type=deck_file'); } else { fileItem.formData = [ { @@ -95,6 +99,13 @@ export default class FileService { this.cardservice.get(item.cardId).attachments.push(response); } + onErrorItem (item, response) { + this.status = { + error: t('deck', `Failed to upload:`) + ' ' + item.file.name, + message: response.message + }; + } + } app.service('FileService', FileService); \ No newline at end of file diff --git a/templates/part.card.php b/templates/part.card.php index 30165cd2a..1b8a4920a 100644 --- a/templates/part.card.php +++ b/templates/part.card.php @@ -104,6 +104,7 @@
+
{{ fileservice.status.error }}
{{ fileservice.status.message }}