From 71f3bffcd69b5aad4319b1362cf35c8efd51bc10 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 21 May 2018 18:36:36 +0200 Subject: wooooord --- app/client/live/actions.js | 10 ++++++++++ app/client/live/index.js | 21 ++++++++++++++++++++- app/client/live/reducer.js | 9 ++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) (limited to 'app/client/live') diff --git a/app/client/live/actions.js b/app/client/live/actions.js index 026788d..eb0a2ff 100644 --- a/app/client/live/actions.js +++ b/app/client/live/actions.js @@ -25,3 +25,13 @@ export const list_sequences = () => { socket.list_sequences() return { type: 'LOADING_SEQUENCES', } } + +export const load_sequence = (sequence) => { + socket.load_sequence(sequence) + return { type: 'LOADING_SEQUENCE', } +} + +export const load_epoch = (checkpoint, epoch) => { + socket.load_epoch(checkpoint, epoch) + return { type: 'LOADING_CHECKPOINT', } +} diff --git a/app/client/live/index.js b/app/client/live/index.js index 5699266..44cc70b 100644 --- a/app/client/live/index.js +++ b/app/client/live/index.js @@ -15,12 +15,28 @@ class App extends Component { props.actions.get_params() props.actions.list_checkpoints() props.actions.list_sequences() + this.changeCheckpoint = this.changeCheckpoint.bind(this) + this.changeEpoch = this.changeEpoch.bind(this) + this.changeSequence = this.changeSequence.bind(this) } componentWillUpdate(nextProps) { console.log('willupdate', nextProps.opt) - if (nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { + if (! nextProps.epochs || nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { this.props.actions.list_epochs(nextProps.opt.checkpoint_name) } + if (! nextProps.epochs || nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { + this.props.actions.list_epochs(nextProps.opt.checkpoint_name) + } + } + changeCheckpoint(checkpoint_name){ + this.props.actions.load_epoch(checkpoint_name, 'latest') + } + changeEpoch(epoch_name){ + this.props.actions.load_epoch(this.props.opt.checkpoint_name, epoch_name) + } + changeSequence(sequence){ + console.log('got sequence', sequence) + this.props.actions.load_sequence(sequence) } render(){ return ( @@ -41,16 +57,19 @@ class App extends Component { name='checkpoint_name' title='checkpoint' options={this.props.checkpoints} + onChange={this.changeCheckpoint} /> diff --git a/app/client/live/reducer.js b/app/client/live/reducer.js index e14a039..f774d3e 100644 --- a/app/client/live/reducer.js +++ b/app/client/live/reducer.js @@ -37,13 +37,16 @@ const liveReducer = (state = liveInitialState, action) => { return { ...state, checkpoints: action.checkpoints, + epochs: [], } - case 'LIST_CHECKPOINT_DIR': + case 'LIST_EPOCHS': return { ...state, - checkpoint_dir: action.checkpoint_dir, - } + epochs: action.epochs.map(a => [ a == 'latest' ? Infinity : a, a ]) + .sort((a,b) => a[0] - b[0]) + .map(a => a[1]) + } case 'LIST_SEQUENCES': return { -- cgit v1.2.3-70-g09d2