Index: lams_admin/web/import/importGroups.jsp =================================================================== diff -u -r80371e446858031dcb9d7fa4456a79e8ab71693c -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_admin/web/import/importGroups.jsp (.../importGroups.jsp) (revision 80371e446858031dcb9d7fa4456a79e8ab71693c) +++ lams_admin/web/import/importGroups.jsp (.../importGroups.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -52,24 +52,35 @@ * Initialise 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 : ['.xls'] - }, - meta: { - // all uploaded files go to this subdir in LAMS tmp dir - // its format is: upload__ - 'tmpFileUploadId' : tmpFileUploadId, - 'largeFilesAllowed' : true - } - }; + var allowedFileTypes = ['.xls'], + 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' : true + }, + 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; @@ -94,6 +105,10 @@ height: 150, width: '100%' }); + + uppy.use(Uppy.Informer, { + target: '#file-upload-area' + }); uppy.use(Uppy.StatusBar, { target: '#file-upload-area',