diff --git a/tdei-ui/src/components/DropZone/Dropzone.js b/tdei-ui/src/components/DropZone/Dropzone.js index 045c4c70..753d5dbd 100644 --- a/tdei-ui/src/components/DropZone/Dropzone.js +++ b/tdei-ui/src/components/DropZone/Dropzone.js @@ -10,10 +10,11 @@ import { useDispatch } from "react-redux"; import JSZip from "jszip"; // Functional component Dropzone -function Dropzone({ onDrop, accept, format, selectedFile }) { +function Dropzone({ onDrop, accept, format, maxSizeMB, selectedFile }) { const dispatch = useDispatch(); const [myFiles, setMyFiles] = useState([]); - const MAX_SIZE_MB = 1024; + const DEFAULT_SIZE_MB = 1024; + const ALLOWED_SIZE_MB = maxSizeMB ?? DEFAULT_SIZE_MB; useEffect(() => { if (selectedFile instanceof File) { @@ -27,11 +28,10 @@ function Dropzone({ onDrop, accept, format, selectedFile }) { accept, onDrop: async (acceptedFiles) => { const totalSizeInMB = await calculateTotalUncompressedSize(acceptedFiles); - if (totalSizeInMB > MAX_SIZE_MB) { + if (totalSizeInMB > ALLOWED_SIZE_MB) { dispatch( - show({ - message: - "The total size of dataset files in zip exceeds 1 GB upload limit.", + show({ + message: `The total size of dataset files exceeds ${ALLOWED_SIZE_MB / 1024} GB upload limit.`, type: "danger", }) ); @@ -66,7 +66,7 @@ function Dropzone({ onDrop, accept, format, selectedFile }) { try { zip = await jszip.loadAsync(fileOrBlob); } catch (e) { - throw new Error("Error loading zip file"); + return fileOrBlob.size; } let totalSize = 0; const entries = Object.values(zip.files); diff --git a/tdei-ui/src/routes/Jobs/CreateJob.js b/tdei-ui/src/routes/Jobs/CreateJob.js index 754101ed..f129ae8a 100644 --- a/tdei-ui/src/routes/Jobs/CreateJob.js +++ b/tdei-ui/src/routes/Jobs/CreateJob.js @@ -135,7 +135,15 @@ const CreateJobService = () => { const filteredJobTypeOptions = jobTypeOptions.filter(option => !(option.value === "dataset-tag-road" && (!isDataAccessible && !user?.isAdmin)) - ); + ); + const twoGBJobTypes = [ + 'osw-validate', + 'osw-convert', + ]; + const dropzoneMaxSizeMB = + jobType && twoGBJobTypes.includes(jobType.value) + ? 2048 + : 1024; // Updates the algorithm configuration state based on input from the QualityMetricAlgo component. const handleAlgorithmUpdate = (updatedConfig) => { @@ -590,6 +598,7 @@ const CreateJobService = () => { accept={getAcceptedFileTypes()} format={getFileFormat()} selectedFile={selectedFile} + maxSizeMB={dropzoneMaxSizeMB} />
diff --git a/tdei-ui/src/routes/UploadDataset/DataFile.js b/tdei-ui/src/routes/UploadDataset/DataFile.js index 7e2aec60..75161472 100644 --- a/tdei-ui/src/routes/UploadDataset/DataFile.js +++ b/tdei-ui/src/routes/UploadDataset/DataFile.js @@ -8,7 +8,7 @@ import style from './UploadDataset.module.css'; import { Form } from "react-bootstrap"; // Functional component DataFile -const DataFile = ({ selectedData = {}, onSelectedFileChange }) => { +const DataFile = ({ selectedData = {}, onSelectedFileChange, dataType }) => { const [derivedDatasetId, setDerivedDatasetId] = useState(''); useEffect(() => { @@ -17,6 +17,11 @@ const DataFile = ({ selectedData = {}, onSelectedFileChange }) => { } }, [selectedData]); + const TWO_GB_TYPES = ['osw']; + const dropzoneMaxSizeMB = TWO_GB_TYPES.includes(dataType) + ? 2048 + : undefined; + // Function to handle file drop const onDrop = (files) => { const selectedFile = files[0]; @@ -69,7 +74,7 @@ const DataFile = ({ selectedData = {}, onSelectedFileChange }) => { }}> Attach data file * - +
); };