pond: render checkbox grid for connecting

This commit is contained in:
Łukasz Magiera 2019-07-24 22:34:40 +02:00
parent 8638057340
commit 7cc6d7f8cf

View File

@ -2,10 +2,44 @@ import React from 'react';
import Cristal from 'react-cristal' import Cristal from 'react-cristal'
class ConnMgr extends React.Component { class ConnMgr extends React.Component {
constructor(props) {
super(props)
this.connect = this.connect.bind(this)
}
connect(action, from, to) {
if (action) {
console.log("conn", from, to)
}
}
render() { render() {
const nodes = this.props.nodes
let keys = Object.keys(nodes)
// T O - -
// F
// R
// O
// M
//
const rows = keys.filter((_, i) => i > 0).map((k, i) => {
const cols = keys.filter((_, j) => i >= j).map((kt, i) => {
return (<td><input type="checkbox" onChange={e => this.connect(e.target.checked, k, kt)}/></td>)
})
return (
<tr><td>{k}</td>{cols}</tr>
)
})
return( return(
<Cristal title="Connection Manager"> <Cristal title="Connection Manager">
{Object.keys(this.props.nodes)} <table>
<thead><tr><td></td>{keys.slice(0, -1).map((i) => (<td>{i}</td>))}</tr></thead>
<tbody>{rows}</tbody>
</table>
</Cristal> </Cristal>
) )
} }