mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Add default selected simulator to new simulation model
This commit is contained in:
parent
b5fa267dc4
commit
f6832a383a
1 changed files with 3 additions and 9 deletions
|
@ -93,7 +93,7 @@ class NewSimulationModelDialog extends React.Component {
|
|||
resetState() {
|
||||
this.setState({
|
||||
name: '',
|
||||
simulator: '',
|
||||
simulator: this.props.simulators[0]._id || '',
|
||||
outputLength: '1',
|
||||
inputLength: '1',
|
||||
outputMapping: [{ name: 'Signal', type: 'Type' }],
|
||||
|
@ -106,16 +106,11 @@ class NewSimulationModelDialog extends React.Component {
|
|||
let name = true;
|
||||
let inputLength = true;
|
||||
let outputLength = true;
|
||||
let simulator = true;
|
||||
|
||||
if (this.state.name === '') {
|
||||
name = false;
|
||||
}
|
||||
|
||||
if (this.state.simulator === '') {
|
||||
simulator = false;
|
||||
}
|
||||
|
||||
// test if simulatorid is a number (in a string, not type of number)
|
||||
if (!/^\d+$/.test(this.state.outputLength)) {
|
||||
outputLength = false;
|
||||
|
@ -125,13 +120,12 @@ class NewSimulationModelDialog extends React.Component {
|
|||
inputLength = false;
|
||||
}
|
||||
|
||||
this.valid = name && inputLength && outputLength && simulator;
|
||||
this.valid = name && inputLength && outputLength;
|
||||
|
||||
// return state to control
|
||||
if (target === 'name') return name ? "success" : "error";
|
||||
else if (target === 'outputLength') return outputLength ? "success" : "error";
|
||||
else if (target === 'inputLength') return inputLength ? "success" : "error";
|
||||
else if (target === 'simulator') return simulator ? "success" : "error";
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -143,7 +137,7 @@ class NewSimulationModelDialog extends React.Component {
|
|||
<FormControl type="text" placeholder="Enter name" value={this.state.name} onChange={(e) => this.handleChange(e)} />
|
||||
<FormControl.Feedback />
|
||||
</FormGroup>
|
||||
<FormGroup controlId="simulator" validationState={this.validateForm('simulator')}>
|
||||
<FormGroup controlId="simulator">
|
||||
<ControlLabel>Simulator</ControlLabel>
|
||||
<FormControl componentClass="select" placeholder="Select simulator" value={this.state.simulator} onChange={(e) => this.handleChange(e)}>
|
||||
{this.props.simulators.map(simulator => (
|
||||
|
|
Loading…
Add table
Reference in a new issue