Merge branch '119-remove-duplications' into 'dev'

remove duplications

Closes #119

See merge request sa4-2020/the-sanmarinoes/frontend!158
This commit is contained in:
Andrea Brites Marto 2020-05-27 18:51:43 +02:00
commit 4585f4e7de
9 changed files with 7 additions and 274 deletions

View file

@ -273,7 +273,7 @@ class SimulationPanel extends Component {
updateSliderValues(type, data, motion) {
console.log(data, motion);
this.setState({
[type ? 'error' : 'value']: data,
[type ? 'error' : 'value']: parseInt(data),
});
}

View file

@ -13,6 +13,7 @@ class SimulationPanelSlider extends Component {
value: this.internalValue,
error: this.internalValue,
};
this.props.update(this.props.error, this.internalValue);
this.updateSliderValues = this.updateSliderValues.bind(this);
}

View file

@ -1,45 +0,0 @@
import React, { Component } from 'react';
import {
Form, Grid, Image, Transition, Divider,
} from 'semantic-ui-react';
export default class SliderHumidity extends Component {
state = { visible: true, duration: 78 }
handleChange = (e, { name, value }) => this.setState({ [name]: value })
handleVisibility = () => this.setState((prevState) => ({ visible: !prevState.visible }))
render() {
const { duration } = this.state;
return (
<Grid columns={2}>
<Grid.Column as={Form} textAlign="center">
<p
style={{
color: 'white',
padding: '0.5rem',
display: 'block',
marinLeft: 'auto',
marginRight: 'auto',
}}
>
{`Humidity: ${duration} %`}
</p>
<Form.Input
min={0}
max={100}
name="duration"
onChange={this.handleChange}
step={1}
type="range"
value={duration}
/>
</Grid.Column>
</Grid>
);
}
}

View file

@ -1,45 +0,0 @@
import React, { Component } from 'react';
import {
Form, Grid, Image, Transition, Divider,
} from 'semantic-ui-react';
export default class SliderLight extends Component {
state = { visible: true, duration: 10500 }
handleChange = (e, { name, value }) => this.setState({ [name]: value })
handleVisibility = () => this.setState((prevState) => ({ visible: !prevState.visible }))
render() {
const { duration } = this.state;
return (
<Grid columns={2}>
<Grid.Column as={Form} textAlign="center">
<p
style={{
color: 'white',
padding: '0.5rem',
display: 'block',
marinLeft: 'auto',
marginRight: 'auto',
}}
>
{`Light intensity: ${duration} lm`}
</p>
<Form.Input
min={0}
max={15000}
name="duration"
onChange={this.handleChange}
step={5}
type="range"
value={duration}
/>
</Grid.Column>
</Grid>
);
}
}

View file

@ -1,46 +0,0 @@
import React, { Component } from 'react';
import {
Form, Grid, Image, Transition, Divider,
} from 'semantic-ui-react';
export default class SliderTempRange extends Component {
state = { visible: true, duration: 500 }
handleChange = (e, { name, value }) => this.setState({ [name]: value })
handleVisibility = () => this.setState((prevState) => ({ visible: !prevState.visible }))
render() {
const { duration } = this.state;
return (
<Grid columns={2}>
<Grid.Column as={Form} textAlign="center">
<p
style={{
color: 'white',
padding: '0.5rem',
display: 'block',
marinLeft: 'auto',
marginRight: 'auto',
}}
>
{`Chosen tolerance: +/- ${duration}`}
</p>
<Form.Input
min={0}
max={1000}
name="duration"
onChange={this.handleChange}
step={1}
type="range"
value={duration}
/>
</Grid.Column>
</Grid>
);
}
}

View file

@ -1,45 +0,0 @@
import React, { Component } from 'react';
import {
Form, Grid, Image, Transition, Divider,
} from 'semantic-ui-react';
export default class SliderLight extends Component {
state = { visible: true, duration: 5 }
handleChange = (e, { name, value }) => this.setState({ [name]: value })
handleVisibility = () => this.setState((prevState) => ({ visible: !prevState.visible }))
render() {
const { duration } = this.state;
return (
<Grid columns={2}>
<Grid.Column as={Form} textAlign="center">
<p
style={{
color: 'white',
padding: '0.5rem',
display: 'block',
marinLeft: 'auto',
marginRight: 'auto',
}}
>
{`Range: ${duration} meters`}
</p>
<Form.Input
min={0}
max={15}
name="duration"
onChange={this.handleChange}
step={5}
type="range"
value={duration}
/>
</Grid.Column>
</Grid>
);
}
}

View file

@ -1,46 +0,0 @@
import React, { Component } from 'react';
import {
Form, Grid, Image, Transition, Divider,
} from 'semantic-ui-react';
export default class SliderTempRange extends Component {
state = { visible: true, duration: 5 }
handleChange = (e, { name, value }) => this.setState({ [name]: value })
handleVisibility = () => this.setState((prevState) => ({ visible: !prevState.visible }))
render() {
const { duration } = this.state;
return (
<Grid columns={2}>
<Grid.Column as={Form} textAlign="center">
<p
style={{
color: 'white',
padding: '0.5rem',
display: 'block',
marinLeft: 'auto',
marginRight: 'auto',
}}
>
{`Chosen tolerance: +/- ${duration}`}
</p>
<Form.Input
min={0}
max={10}
name="duration"
onChange={this.handleChange}
step={1}
type="range"
value={duration}
/>
</Grid.Column>
</Grid>
);
}
}

View file

@ -1,45 +0,0 @@
import React, { Component } from 'react';
import {
Form, Grid, Image, Transition, Divider,
} from 'semantic-ui-react';
export default class SliderTemperature extends Component {
state = { visible: true, duration: 20 }
handleChange = (e, { name, value }) => this.setState({ [name]: value })
handleVisibility = () => this.setState((prevState) => ({ visible: !prevState.visible }))
render() {
const { duration } = this.state;
return (
<Grid columns={2}>
<Grid.Column as={Form} textAlign="center">
<p
style={{
color: 'white',
padding: '0.5rem',
display: 'block',
marinLeft: 'auto',
marginRight: 'auto',
}}
>
{`Heat: ${duration} Celsius Degrees`}
</p>
<Form.Input
min={10}
max={35}
name="duration"
onChange={this.handleChange}
step={1}
type="range"
value={duration}
/>
</Grid.Column>
</Grid>
);
}
}

View file

@ -542,7 +542,11 @@ export const RemoteService = {
updateSimulation: (data) => (dispatch) => {
const url = `/sensor/${data.id}/simulation`;
return Endpoint.put(url, {}, data)
const param = {
typical: data.typical,
error: data.err,
};
return Endpoint.put(url, {}, param)
.then((res) => {
dispatch(actions.deviceSave(res.data));
return res.data;