summaryrefslogtreecommitdiff
path: root/app/client/modules/samplernn/datasets.component.js
blob: 5f45cf22595967bd97a7b9703ae9a4aec270f57f (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

import { actions } from '../../api'
  // folderActions.index({ module: 'samplernn' })
  // folderActions.show(12)
  // folderActions.create({ module: 'samplernn', name: 'foo' })
  // folderActions.update(12, { module: 'pix2pix' })
  // folderActions.destroy(12, { confirm: true })
  // folderActions.upload(12, form_data)

import Group from '../../common/group.component'
import Slider from '../../common/slider.component'
import Select from '../../common/select.component'
import Button from '../../common/button.component'
import FileUpload from '../../common/fileUpload.component'
import TextInput from '../../common/textInput.component'

class SampleRNNDatasets extends Component {
  constructor(props){
    super()
    // fetch file list
    this.handleName = this.handleName.bind(this)
    this.handleUpload = this.handleUpload.bind(this)
    this.handleURL = this.handleURL.bind(this)
    props.actions.folder.index({ module: 'samplernn' })
    props.actions.file.index({ module: 'samplernn' })
  }
  handleName(name) {
    const folder = this.props.samplernn.folder
    console.log(name)
    if (! folder.id) {
      this.props.actions.folder.create({
        module: 'samplernn',
        name
      })
    } else {
      this.props.actions.folder.update({
        id: folder.id,
        module: 'samplernn',
        name
      })
    }
  }
  handleUpload(file) {
    
  }
  handleURL(url) {

  }
  render(){
    const { samplernn } = this.props
    console.log(samplernn)
    return (
      <div className='app'>
        <div className='heading'>
          <h3>SampleRNN</h3>
        </div>
        <div className='params row'>
          <div className='column'>
            <Group title='Dataset'>
              <TextInput
                title='Dataset name'
                value={samplernn.folder.name}
                onSave={this.handleName}
              />
              <FileUpload
                title='Upload a file'
                onChange={this.handleUpload}
              />
              <TextInput
                title='Fetch a URL'
                onSave={this.handleURL}
              />
            </Group>
          </div>
        </div>
        <div className='params row'>
          <h3>Files</h3>
          <div className="media">
            <div className="row">
              <div className="filename">foo.mp3</div>
              <div className="size">1.2 mb</div>
              <div className="date">30 May 2018</div>
              <div className="epoch">epoch 30</div>
              <div className="options">
                delete
              </div>
            </div>
          </div>
        </div>
      </div>
    )
  }
}

const mapStateToProps = state => ({
  samplernn: state.module.samplernn
})

const mapDispatchToProps = (dispatch, ownProps) => ({
  actions: {
    folder: bindActionCreators(actions.folder, dispatch),
    file: bindActionCreators(actions.file, dispatch),
    task: bindActionCreators(actions.task, dispatch),
  }
})

export default connect(mapStateToProps, mapDispatchToProps)(SampleRNNDatasets)