Commit 50cbcd36 authored by Sonja Happ's avatar Sonja Happ

progress with simulation model

parent 42ffff2d
......@@ -87,8 +87,8 @@ class EditableHeader extends React.Component {
<FormControl type='text' bsSize='large' value={this.state.title} onChange={this.onChange} style={editStyle} autoFocus />
</form>
<Button bsStyle="link" onClick={this.save}><Icon icon='check' style={iconStyle} /></Button>
<Button bsStyle="link" onClick={this.cancel}><Icon icon='times' style={iconStyle} /></Button>
<Button onClick={this.save}><Icon icon='check' style={iconStyle} /></Button>
<Button onClick={this.cancel}><Icon icon='times' style={iconStyle} /></Button>
</div>;
}
......@@ -97,7 +97,7 @@ class EditableHeader extends React.Component {
{this.state.title}
</h1>
<Button bsStyle="link" onClick={this.edit}><Icon icon='edit' style={iconStyle} /></Button>
<Button onClick={this.edit}><Icon icon='edit' style={iconStyle} /></Button>
</div>;
}
}
......
......@@ -118,30 +118,30 @@ class SelectFile extends React.Component {
return <div>
<FormGroup>
<Col componentClass={FormLabel} sm={3} md={2}>
<FormLabel sm={3} md={2}>
{this.props.name}
</Col>
</FormLabel>
<Col sm={9} md={10}>
<FormControl disabled={this.props.disabled} componentClass='select' placeholder='Select file' onChange={this.handleChange}>
<FormControl disabled={this.props.disabled} placeholder='Select file' onChange={this.handleChange}>
{fileOptions}
</FormControl>
</Col>
</FormGroup>
<FormGroup>
<Col sm={9} md={10} smOffset={3} mdOffset={2}>
<Col sm={{span: 9, offset: 3}} md={{span: 10, offset: 2}} >
<FormControl disabled={this.props.disabled} type='file' onChange={this.selectUploadFile} />
</Col>
</FormGroup>
<FormGroup>
<Col sm={9} md={10} smOffset={3} mdOffset={2}>
<Button disabled={this.props.disabled} bsSize='small' onClick={this.startFileUpload}>
<Col sm={{span: 9, offset: 3}} md={{span: 10, offset : 2}}>
<Button disabled={this.props.disabled} onClick={this.startFileUpload}>
Upload file
</Button>
<ProgressBar striped active now={this.state.uploadProgress} label={this.state.uploadProgress + '%'} style={progressBarStyle} />
<ProgressBar striped animated now={this.state.uploadProgress} label={this.state.uploadProgress + '%'} style={progressBarStyle} />
</Col>
</FormGroup>
</div>;
......
......@@ -100,7 +100,7 @@ class SignalMapping extends React.Component {
render() {
return <div>
<FormGroup validationState={this.validateLength()}>
<FormGroup validated={this.validateLength()}>
<FormLabel>{this.props.name} Length</FormLabel>
<FormControl name='length' type='number' placeholder='Enter length' defaultValue={this.state.length} min='1' onBlur={this.handleLengthChange} />
<FormControl.Feedback />
......
......@@ -32,6 +32,10 @@ import SelectFile from '../file/select-file';
import SignalMapping from './signal-mapping';
import EditableHeader from '../common/editable-header';
import ParametersEditor from '../common/parameters-editor';
import SimulatorStore from "../simulator/simulator-store";
import SignalStore from "./signal-store";
import FileStore from "../file/file-store"
class SimulationModel extends React.Component {
static getStores() {
......@@ -39,20 +43,60 @@ class SimulationModel extends React.Component {
}
static calculateState(prevState, props) {
const simulationModel = SimulationModelStore.getState().find(m => m.id === props.match.params.simulationModel);
// get selected simulation model
const sessionToken = LoginStore.getState().token;
let simulationModel = SimulationModelStore.getState().find(m => m.id === parseInt(props.match.params.simulationModel, 10));
if (simulationModel == null) {
AppDispatcher.dispatch({
type: 'simulationModels/start-load',
data: props.match.params.simulationModel,
token: sessionToken
});
}
// signals and files of simulation model
let signals = SignalStore.getState().find(sig => sig.simulationModelID === parseInt(props.match.params.simulationModel, 10));
let files = FileStore.getState().find(f => f.simulationModelID === parseInt(props.match.params.simulationModel, 10));
return {
simulationModel: simulationModel || {},
sessionToken: LoginStore.getState().token
simulationModel,
signals,
files,
sessionToken,
simulators: SimulatorStore.getState()
};
}
componentDidMount() {
//load selected simulationModel
AppDispatcher.dispatch({
type: 'simulationModels/start-load',
data: this.props.match.params.simulationModel,
data: this.state.simulationModel.id,
token: this.state.sessionToken
});
// load signals for selected simulation model
AppDispatcher.dispatch({
type: 'signals/start-load',
token: this.state.sessionToken,
param: 'TODO',
});
// load files for selected simulation model
AppDispatcher.dispatch({
type: 'files/start-load',
token: this.state.sessionToken,
param: 'TODO',
});
// load simulators
AppDispatcher.dispatch({
type: 'simulators/start-load',
token: this.state.sessionToken,
});
}
submitForm = event => {
......@@ -140,9 +184,9 @@ class SimulationModel extends React.Component {
<SelectFile disabled type='configuration' name='Configuration' onChange={this.handleConfigurationChange} value={this.state.simulationModel.configuration} />
<div>
<Col componentClass={FormLabel} sm={3} md={2}>
<FormLabel sm={3} md={2}>
Start Parameters
</Col>
</FormLabel>
<Col sm={9} md={10}>
<ParametersEditor content={this.state.simulationModel.startParameters} onChange={this.handleStartParametersChange} />
......@@ -162,7 +206,7 @@ class SimulationModel extends React.Component {
<div style={{ clear: 'both' }}></div>
<Button onClick={this.discardChanges} style={buttonStyle}>Cancel</Button>
<Button bsStyle='primary' onClick={this.saveChanges} style={buttonStyle}>Save</Button>
<Button onClick={this.saveChanges} style={buttonStyle}>Save</Button>
</Form>
</div>;
}
......
......@@ -69,17 +69,19 @@ class SelectSimulator extends React.Component {
};
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>
<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>
<Col componentClass={FormLabel} sm={3} md={2}>
<FormLabel sm={3} md={2}>
Simulator
</Col>
</FormLabel>
<Col sm={9} md={10}>
<FormControl componentClass='select' placeholder='Select simulator' value={this.state.selectedSimulator} onChange={this.handleChange}>
<FormControl as="select" placeholder='Select simulator' value={this.state.selectedSimulator} onChange={(e) => this.handleChange(e)}>
{simulatorOptions}
</FormControl>
</Col>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment