Skip to content

Commit 75b8831

Browse files
harikiranrommalaHari KiranMarSH-Up
authored
Feature/dataset deatils page (#5)
* Webpage building * [Fix][Remove package-lock * [Fix][Validation] * [Fix][Validation] * [Fix][Validation] * [Fix][Validation] * [Fix][Validation] * [Fix][Code]Structure update * [Fix][Code]Structure update * [Fix][Code]Structure update * [Fix][Slice]Return setLoading * [Fix][Slice]Return setLoading * [Fix][Slice]Return setLoading * DatasetDetailsPage features --------- Co-authored-by: Hari Kiran <[email protected]> Co-authored-by: MarSHub <[email protected]>
1 parent 586a3a1 commit 75b8831

File tree

10 files changed

+515
-131
lines changed

10 files changed

+515
-131
lines changed

build/favicon.ico

-87.4 KB
Binary file not shown.

build/io_fav.png

-10.9 KB
Binary file not shown.

build/robots.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/design/Layouts/FullScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ const FullScreen = () => {
203203
<Box
204204
sx={{
205205
width: "100%",
206-
minHeight: "calc(100vh - 6rem)", // Ensure full height minus the AppBar height (6rem)
206+
height: "calc(100vh - 6rem)",
207207
boxSizing: "border-box",
208208
marginTop: "6rem",
209209
background: "#f0f0f0",
210+
overflow: "auto",
210211
}}
211212
>
212213
<Outlet />

src/modules/universe/NeuroJsonGraph.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ const NeuroJsonGraph: React.FC<{ registry: Database[] }> = ({ registry }) => {
143143
ref={graphRef}
144144
style={{
145145
width: "100%",
146-
height: "100vh",
146+
maxHeight: "99%",
147147
backgroundColor: "transparent",
148148
position: "relative",
149+
overflow: "hidden",
149150
}}
150151
/>
151152
);

src/pages/DatasetDetailPage.tsx

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,62 @@ import {
55
CircularProgress,
66
Alert,
77
Button,
8+
Card,
9+
CardContent,
810
} from "@mui/material";
911
import React, { useEffect, useState } from "react";
1012
import ReactJson from "react-json-view";
1113
import { useParams, useNavigate } from "react-router-dom";
1214

15+
interface ExternalDataLink {
16+
name: string;
17+
size: string;
18+
path: string;
19+
url: string;
20+
}
21+
1322
const DatasetDetailPage: React.FC = () => {
1423
const { dbName, docId } = useParams<{ dbName: string; docId: string }>();
1524
const navigate = useNavigate();
1625
const [document, setDocument] = useState<any>(null);
1726
const [loading, setLoading] = useState(true);
1827
const [error, setError] = useState<string | null>(null);
28+
const [externalLinks, setExternalLinks] = useState<ExternalDataLink[]>([]);
29+
30+
// Recursive function to find `_DataLink_`
31+
const extractDataLinks = (obj: any, path: string): ExternalDataLink[] => {
32+
const links: ExternalDataLink[] = [];
33+
34+
if (typeof obj === "object" && obj !== null) {
35+
for (const key in obj) {
36+
if (obj.hasOwnProperty(key)) {
37+
if (key === "_DataLink_" && typeof obj[key] === "string") {
38+
// Use regex to remove anything starting from ':$' (non-greedy)
39+
let correctedUrl = obj[key].replace(/:\$.*$/, ""); // Replace `:$<anything>` with ''
40+
41+
const sizeMatch = obj[key].match(/size=(\d+)/); // Extract size from the link
42+
const size = sizeMatch
43+
? `${(parseInt(sizeMatch[1], 10) / 1024 / 1024).toFixed(2)} MB`
44+
: "Unknown Size";
45+
46+
const subMatch = path.match(/sub-\d+/); // Match the sub-field path
47+
const subPath = subMatch ? subMatch[0] : "Unknown Sub";
48+
49+
links.push({
50+
name: `NIFTIData (${size}) [/${subPath}]`,
51+
size,
52+
path: subPath,
53+
url: correctedUrl, // Use the corrected URL
54+
});
55+
} else if (typeof obj[key] === "object") {
56+
links.push(...extractDataLinks(obj[key], `${path}/${key}`));
57+
}
58+
}
59+
}
60+
}
61+
62+
return links;
63+
};
1964

2065
useEffect(() => {
2166
const fetchData = async () => {
@@ -25,6 +70,10 @@ const DatasetDetailPage: React.FC = () => {
2570
if (dbName && docId) {
2671
const data = await fetchDocumentById(dbName, docId);
2772
setDocument(data);
73+
74+
// Extract external links
75+
const links = extractDataLinks(data, "");
76+
setExternalLinks(links);
2877
}
2978
} catch (err) {
3079
console.error("Error fetching document:", err);
@@ -101,6 +150,69 @@ const DatasetDetailPage: React.FC = () => {
101150
</Typography>
102151
)}
103152
</Box>
153+
154+
{/* External Data Section */}
155+
{externalLinks.length > 0 && (
156+
<Box sx={{ marginTop: 4 }}>
157+
<Typography variant="h5" gutterBottom>
158+
External Data ({externalLinks.length} links)
159+
</Typography>
160+
<Box
161+
sx={{
162+
display: "grid",
163+
gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))",
164+
gap: 2,
165+
}}
166+
>
167+
{externalLinks.map((link, index) => (
168+
<Card
169+
key={index}
170+
sx={{
171+
border: "1px solid #ddd",
172+
borderRadius: "8px",
173+
padding: 2,
174+
backgroundColor: "#f9f9f9",
175+
}}
176+
>
177+
<CardContent>
178+
<Typography>{link.name}</Typography>
179+
<Box sx={{ marginTop: 2, display: "flex", gap: 1 }}>
180+
<Button
181+
variant="contained"
182+
size="small"
183+
onClick={() => window.open(link.url, "_blank")}
184+
>
185+
Download
186+
</Button>
187+
<Button
188+
variant="outlined"
189+
size="small"
190+
onClick={() => console.log("Preview", link.url)}
191+
>
192+
Preview
193+
</Button>
194+
<Button
195+
variant="outlined"
196+
size="small"
197+
onClick={() => console.log("URL", link.url)}
198+
>
199+
URL
200+
</Button>
201+
<Button
202+
variant="text"
203+
size="small"
204+
color="error"
205+
onClick={() => console.log("Close", link.url)}
206+
>
207+
Close
208+
</Button>
209+
</Box>
210+
</CardContent>
211+
</Card>
212+
))}
213+
</Box>
214+
</Box>
215+
)}
104216
</Box>
105217
);
106218
};

0 commit comments

Comments
 (0)