diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-22 21:20:54 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:06:18 +0200 |
| commit | bf7708f658cc6299a3b775afe24459b5a808c54d (patch) | |
| tree | 227520267968759e2a2f1e29e6f3edfeb4e3cf8a /src/containers/app/sidebars/topology/rack | |
| parent | e722cf117d0e3ebac20237f96764fb08cab49a62 (diff) | |
Restructure component and container directories
Diffstat (limited to 'src/containers/app/sidebars/topology/rack')
7 files changed, 140 insertions, 0 deletions
diff --git a/src/containers/app/sidebars/topology/rack/BackToRoomContainer.js b/src/containers/app/sidebars/topology/rack/BackToRoomContainer.js new file mode 100644 index 00000000..01653540 --- /dev/null +++ b/src/containers/app/sidebars/topology/rack/BackToRoomContainer.js @@ -0,0 +1,16 @@ +import {connect} from "react-redux"; +import {goDownOneInteractionLevel} from "../../../../../actions/interaction-level"; +import BackToRoomComponent from "../../../../../components/app/sidebars/topology/rack/BackToRoomComponent"; + +const mapDispatchToProps = dispatch => { + return { + onClick: () => dispatch(goDownOneInteractionLevel()), + }; +}; + +const BackToRoomContainer = connect( + undefined, + mapDispatchToProps +)(BackToRoomComponent); + +export default BackToRoomContainer; diff --git a/src/containers/app/sidebars/topology/rack/DeleteRackContainer.js b/src/containers/app/sidebars/topology/rack/DeleteRackContainer.js new file mode 100644 index 00000000..cf225558 --- /dev/null +++ b/src/containers/app/sidebars/topology/rack/DeleteRackContainer.js @@ -0,0 +1,16 @@ +import {connect} from "react-redux"; +import {openDeleteRackModal} from "../../../../../actions/modals/topology"; +import DeleteRackComponent from "../../../../../components/app/sidebars/topology/rack/DeleteRackComponent"; + +const mapDispatchToProps = dispatch => { + return { + onClick: () => dispatch(openDeleteRackModal()), + }; +}; + +const DeleteRackContainer = connect( + undefined, + mapDispatchToProps +)(DeleteRackComponent); + +export default DeleteRackContainer; diff --git a/src/containers/app/sidebars/topology/rack/EmptySlotContainer.js b/src/containers/app/sidebars/topology/rack/EmptySlotContainer.js new file mode 100644 index 00000000..b8f5e553 --- /dev/null +++ b/src/containers/app/sidebars/topology/rack/EmptySlotContainer.js @@ -0,0 +1,22 @@ +import {connect} from "react-redux"; +import {addMachine} from "../../../../../actions/topology/rack"; +import EmptySlotComponent from "../../../../../components/app/sidebars/topology/rack/EmptySlotComponent"; + +const mapStateToProps = state => { + return { + inSimulation: state.currentExperimentId !== -1 + }; +}; + +const mapDispatchToProps = (dispatch, ownProps) => { + return { + onAdd: () => dispatch(addMachine(ownProps.position)), + }; +}; + +const EmptySlotContainer = connect( + mapStateToProps, + mapDispatchToProps +)(EmptySlotComponent); + +export default EmptySlotContainer; diff --git a/src/containers/app/sidebars/topology/rack/MachineContainer.js b/src/containers/app/sidebars/topology/rack/MachineContainer.js new file mode 100644 index 00000000..cd15ddd0 --- /dev/null +++ b/src/containers/app/sidebars/topology/rack/MachineContainer.js @@ -0,0 +1,35 @@ +import {connect} from "react-redux"; +import {goFromRackToMachine} from "../../../../../actions/interaction-level"; +import MachineComponent from "../../../../../components/app/sidebars/topology/rack/MachineComponent"; +import {getStateLoad} from "../../../../../util/simulation-load"; + +const mapStateToProps = (state, ownProps) => { + const machine = state.objects.machine[ownProps.machineId]; + const inSimulation = state.currentExperimentId !== -1; + + let machineLoad = undefined; + if (inSimulation) { + if (state.states.machine[state.currentTick] && state.states.machine[state.currentTick][machine.id]) { + machineLoad = getStateLoad(state.loadMetric, state.states.machine[state.currentTick][machine.id]); + } + } + + return { + machine, + inSimulation, + machineLoad + }; +}; + +const mapDispatchToProps = (dispatch, ownProps) => { + return { + onClick: () => dispatch(goFromRackToMachine(ownProps.position)), + }; +}; + +const MachineContainer = connect( + mapStateToProps, + mapDispatchToProps +)(MachineComponent); + +export default MachineContainer; diff --git a/src/containers/app/sidebars/topology/rack/MachineListContainer.js b/src/containers/app/sidebars/topology/rack/MachineListContainer.js new file mode 100644 index 00000000..dbedfbb2 --- /dev/null +++ b/src/containers/app/sidebars/topology/rack/MachineListContainer.js @@ -0,0 +1,14 @@ +import {connect} from "react-redux"; +import MachineListComponent from "../../../../../components/app/sidebars/topology/rack/MachineListComponent"; + +const mapStateToProps = state => { + return { + machineIds: state.objects.rack[state.objects.tile[state.interactionLevel.tileId].objectId].machineIds, + }; +}; + +const MachineListContainer = connect( + mapStateToProps +)(MachineListComponent); + +export default MachineListContainer; diff --git a/src/containers/app/sidebars/topology/rack/RackNameContainer.js b/src/containers/app/sidebars/topology/rack/RackNameContainer.js new file mode 100644 index 00000000..49a58155 --- /dev/null +++ b/src/containers/app/sidebars/topology/rack/RackNameContainer.js @@ -0,0 +1,22 @@ +import {connect} from "react-redux"; +import {openEditRackNameModal} from "../../../../../actions/modals/topology"; +import RackNameComponent from "../../../../../components/app/sidebars/topology/rack/RackNameComponent"; + +const mapStateToProps = state => { + return { + rackName: state.objects.rack[state.objects.tile[state.interactionLevel.tileId].objectId].name, + }; +}; + +const mapDispatchToProps = dispatch => { + return { + onEdit: () => dispatch(openEditRackNameModal()), + }; +}; + +const RackNameContainer = connect( + mapStateToProps, + mapDispatchToProps +)(RackNameComponent); + +export default RackNameContainer; diff --git a/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js b/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js new file mode 100644 index 00000000..ba51ee4a --- /dev/null +++ b/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js @@ -0,0 +1,15 @@ +import {connect} from "react-redux"; +import RackSidebarComponent from "../../../../../components/app/sidebars/topology/rack/RackSidebarComponent"; + +const mapStateToProps = state => { + return { + rackId: state.objects.tile[state.interactionLevel.tileId].objectId, + inSimulation: state.currentExperimentId !== -1, + }; +}; + +const RackSidebarContainer = connect( + mapStateToProps +)(RackSidebarComponent); + +export default RackSidebarContainer; |
