Skip to content

Commit d90edfa

Browse files
committed
feat: modify fileProcessors file to be able extract docx, excel,nifti, and snirf files
1 parent 92dbf6f commit d90edfa

6 files changed

Lines changed: 542 additions & 110 deletions

File tree

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
"buffer": "6.0.3",
3333
"dayjs": "^1.11.10",
3434
"jquery": "^3.7.1",
35+
"jsfive": "^0.4.0",
3536
"json-stringify-safe": "^5.0.1",
3637
"jszip": "^3.10.1",
3738
"jwt-decode": "^3.1.2",
3839
"lzma": "^2.3.2",
40+
"mammoth": "^1.11.0",
3941
"numjs": "^0.16.1",
4042
"pako": "1.0.11",
4143
"path-browserify": "^1.0.1",
@@ -54,7 +56,8 @@
5456
"three": "0.145.0",
5557
"typescript": "^5.1.6",
5658
"uplot": "1.6.17",
57-
"web-vitals": "^2.1.0"
59+
"web-vitals": "^2.1.0",
60+
"xlsx": "^0.18.5"
5861
},
5962
"devDependencies": {
6063
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",

src/components/User/Dashboard/DatasetOrganizer/DropZone.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// src/components/DatasetOrganizer/DropZone.tsx
22
import { processFile, processFolder, processZip } from "./utils/fileProcessors";
33
import { CloudUpload, Add } from "@mui/icons-material";
4-
import { Box, Typography, Paper, Button } from "@mui/material";
4+
import { Box, Typography, Paper, Button, TextField } from "@mui/material";
55
import { Colors } from "design/theme";
66
import React, { useState, useRef } from "react";
77
import { FileItem } from "redux/projects/types/projects.interface";
@@ -25,6 +25,7 @@ const DropZone: React.FC<DropZoneProps> = ({
2525
}) => {
2626
const [isDragging, setIsDragging] = useState(false);
2727
const fileInputRef = useRef<HTMLInputElement>(null);
28+
const [basePath, setBasePath] = useState<string>("");
2829

2930
const handleDragOver = (e: React.DragEvent) => {
3031
e.preventDefault();
@@ -68,7 +69,7 @@ const DropZone: React.FC<DropZoneProps> = ({
6869
const zipFiles = await processZip(file);
6970
setFiles((prev) => [...prev, ...zipFiles]);
7071
} else {
71-
const fileItem = await processFile(file);
72+
const fileItem = await processFile(file, basePath);
7273
setFiles((prev) => [...prev, fileItem]);
7374
}
7475
}
@@ -82,10 +83,13 @@ const DropZone: React.FC<DropZoneProps> = ({
8283
const zipFiles = await processZip(file);
8384
setFiles((prev) => [...prev, ...zipFiles]);
8485
} else {
85-
const fileItem = await processFile(file);
86+
const fileItem = await processFile(file, basePath);
8687
setFiles((prev) => [...prev, fileItem]);
8788
}
8889
}
90+
91+
// Reset input
92+
e.target.value = "";
8993
};
9094

9195
return (
@@ -139,6 +143,7 @@ const DropZone: React.FC<DropZoneProps> = ({
139143
<Typography variant="body2" color="text.secondary" sx={{ mb: 1 }}>
140144
Supports NIfTI, SNIRF, HDF5, NeuroJSON, folders, and ZIP archives
141145
</Typography>
146+
142147
{files.length === 0 && (
143148
<>
144149
<Typography
@@ -168,6 +173,16 @@ const DropZone: React.FC<DropZoneProps> = ({
168173
accept=".nii,.nii.gz,.snirf,.h5,.hdf5,.jnii,.jmsh,.json,.txt,.md,.zip,.docx,.pdf,.xlsx,.xls"
169174
/>
170175
</Paper>
176+
<TextField
177+
label="Base Directory Path (optional)"
178+
placeholder="example: /Users/username/Desktop/Downloads"
179+
value={basePath}
180+
onChange={(e) => setBasePath(e.target.value)}
181+
fullWidth
182+
size="small"
183+
sx={{ mb: 2 }}
184+
helperText="Enter the folder path where these files are located"
185+
/>
171186
</Box>
172187
);
173188
};

src/components/User/Dashboard/DatasetOrganizer/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@ const DatasetOrganizer: React.FC = () => {
180180

181181
if (!currentProject) {
182182
return (
183-
<Box p={4}>
183+
<Box
184+
sx={{
185+
p: 4,
186+
background: "linear-gradient(180deg,#f6f7fb 0%, #aeb6e8 100%)",
187+
}}
188+
>
184189
<Alert severity="error">Project not found</Alert>
185190
<Button onClick={() => navigate("/dashboard")} sx={{ mt: 2 }}>
186191
Back to Dashboard
@@ -195,7 +200,7 @@ const DatasetOrganizer: React.FC = () => {
195200
display: "flex",
196201
flexDirection: "column",
197202
height: "100vh",
198-
background: Colors.white,
203+
background: "linear-gradient(180deg,#f6f7fb 0%, #aeb6e8 100%)",
199204
}}
200205
>
201206
{/* Header */}

0 commit comments

Comments
 (0)