blob: 3de6efebec671c2aebbc88d49fd281064a5215cc (
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 { 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]
const { dataset } = task
let dataset_link;
if (task.folder_id) {
const href = '/' + task.module +
'/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') +
'/' + task.folder_id + '/'
dataset_link = <Link to={href}>{dataset}</Link>
} else {
dataset_link = dataset
}
return (
<div class='row'>
<div class='activity'>{task.activity} {task.module}</div>
<div class='dataset'>{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)
|