@@ -26,7 +26,7 @@ import { Colors } from "design/theme";
2626import { useAppDispatch } from "hooks/useAppDispatch" ;
2727import { useAppSelector } from "hooks/useAppSelector" ;
2828import React , { useEffect , useMemo , useState } from "react" ;
29- import ReactJson from "react-json-view" ;
29+ // import ReactJson from "react-json-view";
3030import { useParams , useNavigate } from "react-router-dom" ;
3131import {
3232 fetchDocumentDetails ,
@@ -74,22 +74,16 @@ const UpdatedDatasetDetailPage: React.FC = () => {
7474 const [ previewIndex , setPreviewIndex ] = useState < number > ( 0 ) ;
7575 const aiSummary = datasetDocument ?. [ ".datainfo" ] ?. AISummary ?? "" ;
7676
77- useEffect ( ( ) => {
78- if ( ! datasetDocument ) {
79- setJsonSize ( 0 ) ;
80- return ;
81- }
82- const bytes = new TextEncoder ( ) . encode (
83- JSON . stringify ( datasetDocument )
84- ) . length ;
85- setJsonSize ( bytes ) ;
86- } , [ datasetDocument ] ) ;
87-
88- // 1) detect subjects at the top level, return true or false
89- const hasTopLevelSubjects = useMemo (
90- ( ) => Object . keys ( datasetDocument || { } ) . some ( ( k ) => / ^ s u b - / i. test ( k ) ) ,
91- [ datasetDocument ]
92- ) ;
77+ // useEffect(() => {
78+ // if (!datasetDocument) {
79+ // setJsonSize(0);
80+ // return;
81+ // }
82+ // const bytes = new TextEncoder().encode(
83+ // JSON.stringify(datasetDocument)
84+ // ).length;
85+ // setJsonSize(bytes);
86+ // }, [datasetDocument]);
9387
9488 const linkMap = useMemo ( ( ) => makeLinkMap ( externalLinks ) , [ externalLinks ] ) ;
9589
@@ -98,26 +92,6 @@ const UpdatedDatasetDetailPage: React.FC = () => {
9892 [ datasetDocument , linkMap ]
9993 ) ;
10094
101- // “rest” JSON only when we actually have subjects
102- // const rest = useMemo(() => {
103- // if (!datasetDocument || !hasTopLevelSubjects) return {};
104- // const r: any = {};
105- // Object.keys(datasetDocument).forEach((k) => {
106- // if (!/^sub-/i.test(k)) r[k] = (datasetDocument as any)[k];
107- // });
108- // return r;
109- // }, [datasetDocument, hasTopLevelSubjects]);
110-
111- // JSON panel should always render:
112- // - if we have subjects -> JSON show "rest" (everything except sub-*)
113- // - if we don't have subjects -> JSON show the whole document
114- // const jsonPanelData = useMemo(
115- // () => (hasTopLevelSubjects ? rest : datasetDocument || {}),
116- // [hasTopLevelSubjects, rest, datasetDocument]
117- // );
118-
119- // 5) header title + counts also fall back
120- // const treeTitle = hasTopLevelSubjects ? "Subjects" : "Files";
12195 const treeTitle = "Files" ;
12296 const filesCount = externalLinks . length ;
12397 const totalBytes = useMemo ( ( ) => {
@@ -268,15 +242,24 @@ const UpdatedDatasetDetailPage: React.FC = () => {
268242 return internalLinks ;
269243 } ;
270244
245+ // useEffect(() => {
246+ // const fetchData = async () => {
247+ // if (dbName && docId) {
248+ // await dispatch(fetchDocumentDetails({ dbName, docId }));
249+ // await dispatch(fetchDbInfoByDatasetId({ dbName, docId }));
250+ // }
251+ // };
252+
253+ // fetchData();
254+ // }, [dbName, docId, dispatch]);
255+
271256 useEffect ( ( ) => {
272- const fetchData = async ( ) => {
273- if ( dbName && docId ) {
274- await dispatch ( fetchDocumentDetails ( { dbName, docId } ) ) ;
275- await dispatch ( fetchDbInfoByDatasetId ( { dbName, docId } ) ) ;
276- }
277- } ;
257+ if ( ! dbName || ! docId ) return ;
278258
279- fetchData ( ) ;
259+ ( async ( ) => {
260+ await dispatch ( fetchDocumentDetails ( { dbName, docId } ) ) ; // render tree ASAP
261+ dispatch ( fetchDbInfoByDatasetId ( { dbName, docId } ) ) ; // don't await
262+ } ) ( ) ;
280263 } , [ dbName , docId , dispatch ] ) ;
281264
282265 useEffect ( ( ) => {
@@ -289,7 +272,10 @@ const UpdatedDatasetDetailPage: React.FC = () => {
289272 index, // Assign index correctly
290273 } )
291274 ) ;
292-
275+ const bytes = new TextEncoder ( ) . encode (
276+ JSON . stringify ( datasetDocument )
277+ ) . length ;
278+ setJsonSize ( bytes ) ;
293279 // Extract Internal Data & Assign `index`
294280 const internalData = extractInternalData ( datasetDocument ) . map (
295281 ( data , index ) => ( {
@@ -414,18 +400,7 @@ const UpdatedDatasetDetailPage: React.FC = () => {
414400 if ( typeof window !== "undefined" && ( window as any ) . __previewType ) {
415401 return ( window as any ) . __previewType === "2d" ;
416402 }
417- // if (window.__previewType) {
418- // console.log("work~~~~~~~");
419- // return window.__previewType === "2d";
420- // }
421- // console.log("is 2d preview candidate !== 2d");
422- // console.log("obj", obj);
423- // if (typeof obj === "string" && obj.includes("db=optics-at-martinos")) {
424- // return false;
425- // }
426- // if (typeof obj === "string" && obj.endsWith(".jdb")) {
427- // return true;
428- // }
403+
429404 if ( ! obj || typeof obj !== "object" ) {
430405 return false ;
431406 }
@@ -434,8 +409,6 @@ const UpdatedDatasetDetailPage: React.FC = () => {
434409 return false ;
435410 }
436411 const dim = obj . _ArraySize_ ;
437- // console.log("array.isarray(dim)", Array.isArray(dim));
438- // console.log("dim.length", dim.length === 1 || dim.length === 2);
439412
440413 return (
441414 Array . isArray ( dim ) &&
@@ -512,18 +485,6 @@ const UpdatedDatasetDetailPage: React.FC = () => {
512485 typeof dataOrUrl === "string" ? extractFileName ( dataOrUrl ) : "" ;
513486 if ( isPreviewableFile ( fileName ) ) {
514487 ( window as any ) . previewdataurl ( dataOrUrl , idx ) ;
515- // const is2D = is2DPreviewCandidate(dataOrUrl);
516- // const panel = document.getElementById("chartpanel");
517- // console.log("is2D", is2D);
518- // console.log("panel", panel);
519-
520- // if (is2D) {
521- // // console.log("📊 2D data → rendering inline with dopreview()");
522- // if (panel) panel.style.display = "block"; // Show it!
523- // setPreviewOpen(false); // Don't open modal
524- // } else {
525- // if (panel) panel.style.display = "none"; // Hide chart panel on 3D external
526- // }
527488 } else {
528489 console . warn ( "⚠️ Unsupported file format for preview:" , dataOrUrl ) ;
529490 }
@@ -871,6 +832,8 @@ const UpdatedDatasetDetailPage: React.FC = () => {
871832 < MetaDataPanel
872833 datasetDocument = { datasetDocument }
873834 dbViewInfo = { dbViewInfo }
835+ dbName = { dbName }
836+ docId = { docId }
874837 />
875838 </ Box >
876839 </ Box >
0 commit comments