summaryrefslogtreecommitdiff
path: root/app/client/modules/samplernn/samplernn.import.js
blob: 62a210dbb1dc03204d4b744a56cae7f6b14f8bc9 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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 SampleRNNDatasets from './samplernn.datasets'

const samplernnModule = {
  name: 'samplernn',
  datatype: 'audio',
}

class SampleRNNImport extends Component {
  constructor(){
    super()
    this.state = {
      folder: 1,
      url_base: ''
    }
  }
  render(){
    let datasets = [];
    if (this.props.samplernn.data) {
      datasets = (this.props.samplernn.data.folders || []).map(folder => {
        console.log(folder.id, folder.name)
        return [folder.name, folder.id]
      })
      console.log(datasets)
    }
    return (
      <div className='app'>
        <div class='heading'>
          <h1>Import</h1>
        </div>
        <div class='params form row'>
          <div class='col'>
            <h2>Import to dataset</h2>
            <Select
              title='Destination dataset'
              options={datasets}
              name='folder'
              opt={this.state}
              onChange={(name, value) => this.setState({ folder: value })}
            />
            <TextInput
              title="URL base"
              value={this.state.url_base}
              placeholder="http://"
              onSave={(value) => this.setState({ url_base: value })}
            />
          </div>
        </div>
        <SampleRNNDatasets
          id="unsorted"
          history={this.props.history}
          beforeRow={dataset => this.beforeRow(dataset)}
          afterRow={dataset => this.afterRow(dataset)}
        />
      </div>
    )
  }
  beforeRow(dataset){
    // console.log(dataset)
    return null
  }
  afterRow(dataset){
    return null
  }
}

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)