diff --git a/testbed/front/src/ConnMgr.js b/testbed/front/src/ConnMgr.js
index 4093d3023..49c088abc 100644
--- a/testbed/front/src/ConnMgr.js
+++ b/testbed/front/src/ConnMgr.js
@@ -5,7 +5,7 @@ class ConnMgr extends React.Component {
render() {
return(
- Cmgr
+ {Object.keys(this.props.nodes)}
)
}
diff --git a/testbed/front/src/FullNode.js b/testbed/front/src/FullNode.js
index dd0f28434..b92e17eb0 100644
--- a/testbed/front/src/FullNode.js
+++ b/testbed/front/src/FullNode.js
@@ -41,6 +41,8 @@ class FullNode extends React.Component {
peers: -1
}))
+ this.props.onConnect(client)
+
this.loadInfo()
setInterval(this.loadInfo, 1000)
})
diff --git a/testbed/front/src/NodeList.js b/testbed/front/src/NodeList.js
index 6524bfbb0..f396e0454 100644
--- a/testbed/front/src/NodeList.js
+++ b/testbed/front/src/NodeList.js
@@ -7,7 +7,7 @@ class NodeList extends React.Component {
super(props)
this.state = {
existingLoaded: false,
- nodes: [],
+ nodes: {},
showConnMgr: false,
}
@@ -16,13 +16,20 @@ class NodeList extends React.Component {
this.spawnNode = this.spawnNode.bind(this)
this.connMgr = this.connMgr.bind(this)
- this.props.client.call('Pond.Nodes').then(nodes => this.setState({existingLoaded: true, nodes: nodes}))
+ this.getNodes()
+ }
+
+ async getNodes() {
+ const nds = await this.props.client.call('Pond.Nodes')
+ const nodes = nds.reduce((o, i) => {o[i.ID] = i; return o}, {})
+ console.log('nds', nodes)
+ this.setState({existingLoaded: true, nodes: nodes})
}
async spawnNode() {
const node = await this.props.client.call('Pond.Spawn')
console.log(node)
- this.setState(state => ({nodes: state.nodes.concat(node)}))
+ this.setState(state => ({nodes: {...state.nodes, [node.ID]: node}}))
}
connMgr() {
@@ -43,10 +50,13 @@ class NodeList extends React.Component {
{
- this.state.nodes.map((node, i) => {
+ Object.keys(this.state.nodes).map(n => {
+ const node = this.state.nodes[n]
+
return ()
+ node={{...node}}
+ pondClient={this.props.client}
+ onConnect={conn => this.setState(prev => ({nodes: {...prev.nodes, [n]: {...node, conn: conn}}}))}/>)
})
}
{connMgr}