From eb208a7e2fd020ab5d07d11cc6d52d1e3dcfcc7c Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Sun, 17 Sep 2017 17:55:04 +0200 Subject: Add simulation mode framework Includes object states in the store (by tick), charting, and progress bars. --- .../sidebars/elements/LoadChartContainer.js | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/containers/sidebars/elements/LoadChartContainer.js (limited to 'src/containers/sidebars/elements/LoadChartContainer.js') diff --git a/src/containers/sidebars/elements/LoadChartContainer.js b/src/containers/sidebars/elements/LoadChartContainer.js new file mode 100644 index 00000000..7d8b10e5 --- /dev/null +++ b/src/containers/sidebars/elements/LoadChartContainer.js @@ -0,0 +1,26 @@ +import {connect} from "react-redux"; +import LoadChartComponent from "../../../components/sidebars/elements/LoadChartComponent"; +import {getStateLoad} from "../../../util/simulation-load"; + +const mapStateToProps = (state, ownProps) => { + const data = []; + + if (state.lastSimulatedTick !== -1) { + const objectStates = state.states[ownProps.objectType]; + Object.keys(objectStates).forEach(tick => { + if (objectStates[tick][ownProps.objectId]) { + data.push({x: tick, y: getStateLoad(state.loadMetric, objectStates[tick][ownProps.objectId])}); + } + }); + } + + return { + data + }; +}; + +const LoadChartContainer = connect( + mapStateToProps +)(LoadChartComponent); + +export default LoadChartContainer; -- cgit v1.2.3