1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

remove obsolete select-simulator component

This commit is contained in:
Sonja Happ 2020-02-05 11:51:13 +01:00
parent c2b7593d79
commit 6756ad7209

View file

@ -1,93 +0,0 @@
/**
* File: selectSimulator.js
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
* Date: 10.05.2018
*
* This file is part of VILLASweb.
*
* VILLASweb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VILLASweb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VILLASweb. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
import React from 'react';
import { Container } from 'flux/utils';
import { FormGroup, FormControl, FormLabel, Col } from 'react-bootstrap';
import _ from 'lodash';
import SimulatorStore from './simulator-store';
class SelectSimulator extends React.Component {
static getStores() {
return [ SimulatorStore ];
}
static calculateState() {
return {
simulators: SimulatorStore.getState(),
selectedSimulator: ''
};
}
static getDerivedStateFromProps(props, state){
if (props.value === state.selectedSimulator) {
return null; // no change
}
let selectedSimulator = props.value;
if (selectedSimulator == null) {
if (state.simulators.length > 0) {
selectedSimulator = state.simulators[0].id;
} else {
selectedSimulator = '';
}
}
return {
selectedSimulator
};
}
handleChange = event => {
this.setState({ selectedSimulator: event.target.value });
// send complete simulator to callback
if (this.props.onChange != null) {
const simulator = this.state.simulators.find(s => s.id === event.target.value);
this.props.onChange(simulator);
}
};
render() {
const simulatorOptions = this.state.simulators.map(s =>
<option key={s.id} value={s.id}>{_.get(s, 'properties.name') || _.get(s, 'rawProperties.name') || s.uuid}</option>
);
console.log("simulator options: ", simulatorOptions);
return <FormGroup>
<FormLabel sm={3} md={2}>
Simulator
</FormLabel>
<FormGroup as={Col} sm={9} md={10}>
<FormControl as="select" placeholder='Select simulator' value={this.state.selectedSimulator} onChange={(e) => this.handleChange(e)}>
{simulatorOptions}
</FormControl>
</FormGroup>
</FormGroup>;
}
}
let fluxContainerConverter = require('../common/FluxContainerConverter');
export default Container.create(fluxContainerConverter.convert(SelectSimulator));