1- import React from "react" ;
1+ import React , { useEffect } from "react" ;
22import { Box , Typography , IconButton , Drawer , Grid , Card , CardContent , CardActions , Button } from "@mui/material" ;
33import CloseIcon from "@mui/icons-material/Close" ;
44import { NodeObject } from "modules/universe/NeuroJsonGraph" ;
55import { Colors } from "design/theme" ;
6+ import { useNavigate } from "react-router-dom" ;
7+ import { useAppDispatch } from "hooks/useAppDispatch" ;
8+ import { useAppSelector } from "hooks/useAppSelector" ;
9+ import { RootState } from "redux/store" ;
10+ import { fetchDbInfo } from "redux/neurojson/neurojson.action" ;
11+
612
713interface NodeInfoPanelProps {
814 open : boolean ;
@@ -11,13 +17,25 @@ interface NodeInfoPanelProps {
1117}
1218
1319const NodeInfoPanel : React . FC < NodeInfoPanelProps > = ( { open, onClose, nodeData } ) => {
14- console . log ( "nodeData:" , nodeData ) ;
20+ // console.log("nodeData:", nodeData);
21+ const navigate = useNavigate ( ) ;
22+ const dispatch = useAppDispatch ( ) ;
23+ const dbInfo = useAppSelector ( ( state : RootState ) => state . neurojson . dbInfo ) ;
24+ const loading = useAppSelector ( ( state : RootState ) => state . neurojson . loading ) ;
25+ console . log ( "dbInfo" , dbInfo ) ;
26+
27+ useEffect ( ( ) => {
28+ if ( nodeData ?. id ) {
29+ dispatch ( fetchDbInfo ( nodeData . id . toLowerCase ( ) ) ) ;
30+ }
31+ } , [ nodeData , dispatch ] )
32+
1533 return (
1634 < Drawer
1735 anchor = "right"
18- // open={true}
1936 open = { open }
2037 onClose = { onClose }
38+ // container={document.body}
2139 sx = { {
2240 "& .MuiDrawer-paper" : {
2341 width : "30%" ,
@@ -53,34 +71,40 @@ const NodeInfoPanel: React.FC<NodeInfoPanelProps> = ({ open, onClose, nodeData }
5371
5472 < Grid item xs = { 12 } >
5573 < Typography > Data Types</ Typography >
56- < Typography > { nodeData . datatype . join ( "," ) } </ Typography >
74+ < Typography > { nodeData . datatype . join ( ", " ) } </ Typography >
5775 </ Grid >
5876
5977 < Grid item xs = { 12 } >
6078 < Typography > Data Standards</ Typography >
61- < Typography > { nodeData . standard . join ( "," ) } </ Typography >
79+ < Typography > { nodeData . standard . join ( ", " ) } </ Typography >
6280 </ Grid >
6381
6482 < Grid item xs = { 12 } >
6583 < Typography > Upstream Contact</ Typography >
66- < Typography > { nodeData . support } </ Typography >
84+ < a href = { `mailto:${ nodeData . support } ` } style = { { textDecoration : "none" , color : "blue" } } >
85+ < Typography > { nodeData . support } </ Typography >
86+ </ a >
6787 </ Grid >
6888
6989 < Grid item xs = { 12 } >
7090 < Typography > NeuroJSON-Cuated Datasets</ Typography >
91+ { dbInfo ?( < Typography > { dbInfo . doc_count - 1 } </ Typography > ) : "Coming soon " }
7192 </ Grid >
7293 </ Grid >
7394 { /*database info card*/ }
74- < Card sx = { { mt :2 , backgroundColor : Colors . white } } >
95+ { dbInfo ? (
96+ < Card sx = { { mt :2 , backgroundColor : Colors . white } } >
7597 < CardContent >
7698 < Grid container spacing = { 1 } >
7799 < Grid item xs = { 12 } >
78100 < Typography > NeuroJSON.io Database Name</ Typography >
79- < Typography > </ Typography >
101+ < Typography > { dbInfo . db_name } </ Typography >
80102 </ Grid >
81103 < Grid item xs = { 12 } >
82104 < Typography > REST-API URL</ Typography >
83- < Typography > </ Typography >
105+ < a href = { `https://neurojson.io:7777/${ dbInfo . db_name } ` } target = "_blank" rel = "noopener noreferrer" >
106+ { `https://neurojson.io:7777/${ dbInfo . db_name } ` }
107+ </ a >
84108 </ Grid >
85109 < Grid item xs = { 12 } >
86110 < Typography > Database Creation Time</ Typography >
@@ -109,6 +133,7 @@ const NodeInfoPanel: React.FC<NodeInfoPanelProps> = ({ open, onClose, nodeData }
109133 backgroundColor : Colors . primary . dark ,
110134 } ,
111135 } }
136+ onClick = { ( ) => navigate ( `/databases/${ nodeData . id } ` ) }
112137 >
113138 Browse Database
114139 </ Button >
@@ -154,6 +179,7 @@ const NodeInfoPanel: React.FC<NodeInfoPanelProps> = ({ open, onClose, nodeData }
154179 backgroundColor : Colors . primary . dark ,
155180 } ,
156181 } }
182+ onClick = { ( ) => window . open ( `https://github.com/NeuroJSON-io/${ nodeData . id } ` , "_blank" , "noopener noreferrer" ) }
157183 >
158184 DownLoad Database
159185 </ Button >
@@ -162,18 +188,13 @@ const NodeInfoPanel: React.FC<NodeInfoPanelProps> = ({ open, onClose, nodeData }
162188 </ CardActions >
163189
164190 </ Card >
165- { /* <Box display="flex" flexDirection="column">
166- <Box>
167- <Typography><strong>NeuroJSON.io Database Name</strong></Typography>
168- <Typography><strong>REST-API URL</strong></Typography>
169- <Typography><strong>Database Creation Time</strong></Typography>
170- <Typography><strong>Searchable Database Size</strong></Typography>
171- <Typography><strong>DatabaseDisk Size_compressed</strong></Typography>
172- </Box>
173- </Box> */ }
191+ ) : (
192+ < Typography > Select a node to see database info.</ Typography >
193+ ) }
194+
174195 </ >
175196 ) : (
176- < Typography > Select a node to see metadata .</ Typography >
197+ < Typography > Select a node to see database info .</ Typography >
177198 ) }
178199 </ Box >
179200 </ Drawer >
0 commit comments