From bf7708f658cc6299a3b775afe24459b5a808c54d Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 22 Sep 2017 21:20:54 +0200 Subject: Restructure component and container directories --- .../app/sidebars/elements/LoadChartContainer.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/containers/app/sidebars/elements/LoadChartContainer.js (limited to 'src/containers/app/sidebars/elements/LoadChartContainer.js') diff --git a/src/containers/app/sidebars/elements/LoadChartContainer.js b/src/containers/app/sidebars/elements/LoadChartContainer.js new file mode 100644 index 00000000..227a4fd5 --- /dev/null +++ b/src/containers/app/sidebars/elements/LoadChartContainer.js @@ -0,0 +1,27 @@ +import {connect} from "react-redux"; +import LoadChartComponent from "../../../../components/app/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, + currentTick: state.currentTick, + }; +}; + +const LoadChartContainer = connect( + mapStateToProps +)(LoadChartComponent); + +export default LoadChartContainer; -- cgit v1.2.3