diff --git a/src/components/dialog/edit-widget-plot.js b/src/components/dialog/edit-widget-plot.js index 837e15c..a2371e3 100644 --- a/src/components/dialog/edit-widget-plot.js +++ b/src/components/dialog/edit-widget-plot.js @@ -8,7 +8,7 @@ **********************************************************************************/ import React, { Component } from 'react'; -import { FormGroup, FormControl, ControlLabel, Checkbox } from 'react-bootstrap'; +import { FormGroup, FormControl, ControlLabel, Checkbox, HelpBlock } from 'react-bootstrap'; class EditPlotWidget extends Component { constructor(props) { @@ -17,8 +17,8 @@ class EditPlotWidget extends Component { this.state = { widget: { simulator: '', - plotType: '', - signals: [] + signals: [], + time: 0 } }; } @@ -58,6 +58,11 @@ class EditPlotWidget extends Component { return (
+ + Time + this.props.handleChange(e)} /> + Time in seconds + Simulator this.props.handleChange(e)}> @@ -66,21 +71,12 @@ class EditPlotWidget extends Component { ))} - - Type - this.props.handleChange(e)}> - - - + + Signals + {simulationModel.mapping.map((signal, index) => ( + this.handleSignalChange(e, index)}>{signal.name} + ))} - {this.state.widget.plotType === 'multiple' && - - Signals - {simulationModel.mapping.map((signal, index) => ( - this.handleSignalChange(e, index)}>{signal.name} - ))} - - }
); } diff --git a/src/components/dialog/edit-widget-table.js b/src/components/dialog/edit-widget-table.js index 81d24a8..0388ebd 100644 --- a/src/components/dialog/edit-widget-table.js +++ b/src/components/dialog/edit-widget-table.js @@ -26,17 +26,6 @@ } 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 (
diff --git a/src/components/toolbox-item.js b/src/components/toolbox-item.js index bedb46a..4cc0144 100644 --- a/src/components/toolbox-item.js +++ b/src/components/toolbox-item.js @@ -34,18 +34,31 @@ class ToolboxItem extends Component { type: PropTypes.string.isRequired }; + static defaultProps = { + disabled: false + }; + render() { var itemClass = classNames({ 'toolbox-item': true, - 'toolbox-item-dragging': this.props.isDragging + 'toolbox-item-dragging': this.props.isDragging, + 'toolbox-item-disabled': this.props.disabled }); var dropEffect = 'copy'; - return this.props.connectDragSource( - - {this.props.name} - - , {dropEffect}); + if (this.props.disabled === false) { + return this.props.connectDragSource( + + {this.props.name} + + , {dropEffect}); + } else { + return ( + + {this.props.name} + + ); + } } } diff --git a/src/components/widget-plot.js b/src/components/widget-plot.js index 140a0f6..96de856 100644 --- a/src/components/widget-plot.js +++ b/src/components/widget-plot.js @@ -38,13 +38,20 @@ class WidgetPlot extends Component { } // get timestamps - const latestTimestamp = nextProps.data[simulator].values[0][nextProps.data[simulator].values[0].length - 1].x; - const firstTimestamp = latestTimestamp - nextProps.widget.time * 100; + var latestTimestamp = nextProps.data[simulator].values[0][nextProps.data[simulator].values[0].length - 1].x; + var firstTimestamp = latestTimestamp - nextProps.widget.time * 1000; + var firstIndex; - // find element index representing firstTimestamp - const firstIndex = nextProps.data[simulator].values[0].findIndex((value) => { - return value.x >= firstTimestamp; - }); + if (nextProps.data[simulator].values[0][0].x < firstTimestamp) { + // find element index representing firstTimestamp + firstIndex = nextProps.data[simulator].values[0].findIndex((value) => { + return value.x >= firstTimestamp; + }); + } else { + firstIndex = 0; + firstTimestamp = nextProps.data[simulator].values[0][0].x; + latestTimestamp = firstTimestamp + nextProps.widget.time * 1000; + } // copy all values for each signal in time region var values = []; @@ -71,7 +78,7 @@ class WidgetPlot extends Component { data={this.state.values} title={this.props.widget.name} gridHorizontal={true} - xAccessor={(d) => {return new Date(d.x);}} + xAccessor={(d) => { if (d != null) { return new Date(d.x); } }} hoverAnimation={false} circleRadius={0} domain={{ x: [this.state.firstTimestamp, this.state.latestTimestamp] }} diff --git a/src/containers/visualization.js b/src/containers/visualization.js index e6baf3c..3a58018 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -212,6 +212,7 @@ class Visualization extends Component { +
} diff --git a/src/stores/simulator-data-store.js b/src/stores/simulator-data-store.js index fb97e8f..7e5145b 100644 --- a/src/stores/simulator-data-store.js +++ b/src/stores/simulator-data-store.js @@ -12,7 +12,7 @@ import { ReduceStore } from 'flux/utils'; import AppDispatcher from '../app-dispatcher'; import SimulatorDataDataManager from '../data-managers/simulator-data-data-manager'; -const MAX_VALUES = 1000; +const MAX_VALUES = 10000; class SimulationDataStore extends ReduceStore { constructor() { @@ -71,7 +71,7 @@ class SimulationDataStore extends ReduceStore { case 'simulatorData/closed': // close and delete socket - if (state[action.identifier]) { + if (state[action.identifier] != null) { state[action.identifier].close(); state[action.identifier] = null; diff --git a/src/styles/app.css b/src/styles/app.css index b7d16e3..4c70f45 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -152,3 +152,11 @@ body { .toolbox-item-dragging { opacity: 0.4; } + +.toolbox-item-disabled { + border-color: lightgray; + + color: lightgray; + + cursor: default !important; +}