pond: pass nodes to connmgr
This commit is contained in:
parent
e77fff82a9
commit
8638057340
@ -5,7 +5,7 @@ class ConnMgr extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return(
|
return(
|
||||||
<Cristal title="Connection Manager">
|
<Cristal title="Connection Manager">
|
||||||
Cmgr
|
{Object.keys(this.props.nodes)}
|
||||||
</Cristal>
|
</Cristal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ class FullNode extends React.Component {
|
|||||||
peers: -1
|
peers: -1
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
this.props.onConnect(client)
|
||||||
|
|
||||||
this.loadInfo()
|
this.loadInfo()
|
||||||
setInterval(this.loadInfo, 1000)
|
setInterval(this.loadInfo, 1000)
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ class NodeList extends React.Component {
|
|||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
existingLoaded: false,
|
existingLoaded: false,
|
||||||
nodes: [],
|
nodes: {},
|
||||||
|
|
||||||
showConnMgr: false,
|
showConnMgr: false,
|
||||||
}
|
}
|
||||||
@ -16,13 +16,20 @@ class NodeList extends React.Component {
|
|||||||
this.spawnNode = this.spawnNode.bind(this)
|
this.spawnNode = this.spawnNode.bind(this)
|
||||||
this.connMgr = this.connMgr.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() {
|
async spawnNode() {
|
||||||
const node = await this.props.client.call('Pond.Spawn')
|
const node = await this.props.client.call('Pond.Spawn')
|
||||||
console.log(node)
|
console.log(node)
|
||||||
this.setState(state => ({nodes: state.nodes.concat(node)}))
|
this.setState(state => ({nodes: {...state.nodes, [node.ID]: node}}))
|
||||||
}
|
}
|
||||||
|
|
||||||
connMgr() {
|
connMgr() {
|
||||||
@ -43,10 +50,13 @@ class NodeList extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{
|
{
|
||||||
this.state.nodes.map((node, i) => {
|
Object.keys(this.state.nodes).map(n => {
|
||||||
|
const node = this.state.nodes[n]
|
||||||
|
|
||||||
return (<FullNode key={node.ID}
|
return (<FullNode key={node.ID}
|
||||||
node={node}
|
node={{...node}}
|
||||||
pondClient={this.props.client}/>)
|
pondClient={this.props.client}
|
||||||
|
onConnect={conn => this.setState(prev => ({nodes: {...prev.nodes, [n]: {...node, conn: conn}}}))}/>)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
{connMgr}
|
{connMgr}
|
||||||
|
Loading…
Reference in New Issue
Block a user