blob: 587f2e3dc59ebb51ab2841d6283eaa163a683c78 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom';
import util from '../util'
import actions from '../actions'
class TaskList extends Component {
constructor(props){
super()
}
shouldComponentUpdate(nextProps){
if (nextProps.tasks.length !== this.props.tasks.length) {
return true
}
if (nextProps.tasks[0] !== this.props.tasks[0]) {
return true
}
return false
}
render(){
const { title, tasks } = this.props
let time = 0
const { mapFn, sortFn } = util.sort.orderByFn(this.props.sort || 'date desc')
const taskList = tasks.map(mapFn).sort(sortFn).map(pair => {
const task = pair[1]
const { dataset } = task
let dataset_link, label = "", href = "";
// console.log(task)
switch (task.activity) {
case 'train':
if (task.epoch === 0) {
label += 'latest'
} else {
label += 'ep. ' + task.epoch
}
label += ' + ' + task.epochs
break
case 'augment':
try {
const opt = JSON.parse(task.opt)
label += opt.augment_take + ' x ' + opt.augment_make
} catch (e) {
//
}
default:
break
}
if (task.folder_id) {
href = '/' + task.module +
'/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') +
'/' + task.folder_id + '/'
}
return (
<div className='row'>
<div className='activity'>{task.activity} {task.module}</div>
{task.folder_id
? <div className='dataset'><Link to={href}><span className='datasetName'>{dataset}</span>{label}</Link></div>
: <div className='dataset'><span className='datasetName'>{dataset}</span>{label}</div>
}
<div className={"age " + util.carbon_date(task.updated_at)} title={task.updated_at}>{util.get_age(task.updated_at)}</div>
<div className='options'>
<span className='destroy' onClick={() => this.handleDestroy(task)}>x</span>
</div>
</div>
)
})
return (
<div className='tasklist rows'>
{taskList}
</div>
)
}
handleDestroy(task) {
const yes = confirm('Are you sure you want to delete this task?')
if (yes) {
actions.task.destroy(task)
}
}
}
const mapStateToProps = state => ({
})
const mapDispatchToProps = (dispatch, ownProps) => ({
// actions: bindActionCreators(liveActions, dispatch)
})
export default connect(mapStateToProps, mapDispatchToProps)(TaskList)
|