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', Index: lams_admin/web/import/importexcel.jsp =================================================================== diff -u -r80371e446858031dcb9d7fa4456a79e8ab71693c -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_admin/web/import/importexcel.jsp (.../importexcel.jsp) (revision 80371e446858031dcb9d7fa4456a79e8ab71693c) +++ lams_admin/web/import/importexcel.jsp (.../importexcel.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -51,24 +51,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; @@ -93,6 +104,10 @@ height: 150, width: '100%' }); + + uppy.use(Uppy.Informer, { + target: '#file-upload-area' + }); uppy.use(Uppy.StatusBar, { target: '#file-upload-area', Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r7c20941ea3590d8a05b4a71e03a66749fb73ce87 -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7c20941ea3590d8a05b4a71e03a66749fb73ce87) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -78,6 +78,7 @@ title.import.instruction = Please choose LAMS sequence to import. title.export.loading = Export tool content loading label.ld.zip.file = Learning design import file +error.ld.zip.file = Only zip files allowed msg.import.success = Learning design and activities imported successfully. msg.import.ld.success = Learning design imported successfully. msg.import.tool.error.prefix = But there are some tool(s) imports that failed Index: lams_central/web/qb/importQuestionsXml.jsp =================================================================== diff -u -rf92b1383638a766c5d8496c6f607322dd2af8329 -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_central/web/qb/importQuestionsXml.jsp (.../importQuestionsXml.jsp) (revision f92b1383638a766c5d8496c6f607322dd2af8329) +++ lams_central/web/qb/importQuestionsXml.jsp (.../importQuestionsXml.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -50,24 +50,35 @@ UPLOAD_FILE_MAX_SIZE = ''; 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 : ['.xml'] - }, - meta: { - // all uploaded files go to this subdir in LAMS tmp dir - // its format is: upload__ - 'tmpFileUploadId' : tmpFileUploadId, - 'largeFilesAllowed' : true - } - }; + var allowedFileTypes = ['.xml'], + 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; @@ -92,6 +103,10 @@ height: 120, width: '100%' }); + + uppy.use(Uppy.Informer, { + target: '#image-upload-area' + }); uppy.use(Uppy.StatusBar, { target: '#image-upload-area', Index: lams_central/web/questions/questionFile.jsp =================================================================== diff -u -radd24141d43ff78942c251760e1614925db89464 -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_central/web/questions/questionFile.jsp (.../questionFile.jsp) (revision add24141d43ff78942c251760e1614925db89464) +++ lams_central/web/questions/questionFile.jsp (.../questionFile.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -47,7 +47,8 @@ UPLOAD_FILE_MAX_SIZE = ''; function initFileUpload(tmpFileUploadId, language) { - var uppyProperties = { + var allowedFileTypes = ['.zip', '.xml'], + uppyProperties = { // upload immediately autoProceed: true, allowMultipleUploads: true, @@ -56,14 +57,24 @@ // taken from LAMS configuration maxFileSize: +UPLOAD_FILE_MAX_SIZE, maxNumberOfFiles: 1, - allowedFileTypes : ['.zip', '.xml'] + 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) { @@ -89,6 +100,11 @@ height: 120, width: '100%' }); + + + uppy.use(Uppy.Informer, { + target: '#image-upload-area' + }); uppy.use(Uppy.StatusBar, { target: '#image-upload-area', 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(){ Index: lams_tool_forum/web/includes/javascript/message.js =================================================================== diff -u -r878c21db8928877b26b38d8e08559ba5d783adfd -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_tool_forum/web/includes/javascript/message.js (.../message.js) (revision 878c21db8928877b26b38d8e08559ba5d783adfd) +++ lams_tool_forum/web/includes/javascript/message.js (.../message.js) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -104,14 +104,14 @@ 'largeFilesAllowed' : largeFilesAllowed }, onBeforeFileAdded: function(currentFile, files) { - var name = currentFile.data.name, - extensionIndex = name.lastIndexOf('.'), - valid = extensionIndex < 0 || !EXE_FILE_TYPES.includes(name.substring(extensionIndex).trim()); - if (!valid) { - uppy.info(EXE_FILE_ERROR, 'error', 10000); - } - - return valid; + var name = currentFile.data.name, + extensionIndex = name.lastIndexOf('.'), + valid = extensionIndex < 0 || !EXE_FILE_TYPES.includes(name.substring(extensionIndex).trim()); + if (!valid) { + uppy.info(EXE_FILE_ERROR, 'error', 10000); + } + + return valid; } }; @@ -139,6 +139,10 @@ width: '100%' }); + uppy.use(Uppy.Informer, { + target: '#image-upload-area' + }); + uppy.use(Uppy.StatusBar, { target: '#image-upload-area', hideAfterFinish: false, @@ -147,7 +151,7 @@ hidePauseResumeButton: true, hideCancelButton: true }); - + uppy.on('upload-success', (file, response) => { // if file name was modified by server, reflect it in Uppy file.meta.name = response.body.name; Index: lams_tool_images/web/includes/javascript/imageGalleryitem.js =================================================================== diff -u -r5ca819dd0f4447eb517ca030f301b2a4dbab544a -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_tool_images/web/includes/javascript/imageGalleryitem.js (.../imageGalleryitem.js) (revision 5ca819dd0f4447eb517ca030f301b2a4dbab544a) +++ lams_tool_images/web/includes/javascript/imageGalleryitem.js (.../imageGalleryitem.js) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -79,7 +79,17 @@ // for server-side file type validation; consistent with CKEditor parameter 'Type' : 'Image', 'largeFilesAllowed' : true - } + }, + onBeforeFileAdded: function(currentFile, files) { + var name = currentFile.data.name, + extensionIndex = name.lastIndexOf('.'), + valid = UPLOAD_ALLOWED_EXTENSIONS.includes(name.substring(extensionIndex).trim()); + if (!valid) { + uppy.info(LABEL_NOT_ALLOWED_FORMAT, 'error', 10000); + } + + return valid; + } }; switch(language) { Index: lams_tool_images/web/pages/learning/learning.jsp =================================================================== diff -u -r3a64b2f8137870eb67586cd9b18e71f84096b43c -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_tool_images/web/pages/learning/learning.jsp (.../learning.jsp) (revision 3a64b2f8137870eb67586cd9b18e71f84096b43c) +++ lams_tool_images/web/pages/learning/learning.jsp (.../learning.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -49,6 +49,7 @@ // convert Java syntax to JSON var UPLOAD_ALLOWED_EXTENSIONS = JSON.parse("[" + "${ALLOWED_EXTENSIONS_IMAGE}".replace(/\.\w+/g, '"$&"') + "]"); var LABEL_ITEM_BLANK = ''; + var LABEL_NOT_ALLOWED_FORMAT = ''; Index: lams_tool_images/web/pages/monitoring/monitoring.jsp =================================================================== diff -u -r3a64b2f8137870eb67586cd9b18e71f84096b43c -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_tool_images/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 3a64b2f8137870eb67586cd9b18e71f84096b43c) +++ lams_tool_images/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -65,6 +65,7 @@ // convert Java syntax to JSON var UPLOAD_ALLOWED_EXTENSIONS = JSON.parse("[" + "${ALLOWED_EXTENSIONS_IMAGE}".replace(/\.\w+/g, '"$&"') + "]"); var LABEL_ITEM_BLANK = ''; + var LABEL_NOT_ALLOWED_FORMAT = ''; Index: lams_tool_task/web/pages/learning/learning.jsp =================================================================== diff -u -r2b05721ac0d8b1f4366c207570cf62326e855ddf -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_tool_task/web/pages/learning/learning.jsp (.../learning.jsp) (revision 2b05721ac0d8b1f4366c207570cf62326e855ddf) +++ lams_tool_task/web/pages/learning/learning.jsp (.../learning.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -175,14 +175,14 @@ 'largeFilesAllowed' : false }, onBeforeFileAdded: function(currentFile, files) { - var name = currentFile.data.name, - extensionIndex = name.lastIndexOf('.'), - valid = extensionIndex < 0 || !EXE_FILE_TYPES.includes(name.substring(extensionIndex).trim()); - if (!valid) { - uppy.info(EXE_FILE_ERROR, 'error', 10000); - } - - return valid; + var name = currentFile.data.name, + extensionIndex = name.lastIndexOf('.'), + valid = extensionIndex < 0 || !EXE_FILE_TYPES.includes(name.substring(extensionIndex).trim()); + if (!valid) { + uppy.info(EXE_FILE_ERROR, 'error', 10000); + } + + return valid; } }; @@ -210,6 +210,10 @@ width: '100%' }); + uppy.use(Uppy.Informer, { + target: '#image-upload-area' + }); + uppy.use(Uppy.StatusBar, { target: '#image-upload-area', hideAfterFinish: false,