diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-09-05 13:28:55 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-09-05 13:28:55 +0200 |
| commit | a4f6d0e9afa4993437e3031aaa4771f268ce4d99 (patch) | |
| tree | 1524924ff751f752a8db6341f08b152d9dcb11b6 /app/client/common/taskList.component.js | |
| parent | ead43de436c7e625a77b0103e70ba0100ad52f8e (diff) | |
app
Diffstat (limited to 'app/client/common/taskList.component.js')
| -rw-r--r-- | app/client/common/taskList.component.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/app/client/common/taskList.component.js b/app/client/common/taskList.component.js new file mode 100644 index 0000000..f6383e0 --- /dev/null +++ b/app/client/common/taskList.component.js @@ -0,0 +1,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(this.props.sort || '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) |
