@@ -7,42 +7,49 @@ import TreeView from '@material-ui/lab/TreeView';
77import TreeItem from '@material-ui/lab/TreeItem' ;
88import ExpandMoreIcon from '@material-ui/icons/ExpandMore' ;
99import ChevronRightIcon from '@material-ui/icons/ChevronRight' ;
10- import Visibility from '@material-ui/icons/Visibility' ;
11- import ColorLens from '@material-ui/icons/ColorLens' ;
10+ import ControlPanelTreeItem from './ControlPanelTreeItem' ;
1211
1312import { MODEL_STATE } from '../../constants' ;
1413
15- const useStyles = makeStyles ( ( ) => ( {
16- networkItem : {
17- '&:hover' : {
18- '& .MuiSvgIcon-root' : {
19- display : 'block' ,
20- } ,
21- } ,
22- } ,
23- } ) ) ;
24-
2514const ExperimentControlPanel = ( props ) => {
26- const classes = useStyles ( ) ;
27- const [ state , setState ] = React . useState ( true ) ;
2815 const [ filter , setFilter ] = React . useState ( '' ) ;
29- console . log ( 'Instances from control panel' , window . Instances ) ;
16+ const onNodeSelect = ( event , nodeId ) => {
17+ console . log ( `Node with id ${ nodeId } clicked` ) ;
18+ } ;
3019
31- const NetworkItem = ( props ) => (
32- < Box className = { classes . networkItem } display = "flex" flexDirection = "row" justifyContent = "space-between" >
33- < Box > { props . name } </ Box >
34- < Box > { props . type } </ Box >
35- < Box display = "none" >
36- < span > < Visibility /> </ span >
37- < span > < ColorLens /> </ span >
38- </ Box >
39- </ Box >
40- ) ;
20+ const onVisibilityClick = ( event , nodeId ) => {
21+ console . log ( `Visibility of node with id of ${ nodeId } clicked.` ) ;
22+ } ;
23+
24+ const onColorClick = ( event , nodeId ) => {
25+ console . log ( `Color of node with id of ${ nodeId } clicked` ) ;
26+ } ;
27+
28+ const getTreeItemsFromData = ( treeItems ) => treeItems . map ( ( treeItemData ) => {
29+ let children ;
30+ if ( treeItemData . getChildren ( ) && treeItemData . getChildren ( ) . length > 0 ) {
31+ children = getTreeItemsFromData ( treeItemData . getChildren ( ) ) ;
32+ }
33+
34+ console . log ( 'inside getTreeItemsFromData' ) ;
35+
36+ return (
37+ < ControlPanelTreeItem
38+ nodeId = { treeItemData . id }
39+ label = { treeItemData . getPath ( ) }
40+ type = { treeItemData . id }
41+ onNodeSelect = { onNodeSelect }
42+ onVisibilityClick = { onVisibilityClick }
43+ >
44+ { children }
45+ </ ControlPanelTreeItem >
46+ ) ;
47+ } ) ;
4148
4249 return (
4350 < >
4451 {
45- window . Instances // temporary, change to props.modelState === MODEL_STATE.INSTANTIATED
52+ window . Instances // temporary change to -> props.modelState === MODEL_STATE.INSTANTIATED
4653 ? (
4754 window . Instances
4855 ? (
@@ -57,8 +64,9 @@ const ExperimentControlPanel = (props) => {
5764 defaultCollapseIcon = { < ExpandMoreIcon /> }
5865 defaultExpandIcon = { < ChevronRightIcon /> }
5966 >
60- { /* <NetworkItem name="network_name" type="network_type" /> */ }
61- < TreeItem label = "test tree item" />
67+ < TreeItem nodeId = "network" label = "network_netpyne" >
68+ { getTreeItemsFromData ( window . Instances . network . getChildren ( ) ) }
69+ </ TreeItem >
6270 </ TreeView >
6371 </ Box >
6472 )
0 commit comments