summaryrefslogtreecommitdiff
path: root/app/client/dashboard/dashboardHeader.component.js
blob: 063cd47707070ef4183481ab0de97fdc1259fd11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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 (
	    <div class='dashboardHeader heading'>
	      <h1>{site.name} cortex</h1>
        {this.renderStatus("GPU", runner.gpu)}
        {this.renderStatus("CPU", runner.cpu)}
	    </div>
    )
  }
  renderStatus(name, gpu){
    if (gpu.status === 'IDLE') {
      return <div>{name} idle</div>
    }
    const task = gpu.task
    let activityPhrase, liveMessage
    if (task.activity === 'live') {
      return (
        <div>
          {name} running <b>{task.module}</b> live on "{task.dataset}"
        </div>
      )
    }
    else {
      return (
        <div>
          {name} {util.gerund(task.activity)} <b>{task.module}</b> on <b>{task.dataset}</b>
          {!!task.epoch && <span>Epoch: {task.epoch} / {task.epochs}<br/></span>}
        </div>
      )
    }
  }
}

const mapStateToProps = state => ({
  runner: state.system.runner,
	site: state.system.site,
})

const mapDispatchToProps = (dispatch, ownProps) => ({
})

export default connect(mapStateToProps, mapDispatchToProps)(DashboardHeader)