Skip to content

Commit 75259dc

Browse files
Hari KiranHari Kiran
authored andcommitted
Fix #36 external linked files labelling and rendering method based on linked file type
1 parent d7a92ee commit 75259dc

File tree

2 files changed

+78
-67
lines changed

2 files changed

+78
-67
lines changed

src/index.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
1-
// import App from "./App";
2-
// import { ThemeProvider } from "@emotion/react";
3-
// import { CssBaseline } from "@mui/material";
4-
// import theme from "design/theme";
5-
// import ReactDOM from "react-dom/client";
6-
// import { Provider } from "react-redux";
7-
// import store from "redux/store";
8-
9-
// const root = ReactDOM.createRoot(
10-
// document.getElementById("root") as HTMLElement
11-
// );
12-
13-
// root.render(
14-
// <Provider store={store}>
15-
// <ThemeProvider theme={theme}>
16-
// <CssBaseline />
17-
// <App />
18-
// </ThemeProvider>
19-
// </Provider>
20-
// );
21-
221
import React from "react";
232
import ReactDOM from "react-dom/client";
243
import App from "./App";

src/pages/DatasetDetailPage.tsx

Lines changed: 78 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const DatasetDetailPage: React.FC = () => {
8585
const subPath = subMatch ? subMatch[0] : "Unknown Sub";
8686

8787
links.push({
88-
name: `NIFTIData (${size}) [/${subPath}]`,
88+
name: `${path.split("/").pop() || "ExternalData"} (${size}) [/${subPath}]`,
8989
size,
9090
path: subPath,
9191
url: correctedUrl,
@@ -241,22 +241,6 @@ const DatasetDetailPage: React.FC = () => {
241241
urlMatch: /\.(nii\.gz|jdt|jdb|bmsh|jmsh|bnii)$/i.test(dataOrUrl),
242242
});
243243

244-
245-
// if (isInternal) {
246-
// try {
247-
// // ✅ Create a writable deep copy to avoid modifying read-only properties
248-
// const writableData = JSON.parse(JSON.stringify(dataOrUrl));
249-
250-
// if (typeof (window as any).previewdata === "function") {
251-
// console.log("✅ Calling previewdata() for internal data:", writableData);
252-
// (window as any).previewdata(writableData, idx, false); // ✅ Pass writable copy
253-
// } else {
254-
// console.error("❌ previewdata() is not defined!");
255-
// }
256-
// } catch (error) {
257-
// console.error("❌ Error processing internal data:", error);
258-
// }
259-
// }
260244
if (isInternal) {
261245
try {
262246
// 🔐 Step 1: Ensure global intdata exists
@@ -569,7 +553,7 @@ const DatasetDetailPage: React.FC = () => {
569553
</Box>
570554

571555
{/* ✅ Data panels (right panel) */}
572-
<Box sx={{ flex: 2, display: "flex", flexDirection: "column", gap: 2 }}>
556+
<Box sx={{ width: "460px", minWidth: "360px", display: "flex", flexDirection: "column", gap: 2, }}>
573557
<Box sx={{ backgroundColor: "#cdddf6", padding: 2, borderRadius: "8px", marginTop: 4 }}>
574558
{/* ✅ Collapsible header */}
575559
<Box
@@ -604,25 +588,40 @@ const DatasetDetailPage: React.FC = () => {
604588
<Box
605589
key={index}
606590
sx={{
607-
mt: 1,
608-
p: 1.5,
609-
bgcolor: "white",
610-
borderRadius: 1,
611-
display: "flex",
612-
justifyContent: "space-between",
613-
alignItems: "center",
614-
flexWrap: "wrap",
615-
gap: 2,
616-
border: "1px solid #bbb",
591+
display: "flex",
592+
alignItems: "center",
593+
justifyContent: "space-between",
594+
padding: "6px 10px",
595+
backgroundColor: "white",
596+
borderRadius: "4px",
597+
border: "1px solid #ddd",
598+
mt: 1,
599+
height: "34px",
600+
minWidth: 0,
601+
fontSize: "0.85rem",
617602
}}
618603
>
619-
<Typography sx={{ flexGrow: 1 }}>
604+
<Typography sx={{
605+
flexGrow: 1,
606+
minWidth:0,
607+
whiteSpace: "nowrap",
608+
overflow: "hidden",
609+
textOverflow: "ellipsis",
610+
fontSize: "1rem",
611+
marginRight: "12px",
612+
maxWidth: "calc(100% - 160px)",}}
613+
title={link.name}>
620614
{link.name} {link.arraySize ? `[${link.arraySize.join("x")}]` : ""}
621615
</Typography>
622616
<Button
623617
variant="contained"
624618
size="small"
625-
sx={{ backgroundColor: "#1976d2" }}
619+
sx={{ backgroundColor: "#1976d2", flexShrink: 0,
620+
minWidth: "70px",
621+
fontSize: "0.7rem",
622+
padding: "2px 6px",
623+
lineHeight: 1,
624+
}}
626625
onClick={() => handlePreview(link.data, link.index, true)}
627626
>
628627
Preview
@@ -665,42 +664,76 @@ const DatasetDetailPage: React.FC = () => {
665664
}}
666665
>
667666
{externalLinks.length > 0 ? (
668-
externalLinks.map((link, index) => (
667+
externalLinks.map((link, index) => {
668+
669+
const match = link.url.match(/file=([^&]+)/);
670+
const fileName = match ? match[1] : "";
671+
const isPreviewable = /\.(nii(\.gz)?|bnii|jdt|jdb|jmsh|bmsh)$/i.test(fileName);
672+
673+
return (
669674
<Box
670675
key={index}
671676
sx={{
672-
mt: 1,
673-
p: 1.5,
674-
bgcolor: "white",
675-
borderRadius: 1,
676-
display: "flex",
677-
justifyContent: "space-between",
678-
alignItems: "center",
679-
flexWrap: "wrap",
680-
gap: 2,
681-
border: "1px solid #ddd",
677+
display: "flex",
678+
alignItems: "center",
679+
justifyContent: "space-between",
680+
padding: "6px 10px",
681+
backgroundColor: "white",
682+
borderRadius: "4px",
683+
border: "1px solid #ddd",
684+
mt: 1,
685+
height: "34px",
686+
minWidth: 0,
687+
fontSize: "0.85rem",
682688
}}
683689
>
684-
<Typography sx={{ flexGrow: 1 }}>{link.name}</Typography>
685-
<Box sx={{ display: "flex", gap: 1 }}>
690+
<Typography
691+
sx={{
692+
flexGrow: 1,
693+
whiteSpace: "nowrap",
694+
overflow: "hidden",
695+
textOverflow: "ellipsis",
696+
minWidth: 0,
697+
fontSize: "1rem",
698+
marginRight: "12px",
699+
maxWidth: "calc(100% - 160px)",
700+
}}
701+
title={link.name}
702+
>
703+
{link.name}
704+
</Typography>
705+
<Box sx={{ display: "flex", flexShrink: 0, gap: 1 }}>
686706
<Button
687707
variant="contained"
688708
size="small"
689-
sx={{ backgroundColor: "#1976d2" }}
709+
sx={{ backgroundColor: "#1976d2",
710+
minWidth: "70px",
711+
fontSize: "0.7rem",
712+
padding: "2px 6px",
713+
lineHeight: 1,}}
690714
onClick={() => window.open(link.url, "_blank")}
691715
>
692716
Download
693717
</Button>
718+
{isPreviewable && (
694719
<Button
695720
variant="outlined"
696721
size="small"
722+
sx={{
723+
minWidth: "65px",
724+
fontSize: "0.7rem",
725+
padding: "2px 6px",
726+
lineHeight: 1,
727+
}}
697728
onClick={() => handlePreview(link.url, link.index, false)}
698729
>
699730
Preview
700731
</Button>
732+
)}
701733
</Box>
702734
</Box>
703-
))
735+
);
736+
})
704737
) : (
705738
<Typography sx={{ fontStyle: "italic", mt: 1 }}>No external links found.</Typography>
706739
)}
@@ -728,7 +761,6 @@ const DatasetDetailPage: React.FC = () => {
728761
isInternal={previewIsInternal}
729762
onClose={handleClosePreview}
730763
/>
731-
{/* <div id="chartpanel" style={{ display: "none" }}></div> */}
732764
</Box>
733765
)};
734766

0 commit comments

Comments
 (0)