Index: lams_central/web/toolcontent/import.jsp =================================================================== diff -u -r5ca819dd0f4447eb517ca030f301b2a4dbab544a -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_central/web/toolcontent/import.jsp (.../import.jsp) (revision 5ca819dd0f4447eb517ca030f301b2a4dbab544a) +++ lams_central/web/toolcontent/import.jsp (.../import.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -40,27 +40,38 @@ } /** - * Initialise Uppy as the file upload widget + * Initialised Uppy as the file upload widget */ function initFileUpload(tmpFileUploadId, language) { - var uppyProperties = { - // upload immediately - autoProceed: true, - allowMultipleUploads: true, - debug: false, - restrictions: { - // taken from LAMS configuration - maxFileSize: +UPLOAD_FILE_MAX_SIZE, - maxNumberOfFiles: 1, - allowedFileTypes : ['.zip'] - }, - meta: { - // all uploaded files go to this subdir in LAMS tmp dir - // its format is: upload__ - 'tmpFileUploadId' : tmpFileUploadId, - 'largeFilesAllowed' : false - } - }; + var allowedFileTypes = ['.zip'], + uppyProperties = { + // upload immediately + autoProceed: true, + allowMultipleUploads: true, + debug: false, + restrictions: { + // taken from LAMS configuration + maxFileSize: +UPLOAD_FILE_MAX_SIZE, + maxNumberOfFiles: 1, + allowedFileTypes : allowedFileTypes + }, + meta: { + // all uploaded files go to this subdir in LAMS tmp dir + // its format is: upload__ + 'tmpFileUploadId' : tmpFileUploadId, + 'largeFilesAllowed' : false + }, + onBeforeFileAdded: function(currentFile, files) { + var name = currentFile.data.name, + extensionIndex = name.lastIndexOf('.'), + valid = allowedFileTypes.includes(name.substring(extensionIndex).trim()); + if (!valid) { + uppy.info('', 'error', 10000); + } + + return valid; + } + }; switch(language) { case 'es' : uppyProperties.locale = Uppy.locales.es_ES; break; @@ -86,6 +97,10 @@ width: '100%' }); + uppy.use(Uppy.Informer, { + target: '#image-upload-area' + }); + uppy.use(Uppy.StatusBar, { target: '#image-upload-area', hideAfterFinish: false, @@ -94,6 +109,8 @@ hidePauseResumeButton: true, hideCancelButton: true }); + + } $(document).ready(function(){