diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-09-16 16:39:27 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-09-16 16:39:27 +0200 |
| commit | d94c415168b20dd43848dd7c8c77c07d8d4528d4 (patch) | |
| tree | a05f0596359891605d9154e98f720903eee28bd9 /app/client/common | |
| parent | 14652eecb0fb4ebcb14e830504bfb02017bd010e (diff) | |
s00per k3wl 0bj3ct d357rUc7ur1nG
Diffstat (limited to 'app/client/common')
| -rw-r--r-- | app/client/common/buttonGrid.component.js | 73 | ||||
| -rw-r--r-- | app/client/common/currentTask.component.js | 6 |
2 files changed, 49 insertions, 30 deletions
diff --git a/app/client/common/buttonGrid.component.js b/app/client/common/buttonGrid.component.js index 4b86d62..6c7c105 100644 --- a/app/client/common/buttonGrid.component.js +++ b/app/client/common/buttonGrid.component.js @@ -1,32 +1,51 @@ import { h, Component } from 'preact' -export default function ButtonGrid(props) { - const max = props.max || Infinity - return ( - <table className='buttonGrid'> - <tr className='row'> - <th>{" "}</th> - {props.x.map(x => ( - <th>{x}</th> - ))} - </tr> - {props.y.map(y => ( +export default class ButtonGrid extends Component { + state = { + x: 0, y: 0, + } + + render() { + const { + x: _x, + y: _y, + } = this.state + const { + x: X, + y: Y, + max = Infinity, + onClick, + onHover, + } = this.props + return ( + <table className='buttonGrid'> <tr className='row'> - <th>{y}</th> - {props.x.map(x => ( - <td> - {x * y > max ? " " : - <button - onClick={() => props.onClick(x, y)} - onMouseEnter={() => props.onHover(x, y)} - > - {" "} - </button> - } - </td> + <th>{" "}</th> + {X.map(x => ( + <th className={x === _x && 'bold'}>{x}</th> ))} - </tr> - ))} - </table> - ) + </tr> + {Y.map(y => ( + <tr className='row'> + <th className={y === _y && 'bold'}>{y}</th> + {X.map(x => ( + <td> + {x * y > max ? " " : + <button + onClick={() => onClick(x, y)} + onMouseEnter={() => { + this.setState({ x, y }) + onHover(x, y) + }} + > + {" "} + </button> + } + </td> + ))} + </tr> + ))} + </table> + ) + } } diff --git a/app/client/common/currentTask.component.js b/app/client/common/currentTask.component.js index a4d9750..3c71a88 100644 --- a/app/client/common/currentTask.component.js +++ b/app/client/common/currentTask.component.js @@ -22,10 +22,10 @@ function CurrentTask ({ cpu, gpu, processor }) { const { last_message, pid, task } = p const { activity, epoch, epochs, dataset, module } = task return ( - <div> + <div className='currentTask'> #{pid}: <b>{module} {activity}</b> <i>{dataset}</i> - {epochs - ? <span>{epoch} epoch{util.courtesy_s(epoch)}</span> + {!!epochs + ? <span>{epochs} epoch{util.courtesy_s(epochs)}</span> : ""} {epoch ? <span>(currently #{epoch})</span> |
