summaryrefslogtreecommitdiff
path: root/app/client/modules/samplernn/samplernn.actions.js
blob: 5bf8a376726b7773d364021b46a39b1cd5d012ec (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
import socket from '../../socket'
import types from '../../types'

import actions from '../../actions'

export const load_directories = () => (dispatch) => {
  // load datasets
  // load directories from server
  console.log(actions)
  Promise.all([
    actions.folder.index({ module: 'samplernn' }),
    actions.file.index({ module: 'samplernn' }),
    actions.task.index({ module: 'samplernn' }),
    actions.socket.list_directory({ module: 'samplernn', dir: 'results' }),
    actions.socket.list_directory({ module: 'samplernn', dir: 'datasets' }),
  ]).then(res => {
    console.log(res)
    const [folders, files, results, datasets] = res
    console.log(folders.length, files.length, results.length, datasets.length)
    dispatch({
      type: types.samplernn.init,
      data: { folders, files, results, datasets },
    })
  })
}

export const fetch_url = (url) => (dispatch) => {
  console.log(url)
  actions.task.start_task({
    activity: 'fetch',
    module: 'samplernn',
    dataset: 'test',
    epochs: 1,
    opt: { url }
  }, { preempt: true, watch: true })
}