From 94f083788d58bccb09f775ef731827d29d719d43 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 4 Jun 2018 03:13:46 +0200 Subject: promises progress --- app/client/modules/samplernn/index.js | 2 +- app/client/modules/samplernn/samplernn.actions.js | 8 ++++++-- app/client/modules/samplernn/samplernn.datasets.js | 5 ++--- app/client/modules/samplernn/samplernn.show.js | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'app/client/modules') diff --git a/app/client/modules/samplernn/index.js b/app/client/modules/samplernn/index.js index d8ea9f8..9efb6de 100644 --- a/app/client/modules/samplernn/index.js +++ b/app/client/modules/samplernn/index.js @@ -15,7 +15,7 @@ function router () { - + diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js index 30620a7..343550e 100644 --- a/app/client/modules/samplernn/samplernn.actions.js +++ b/app/client/modules/samplernn/samplernn.actions.js @@ -3,9 +3,11 @@ import types from '../../types' import actions from '../../actions' +import { allProgress } from '../../util' + export const load_directories = (id) => (dispatch) => { // console.log(actions) - Promise.all([ + allProgress([ actions.folder.index({ module: 'samplernn' }), actions.file.index({ module: 'samplernn' }), actions.task.index({ module: 'samplernn' }), @@ -13,7 +15,9 @@ export const load_directories = (id) => (dispatch) => { actions.socket.list_directory({ module: 'samplernn', dir: 'results' }), actions.socket.list_directory({ module: 'samplernn', dir: 'output' }), load_loss()(dispatch), - ]).then(res => { + ], (percent, i, n) => { + console.log(percent + "%") + }).then(res => { // console.log(res) const [folders, files, tasks, datasets, results, output, lossReport] = res diff --git a/app/client/modules/samplernn/samplernn.datasets.js b/app/client/modules/samplernn/samplernn.datasets.js index 0b7ccb8..683d44a 100644 --- a/app/client/modules/samplernn/samplernn.datasets.js +++ b/app/client/modules/samplernn/samplernn.datasets.js @@ -21,8 +21,8 @@ class SampleRNNDatasets extends Component { this.pickFile = this.pickFile.bind(this) } componentWillMount(){ - const id = this.props.id || this.props.match.params.id || localStorage.getItem('samplernn.last_id') - console.log('load dataset:', id) + const id = this.props.id + console.log('load dataset:', id, this.props.id) const { match, samplernn, actions } = this.props if (id === 'new') return if (id) { @@ -60,7 +60,6 @@ class SampleRNNDatasets extends Component { } render(){ const { samplernn, match, history } = this.props - const id = this.props.id || localStorage.getItem('samplernn.last_id') if (samplernn.loading) { // console.log('loading') return Loading diff --git a/app/client/modules/samplernn/samplernn.show.js b/app/client/modules/samplernn/samplernn.show.js index f16758a..8e271fc 100644 --- a/app/client/modules/samplernn/samplernn.show.js +++ b/app/client/modules/samplernn/samplernn.show.js @@ -20,13 +20,12 @@ class SampleRNNShow extends Component { render(){ const { samplernn, match, history } = this.props const { folder } = samplernn || {} - console.log(folder) return (

{folder ? folder.name : 'Loading...'}

- {folder && folder.name !== 'unsorted' && + {folder && folder.name && folder.name !== 'unsorted' && }
) @@ -44,6 +43,7 @@ class SampleRNNShow extends Component { const mapStateToProps = state => ({ samplernn: state.module.samplernn, + dataset: state.dataset, }) const mapDispatchToProps = (dispatch, ownProps) => ({ -- cgit v1.2.3-70-g09d2