summaryrefslogtreecommitdiff
path: root/app/client/common/currentTask.component.js
blob: ef976bc848fb453010d17250e85a866d7d9bbf60 (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
import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import util from '../util'

// import { Loading, CurrentTask, FileList, FileRow } from '../../../common'

function CurrentTask ({ cpu, gpu, processor }) {
  let processor_name
  if (processor) {
    processor_name = processor === 'cpu' ? 'cpu' : 'gpu'
  } else if (gpu.status !== 'IDLE') {
    processor_name = 'gpu'
  } else if (cpu.status !== 'IDLE') {
    processor_name = 'cpu'
  }
  const p = processor_name === 'cpu' ? cpu : gpu
  if (!p) return <div></div>
  if (p.status === 'IDLE') {
    return <div>{processor_name} idle</div>
  }
  const { last_message, pid, task } = p
  const { activity, epoch, epochs, dataset, module } = task
  return (
    <div className='currentTask'>
      #{pid}: <b>{module} {activity}</b> <i>{dataset}</i>
      {!!epochs
        ? <span>{epochs} epoch{util.courtesy_s(epochs)}</span>
        : ""}
      {epoch
        ? <span>(currently #{epoch})</span>
        : ""}
      <br/><br/>
      <div className='quiet'>{last_message}</div>
    </div>
  )
}

const mapStateToProps = state => state.system.runner

const mapDispatchToProps = (dispatch, ownProps) => ({
  // actions: bindActionCreators(samplernnActions, dispatch),
  // remote: bindActionCreators(samplernnTasks, dispatch),
  // audioPlayer: bindActionCreators(audioPlayerActions, dispatch),
})

export default connect(mapStateToProps, mapDispatchToProps)(CurrentTask)