blob: 8817096afbcc58700a01a54de32612a4eedeb03f (
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
|
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()
}
render(){
const { title, tasks } = this.props
let time = 0
const { mapFn, sortFn } = util.sort.orderByFn('date desc')
const taskList = tasks.map(mapFn).sort(sortFn).map(pair => {
const task = pair[1]
console.log(task)
const { dataset } = task
const href = '/' + task.module +
'/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') +
'/' + task.folder_id + '/'
return (
<div class='row'>
<div class='activity'>{task.activity} {task.module}</div>
<div class='dataset'><Link to={href}>{dataset}</Link></div>
<div className={"age " + util.carbon_date(task.updated_at)}>{util.get_age(task.updated_at)}</div>
<div class='options'>
<span class='destroy' onClick={() => this.handleDestroy(task)}>x</span>
</div>
</div>
)
})
return (
<div class='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)
|