Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tdei-ui/src/components/DropZone/Dropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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",
})
);
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion tdei-ui/src/routes/Jobs/CreateJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -590,6 +598,7 @@ const CreateJobService = () => {
accept={getAcceptedFileTypes()}
format={getFileFormat()}
selectedFile={selectedFile}
maxSizeMB={dropzoneMaxSizeMB}
/>
<div className="d-flex align-items-start mt-2">
<Form.Text id="passwordHelpBlock" className={style.description}>
Expand Down
9 changes: 7 additions & 2 deletions tdei-ui/src/routes/UploadDataset/DataFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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];
Expand Down Expand Up @@ -69,7 +74,7 @@ const DataFile = ({ selectedData = {}, onSelectedFileChange }) => {
}}>
Attach data file<span style={{ color: 'red' }}> *</span>
</Typography>
<Dropzone onDrop={onDrop} accept={{ 'application/zip': ['.zip'] }} format={".zip"} selectedFile={selectedData.file} />
<Dropzone onDrop={onDrop} accept={{ 'application/zip': ['.zip'] }} format={".zip"} selectedFile={selectedData.file} maxSizeMB={dropzoneMaxSizeMB} />
</div>
);
};
Expand Down