diff --git a/src/components/dialog/edit-widget-signal-control.js b/src/components/dialog/edit-widget-signal-control.js new file mode 100644 index 0000000..fd2cd5e --- /dev/null +++ b/src/components/dialog/edit-widget-signal-control.js @@ -0,0 +1,54 @@ +/** + * File: edit-widget-signal-control.js + * Author: Ricardo Hernandez-Montoya + * Date: 03.04.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +import React, { Component } from 'react'; +import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; + +class EditWidgetSignalControl extends Component { + constructor(props) { + super(props); + + this.state = { + widget: { + simulator: '' + } + }; + } + + componentWillReceiveProps(nextProps) { + // Update state's widget with props + this.setState({ widget: nextProps.widget }); + } + + render() { + // get selected simulation model + var simulationModel = {}; + + if (this.props.simulation) { + this.props.simulation.models.forEach((model) => { + if (model.simulation === this.state.widget.simulation) { + simulationModel = model; + } + }); + } + + return ( + + Signal + this.props.handleChange(e)}> + {simulationModel.mapping.map((signal, index) => ( + + ))} + + + ); + } +} + +export default EditWidgetSignalControl; \ No newline at end of file diff --git a/src/components/dialog/edit-widget-simulator-control.js b/src/components/dialog/edit-widget-simulator-control.js new file mode 100644 index 0000000..baa9679 --- /dev/null +++ b/src/components/dialog/edit-widget-simulator-control.js @@ -0,0 +1,44 @@ +/** + * File: edit-widget-simulator-control.js + * Author: Ricardo Hernandez-Montoya + * Date: 03.04.2017 + * Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC + * This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential. + * Unauthorized copying of this file, via any medium is strictly prohibited. + **********************************************************************************/ + +import React, { Component } from 'react'; +import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap'; + +class EditWidgetSimulatorControl extends Component { + constructor(props) { + super(props); + + this.state = { + widget: { + simulator: '' + } + }; + } + + componentWillReceiveProps(nextProps) { + // Update state's widget with props + this.setState({ widget: nextProps.widget }); + } + + render() { + + return ( + + Simulator + this.props.handleChange(e)}> + {this.props.simulation.models.map((model, index) => ( + + ))} + + + ); + } +} + +export default EditWidgetSimulatorControl; \ No newline at end of file diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index 2b7a21e..7275649 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -16,6 +16,8 @@ import EditValueWidget from './edit-widget-value'; import EditPlotWidget from './edit-widget-plot'; import EditTableWidget from './edit-widget-table'; import EditImageWidget from './edit-widget-image'; +import EditWidgetSimulatorControl from './edit-widget-simulator-control'; +import EditWidgetSignalControl from './edit-widget-signal-control'; class EditWidgetDialog extends Component { static propTypes = { @@ -75,6 +77,8 @@ class EditWidgetDialog extends Component { render() { // get widget part var widgetDialog = null; + // Use a list to concatenate the controls according to the widget type + var dialogControls = []; if (this.props.widget) { if (this.props.widget.type === 'Value') { @@ -85,6 +89,11 @@ class EditWidgetDialog extends Component { widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; } else if (this.props.widget.type === 'Image') { widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; + } else if (this.props.widget.type === 'Gauge') { + dialogControls.push( + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />, + this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} /> + ) } } @@ -96,7 +105,7 @@ class EditWidgetDialog extends Component { this.handleChange(e)} /> - + { dialogControls } {widgetDialog}