From 19396cc59741f4d3a0c6b7d1a93822791572d898 Mon Sep 17 00:00:00 2001 From: Silas Joisten Date: Sun, 8 Jul 2018 12:43:25 +0200 Subject: [PATCH] added notification --- .../SonataMultiUploadBundle.de.yml | 3 +++ .../SonataMultiUploadBundle.en.yml | 3 +++ src/Resources/views/multi_upload.html.twig | 21 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/Resources/translations/SonataMultiUploadBundle.de.yml b/src/Resources/translations/SonataMultiUploadBundle.de.yml index 2cacde7..32bd558 100644 --- a/src/Resources/translations/SonataMultiUploadBundle.de.yml +++ b/src/Resources/translations/SonataMultiUploadBundle.de.yml @@ -6,3 +6,6 @@ uploading: Hochladen canceled: Abgebrochen upload_complete: Abgeschlossen drag_and_drop: Dateien hier ablegen +file_type_error: Dateityp wird nicht unterstützt +file_size_error: Datei ist zu groß +file_extension_error: Dateiending wird nicht unterstützt diff --git a/src/Resources/translations/SonataMultiUploadBundle.en.yml b/src/Resources/translations/SonataMultiUploadBundle.en.yml index 115a7df..6142461 100644 --- a/src/Resources/translations/SonataMultiUploadBundle.en.yml +++ b/src/Resources/translations/SonataMultiUploadBundle.en.yml @@ -6,3 +6,6 @@ uploading: Uploading canceled: Canceled upload_complete: Upload complete drag_and_drop: Drag & drop files here +file_type_error: Filetype is not correct +file_size_error: File is to large +file_extension_error: File extension is not supported diff --git a/src/Resources/views/multi_upload.html.twig b/src/Resources/views/multi_upload.html.twig index 81d9c13..87eda77 100644 --- a/src/Resources/views/multi_upload.html.twig +++ b/src/Resources/views/multi_upload.html.twig @@ -7,6 +7,11 @@ {% block content %}
+
@@ -69,6 +74,15 @@ setStatus(id, 'danger', message); setProgress(id, 0, 'danger', false); }, + onFileTypeError: function (file) { + setNotification('danger', '' + file.name + ' {{ 'file_type_error'|trans({}, 'SonataMultiUploadBundle') }}'); + }, + onFileSizeError: function (file) { + setNotification('danger', '' + file.name + ' {{ 'file_size_error'|trans({}, 'SonataMultiUploadBundle') }}'); + }, + onFileExtError: function (file) { + setNotification('danger', '' + file.name + ' {{ 'file_extension_error'|trans({}, 'SonataMultiUploadBundle') }}'); + } }); }); @@ -82,6 +96,13 @@ $('#files').prepend($template); } + function setNotification(status, message) { + var $alert = $('div.alert') + $alert.addClass('alert-' + status); + $alert.find('.text').append('

' + message + '

'); + $alert.removeClass('hidden').fadeIn(); + } + function setStatus(id, status, message) { $('#uploaderFile' + id).find('span').html(message).prop('class', 'status text-' + status); }