diff options
Diffstat (limited to 'app/client/modules')
| -rw-r--r-- | app/client/modules/samplernn/datasets.component.js | 37 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 47 |
2 files changed, 58 insertions, 26 deletions
diff --git a/app/client/modules/samplernn/datasets.component.js b/app/client/modules/samplernn/datasets.component.js index ae51c0f..441c17b 100644 --- a/app/client/modules/samplernn/datasets.component.js +++ b/app/client/modules/samplernn/datasets.component.js @@ -2,7 +2,7 @@ import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import { actions } from '../../api' +import { actions, parser } from '../../api' import * as taskActions from '../../task/task.actions' import * as systemActions from '../../system/system.actions' // folderActions.index({ module: 'samplernn' }) @@ -72,15 +72,20 @@ class SampleRNNDatasets extends Component { // duration analysis // size activity // opt created_at updated_at - const folder = this.props.samplernn.folder - this.props.actions.file.create({ - folder_id: folder.id, - module: 'samplernn', - activity: 'url', - epoch: 0, - processed: false, - generated: false, - url + parser.parse(url, media => { + if (!media) return + console.log('media', media) + return + const folder = this.props.samplernn.folder + this.props.actions.file.create({ + folder_id: folder.id, + module: 'samplernn', + activity: 'url', + epoch: 0, + processed: false, + generated: false, + url + }) }) } fetchURL(url) { @@ -122,6 +127,8 @@ class SampleRNNDatasets extends Component { } render(){ const { samplernn } = this.props + console.log(samplernn.upload) + // sort files?? return ( <div className='app'> <div className='heading'> @@ -153,13 +160,17 @@ class SampleRNNDatasets extends Component { </div> </div> <div className='params col'> - {samplernn.files.length ? - <h3>Files</h3> : - <h4>No files</h4>} + <div class='row heading'> + {samplernn.files.length ? + <h3>Files</h3> : + <h4>No files</h4>} + <div>{samplernn.upload.loading && samplernn.upload.status}</div> + </div> <FileList files={samplernn.files} options={this.fileOptions} onClick={this.pickFile} + showDelete linkFiles /> </div> diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index ba429ee..efd31f5 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -8,8 +8,8 @@ const samplernnInitialState = { files: [], results: [], upload: { - loading: true, - status: 'Loading...', + loading: false, + status: '', }, } @@ -28,29 +28,21 @@ const samplernnReducer = (state = samplernnInitialState, action) => { return { ...state, } + case types.folder.index: - console.log(action) return { ...state, folders: action.data, folder: action.data[0], } case types.folder.update: - console.log(action) return state case types.file.index: - console.log(action) return { ...state, files: action.data } - case types.file.create: - console.log(action) - return { - ...state, - files: [action.data].concat(this.files) - } - return + case types.folder.upload_loading: return { ...state, @@ -85,14 +77,43 @@ const samplernnReducer = (state = samplernnInitialState, action) => { status: 'Waiting for server to finish processing...', }, } + case types.file.create_loading: + return { + ...state, + upload: { + loading: true, + status: 'Creating file...' + } + } + case types.file.create: + console.log('booo') + if (state.folder.id === action.data.folder_id) { + return { + ...state, + files: [action.data].concat(state.files), + upload: { + loading: false, + status: 'File created', + }, + } + } else { + return { + ...state, + upload: { + loading: false, + status: 'created', + }, + } + } case types.folder.upload_complete: console.log(action) if (state.folder.id === action.folder) { return { ...state, - files: state.files.concat(state.file), // sort here also + files: [action.files].concat(state.files), upload: { loading: false, + status: 'Upload complete', }, } } else { |
