From cba34c1ff3fc4fa3e4444884133a9140443bb233 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 30 May 2018 14:37:03 +0200 Subject: parse urls using the old parser --- app/client/modules/samplernn/datasets.component.js | 37 +++++++++++------ app/client/modules/samplernn/samplernn.reducer.js | 47 ++++++++++++++++------ 2 files changed, 58 insertions(+), 26 deletions(-) (limited to 'app/client/modules/samplernn') 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 (
@@ -153,13 +160,17 @@ class SampleRNNDatasets extends Component {
- {samplernn.files.length ? -

Files

: -

No files

} +
+ {samplernn.files.length ? +

Files

: +

No files

} +
{samplernn.upload.loading && samplernn.upload.status}
+
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 { -- cgit v1.2.3-70-g09d2