@@ -16,8 +16,25 @@ interface NodeInfoPanelProps {
1616 nodeData : NodeObject | null ;
1717}
1818
19+ // helper function to covert the database size format
20+ const formatSize = ( bytes ?: number ) : string => {
21+ if ( bytes === undefined ) return "N/A" ;
22+ if ( bytes >= 1_073_741_824 ) {
23+ return `${ Math . floor ( bytes / 1_073_741_824 ) } Gb` ;
24+ } else if ( bytes >= 1_048_576 ) {
25+ return `${ Math . floor ( bytes / 1_048_576 ) } Mb` ;
26+ } else if ( bytes >= 1024 ) {
27+ return `${ Math . floor ( bytes / 1024 ) } Kb` ;
28+ } else {
29+ return `${ bytes } Bytes` ;
30+ }
31+ } ;
32+
33+ // 1 Kilobyte (KB) = 1,024 Bytes
34+ // 1 Megabyte (MB) = 1,024 KB = 1,048,576 Bytes (1024*1024)
35+ // 1 Gigabyte (GB) = 1,024 MB = 1,073,741,824 Bytes (1024*1024*1024)
36+
1937const NodeInfoPanel : React . FC < NodeInfoPanelProps > = ( { open, onClose, nodeData } ) => {
20- // console.log("nodeData:", nodeData);
2138 const navigate = useNavigate ( ) ;
2239 const dispatch = useAppDispatch ( ) ;
2340 const dbInfo = useAppSelector ( ( state : RootState ) => state . neurojson . dbInfo ) ;
@@ -35,7 +52,7 @@ const NodeInfoPanel: React.FC<NodeInfoPanelProps> = ({ open, onClose, nodeData }
3552 anchor = "right"
3653 open = { open }
3754 onClose = { onClose }
38- // container={document.body}
55+ container = { document . body }
3956 sx = { {
4057 "& .MuiDrawer-paper" : {
4158 width : "30%" ,
@@ -112,11 +129,11 @@ const NodeInfoPanel: React.FC<NodeInfoPanelProps> = ({ open, onClose, nodeData }
112129 </ Grid >
113130 < Grid item xs = { 12 } >
114131 < Typography > Searchable Database Size</ Typography >
115- < Typography > </ Typography >
132+ < Typography > { formatSize ( dbInfo . sizes ?. external ) } </ Typography >
116133 </ Grid >
117134 < Grid item xs = { 12 } >
118- < Typography > DatabaseDisk Size_compressed </ Typography >
119- < Typography > </ Typography >
135+ < Typography > DatabaseDisk Size (compressed) </ Typography >
136+ < Typography > { formatSize ( dbInfo . sizes ?. file ) } </ Typography >
120137 </ Grid >
121138 </ Grid >
122139 </ CardContent >
0 commit comments