blob: d27a3243a577734b642e1e81b383be5dcde5b22e (
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
58
59
60
61
|
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 } = this.props
return (
<div class='dashboardHeader heading'>
<h1>{site.name} cortex</h1>
{this.renderGPUStatus()}
</div>
)
}
renderGPUStatus(){
const { runner } = this.props
const gpu = runner.cpu
if (gpu.status === 'IDLE') {
return null
}
const task = gpu.task
const eta = ((task.epochs - (task.epoch || 0)) * 180 / 60) + " minutes"
let activityPhrase, liveMessage
if (task.activity === 'live') {
return (
<div>
Currently running {task.module} live on "{task.dataset}"
</div>
)
}
else {
return (
<div>
Currently {util.gerund(task.activity)} {task.module} on {task.dataset}<br/>
Epoch: {task.epoch} / {task.epochs}, ETA {eta}<br/>
<br />
Want to play live? <button>Pause at the end of this epoch</button>
</div>
)
}
}
}
const mapStateToProps = state => ({
runner: state.system.runner,
site: state.system.site,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
})
export default connect(mapStateToProps, mapDispatchToProps)(DashboardHeader)
|