diff options
Diffstat (limited to 'app/client/dataset/dataset.component.js')
| -rw-r--r-- | app/client/dataset/dataset.component.js | 60 |
1 files changed, 8 insertions, 52 deletions
diff --git a/app/client/dataset/dataset.component.js b/app/client/dataset/dataset.component.js index 45f88dc..ebea8c9 100644 --- a/app/client/dataset/dataset.component.js +++ b/app/client/dataset/dataset.component.js @@ -2,7 +2,7 @@ import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import { actions, parser } from '../api' +import * as datasetActions from './dataset.actions' import Group from '../common/group.component' import Param from '../common/param.component' @@ -19,59 +19,16 @@ class Dataset extends Component { this.pickFile = this.pickFile.bind(this) } handleName(name) { - const { module, folder } = this.props - if (! folder.id) { - this.props.actions.folder.create({ - // username... should get added inside the API - module: module.name, - datatype: module.datatype, - activity: 'dataset', - name - }) - } else { - this.props.actions.folder.update({ - id: folder.id, - module: module.name, - datatype: module.datatype, - activity: 'dataset', - name - }) - } + const { module, folder, actions } = this.props + actions.dataset.createOrUpdateFolder(module, folder) } handleUpload(file) { - const { module, folder } = this.props - const fd = new FormData() - fd.append('file', file) - this.props.actions.folder.upload(fd, { - id: folder.id, - module: module.name, - activity: 'file', - epoch: 0, - processed: false, - generated: false, - }) + const { module, folder, actions } = this.props + actions.dataset.uploadFile(module, folder, file) } handleURL(url) { - // name url - // mime datatype - // duration analysis - // size activity - // opt created_at updated_at - parser.parse(url, media => { - if (!media) return - console.log('media', media) - this.props.actions.file.create({ - folder_id: this.props.folder.id, - module: this.props.module.name, - activity: 'url', - duration: parseInt(media.duration) || 0, - epoch: 0, - processed: false, - generated: false, - opt: media, - url - }) - }) + const { module, folder, actions } = this.props + actions.dataset.fetchURL(module, folder, url) } pickFile(file){ console.log('pick', file) @@ -139,8 +96,7 @@ const mapStateToProps = state => state.dataset const mapDispatchToProps = (dispatch, ownProps) => ({ actions: { - folder: bindActionCreators(actions.folder, dispatch), - file: bindActionCreators(actions.file, dispatch), + dataset: bindActionCreators(datasetActions, dispatch), } }) |
