@@ -94,6 +94,14 @@ const DatasetDetailPage: React.FC = () => {
9494 const [ jsonSize , setJsonSize ] = useState < number > ( 0 ) ;
9595 const [ transformedDataset , setTransformedDataset ] = useState < any > ( null ) ;
9696
97+ // Dataset download button size calculation function
98+ const formatSize = ( sizeInBytes : number ) : string => {
99+ if ( sizeInBytes < 1024 * 1024 ) {
100+ return `${ ( sizeInBytes / 1024 ) . toFixed ( 1 ) } KB` ;
101+ }
102+ return `${ ( sizeInBytes / 1024 / 1024 ) . toFixed ( 2 ) } MB` ;
103+ } ;
104+
97105 // Recursive function to find `_DataLink_`
98106 const extractDataLinks = ( obj : any , path : string ) : ExternalDataLink [ ] => {
99107 const links : ExternalDataLink [ ] = [ ] ;
@@ -223,8 +231,8 @@ const DatasetDetailPage: React.FC = () => {
223231 } )
224232 ) ;
225233
226- console . log ( "🟢 Extracted external links:" , links ) ;
227- console . log ( "🟢 Extracted internal data:" , internalData ) ;
234+ // console.log("🟢 Extracted external links:", links);
235+ // console.log("🟢 Extracted internal data:", internalData);
228236
229237 setExternalLinks ( links ) ;
230238 setInternalLinks ( internalData ) ;
@@ -241,10 +249,21 @@ const DatasetDetailPage: React.FC = () => {
241249
242250 externalLinks . forEach ( ( link ) => {
243251 const url = link . url ;
252+ // console.log("url", url);
244253 const match = url . match ( / f i l e = ( [ ^ & ] + ) / ) ;
254+ // console.log("match", match);
255+ // console.log("match[1]", match?.[1]);
256+ // try {
257+ // const decoded = match?.[1] ? decodeURIComponent(match[1]) : "N/A";
258+ // console.log("decode", decoded);
259+ // } catch (err) {
260+ // console.warn("⚠️ Failed to decode match[1]:", match?.[1], err);
261+ // }
262+
245263 // const filename = match
246264 // ? decodeURIComponent(match[1])
247265 // : `file-${link.index}`;
266+
248267 const filename = match
249268 ? ( ( ) => {
250269 try {
@@ -254,6 +273,7 @@ const DatasetDetailPage: React.FC = () => {
254273 }
255274 } ) ( )
256275 : `file-${ link . index } ` ;
276+ // console.log("filename", filename);
257277
258278 const outputPath = `$HOME/.neurojson/io/${ dbName } /${ docId } /${ filename } ` ;
259279
@@ -669,7 +689,8 @@ const DatasetDetailPage: React.FC = () => {
669689 } }
670690 >
671691 { /* Download Dataset (1 Mb) */ }
672- Download Dataset ({ ( jsonSize / 1024 ) . toFixed ( 0 ) } MB)
692+ { /* Download Dataset ({(jsonSize / 1024).toFixed(0)} MB) */ }
693+ Download Dataset ({ formatSize ( jsonSize ) } )
673694 </ Button >
674695
675696 < Button
0 commit comments