import { h, Component } from 'preact' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import util from '../util' class DashboardHeader extends Component { constructor(props){ super(props) this.handleClick = this.handleClick.bind(this) } handleClick(e){ this.props.onClick && this.props.onClick() } render() { const { site, runner } = this.props return (

{site.name} cortex

{this.renderStatus("GPU", runner.gpu)} {this.renderStatus("CPU", runner.cpu)}
) } renderStatus(name, gpu){ if (gpu.status === 'IDLE') { return
{name} idle
} const task = gpu.task let activityPhrase, liveMessage if (task.activity === 'live') { return (
{name} running {task.module} live on "{task.dataset}"
) } else { return (
{name} {util.gerund(task.activity)} {task.module} on {task.dataset} {!!task.epoch && Epoch: {task.epoch} / {task.epochs}
}
) } } } const mapStateToProps = state => ({ runner: state.system.runner, site: state.system.site, }) const mapDispatchToProps = (dispatch, ownProps) => ({ }) export default connect(mapStateToProps, mapDispatchToProps)(DashboardHeader)