summaryrefslogtreecommitdiff
path: root/frontend/src/containers/app/sidebars/elements/LoadChartContainer.js
blob: 49962d57ee1cc3e90fb1c28354fed0463fa66a95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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