From 0b4241c0a8e0d3fa9c130d3ca6b3d64cdda43cac Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 21 May 2018 13:23:19 +0200 Subject: toggles and layout adjust --- app/client/common/paramGroup.component.js | 19 ++- app/client/common/slider.component.js | 7 +- app/client/live/actions.js | 1 + app/client/live/index.js | 195 +++++++++++++++--------------- app/client/live/reducer.js | 3 + 5 files changed, 126 insertions(+), 99 deletions(-) (limited to 'app') diff --git a/app/client/common/paramGroup.component.js b/app/client/common/paramGroup.component.js index ccff0b0..2533642 100644 --- a/app/client/common/paramGroup.component.js +++ b/app/client/common/paramGroup.component.js @@ -4,13 +4,28 @@ import { bindActionCreators } from 'redux' import * as liveActions from '../live/actions' class ParamGroup extends Component { + constructor(props){ + super(props) + this.handleClick = this.handleClick.bind(this) + } + handleClick(e){ + clearTimeout(this.timeout) + let new_value = e.target.checked + this.props.actions.set_param(this.props.name, new_value) + } render() { const props = this.props + const checked = this.props.opt[this.props.name] + const className = checked ? 'paramGroup active' : 'paramGroup inactive' return ( -
+
{props.children}
diff --git a/app/client/common/slider.component.js b/app/client/common/slider.component.js index c8b4ed1..ca22689 100644 --- a/app/client/common/slider.component.js +++ b/app/client/common/slider.component.js @@ -15,7 +15,12 @@ class Slider extends Component { this.handleInput = this.handleInput.bind(this) this.handleRange = this.handleRange.bind(this) } - + componentWillReceiveProps(nextProps) { + const next_value = nextProps.opt[nextProps.name] + if (next_value !== this.state.value) { + this.setState({ value: next_value }); + } + } handleInput(e){ let { name, opt } = this.props let old_value = opt[name] diff --git a/app/client/live/actions.js b/app/client/live/actions.js index 047e51f..bde954b 100644 --- a/app/client/live/actions.js +++ b/app/client/live/actions.js @@ -6,6 +6,7 @@ export const get_params = () => { } export const set_param = (key, value) => { + console.log('set param', key, value) socket.set_param(key, value) return { type: 'SET_PARAM', key, value, } } diff --git a/app/client/live/index.js b/app/client/live/index.js index 8d16785..411191d 100644 --- a/app/client/live/index.js +++ b/app/client/live/index.js @@ -19,108 +19,111 @@ class App extends Component {
+
+ + + + + - - - - - + + + + + - - - - - + + + + +
+
+ + + - - - - + + + + - - - + + + + - - - - - - - - - - - - - - + + + + +
) diff --git a/app/client/live/reducer.js b/app/client/live/reducer.js index 6e18624..93fc448 100644 --- a/app/client/live/reducer.js +++ b/app/client/live/reducer.js @@ -11,6 +11,9 @@ const liveReducer = (state = liveInitialState, action) => { switch(action.type) { case 'LOAD_PARAMS': + if (! action.opt || ! Object.keys(action.opt).length) { + return state + } return { ...state, loading: false, -- cgit v1.2.3-70-g09d2