From 18321f234e5261af43624b67c99a4dee3c060ed8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 5 Jun 2018 20:11:11 +0200 Subject: move views into own folder and begin prising away dataset code --- .../modules/samplernn/views/samplernn.import.js | 145 +++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 app/client/modules/samplernn/views/samplernn.import.js (limited to 'app/client/modules/samplernn/views/samplernn.import.js') diff --git a/app/client/modules/samplernn/views/samplernn.import.js b/app/client/modules/samplernn/views/samplernn.import.js new file mode 100644 index 0000000..6f5f78a --- /dev/null +++ b/app/client/modules/samplernn/views/samplernn.import.js @@ -0,0 +1,145 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import * as util from '../../../util' + +import * as samplernnActions from '../samplernn.actions' + +import Select from '../../../common/select.component' +import TextInput from '../../../common/textInput.component' +import Button from '../../../common/button.component' + +import SampleRNNDatasets from '../samplernn.datasets' + +const samplernnModule = { + name: 'samplernn', + datatype: 'audio', +} + +class SampleRNNImport extends Component { + constructor(){ + super() + this.state = { + folder: 1, + import_action: 'Hotlink', + url_base: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4279/', + selected: {}, + } + } + componentWillMount(){ + const id = this.props.match.params.id || localStorage.getItem('samplernn.last_id') + console.log('load dataset:', id) + const { match, samplernn, samplernnActions } = this.props + if (id === 'new') return + if (id) { + if (parseInt(id)) localStorage.setItem('samplernn.last_id', id) + if (! samplernn.folder || samplernn.folder.id !== id) { + samplernnActions.load_directories(id) + } + } + } + render(){ + let datasets = [], folder; + if (this.props.samplernn.data) { + datasets = (this.props.samplernn.data.folders || []).map(folder => { + return [folder.name, folder.id] + }) + folder = this.props.samplernn.data.folderLookup.unsorted + } + return ( +
+
+

Import

+
+
+
+
+
+
+
+
+
+
+

Import to dataset

+ this.setState({ import_action: value })} + /> + this.setState({ url_base: value })} + /> + +
+
+
+ this.toggle(dataset.name, this.state.selected[name]))} + beforeRow={dataset => this.beforeRow(dataset)} + afterRow={dataset => this.afterRow(dataset)} + /> +
+ ) + } + toggle(name){ + this.setState({ + ...this.state, + selected: { + ...this.state.selected, + [name]: !this.state.selected[name], + } + }) + } + beforeRow(dataset){ + // console.log(dataset) + } + afterRow(dataset){ + const name = dataset.name + return ( +
+ +
+ ) + } + doImport(){ + const { samplernn } = this.props + console.log(this.state) + this.props.actions.import_files(this.state, samplernn.data.datasetLookup, samplernn.data.fileLookup) + } +} + +const mapStateToProps = state => ({ + samplernn: state.module.samplernn, + runner: state.system.runner, + task: state.task, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(samplernnActions, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(SampleRNNImport) -- cgit v1.2.3-70-g09d2