summaryrefslogtreecommitdiff
path: root/src/containers
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-07 11:38:42 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:05:58 +0200
commite9909159dc5db91eda12437e18c1474cae848af7 (patch)
treef34e0ca56b666f6a4ab1022e58a6dcd84b779725 /src/containers
parentd5a92d3006561fd631279b68b23a1f8075b28bb8 (diff)
Implement first machine slot listing
Diffstat (limited to 'src/containers')
-rw-r--r--src/containers/map/TileContainer.js4
-rw-r--r--src/containers/map/layers/ObjectHoverLayer.js2
-rw-r--r--src/containers/modals/DeleteRackModal.js36
-rw-r--r--src/containers/modals/EditRackNameModal.js39
-rw-r--r--src/containers/sidebars/topology/rack/DeleteRackContainer.js16
-rw-r--r--src/containers/sidebars/topology/rack/EmptySlotContainer.js16
-rw-r--r--src/containers/sidebars/topology/rack/MachineContainer.js21
-rw-r--r--src/containers/sidebars/topology/rack/MachineListContainer.js14
-rw-r--r--src/containers/sidebars/topology/rack/RackNameContainer.js22
-rw-r--r--src/containers/sidebars/topology/room/RackConstructionContainer.js8
10 files changed, 171 insertions, 7 deletions
diff --git a/src/containers/map/TileContainer.js b/src/containers/map/TileContainer.js
index d00c3611..9e98636a 100644
--- a/src/containers/map/TileContainer.js
+++ b/src/containers/map/TileContainer.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import {goFromRoomToObject} from "../../actions/interaction-level";
+import {goFromRoomToRack} from "../../actions/interaction-level";
import TileGroup from "../../components/map/groups/TileGroup";
const mapStateToProps = (state, ownProps) => {
@@ -13,7 +13,7 @@ const mapDispatchToProps = dispatch => {
return {
onClick: tile => {
if (tile.objectType) {
- dispatch(goFromRoomToObject(tile.id))
+ dispatch(goFromRoomToRack(tile.id))
}
}
};
diff --git a/src/containers/map/layers/ObjectHoverLayer.js b/src/containers/map/layers/ObjectHoverLayer.js
index e9df0384..138daa2c 100644
--- a/src/containers/map/layers/ObjectHoverLayer.js
+++ b/src/containers/map/layers/ObjectHoverLayer.js
@@ -5,7 +5,7 @@ import {findTileWithPosition} from "../../../util/tile-calculations";
const mapStateToProps = state => {
return {
- isEnabled: () => state.construction.inObjectConstructionMode,
+ isEnabled: () => state.construction.inRackConstructionMode,
isValid: (x, y) => {
if (state.interactionLevel.mode !== "ROOM") {
return false;
diff --git a/src/containers/modals/DeleteRackModal.js b/src/containers/modals/DeleteRackModal.js
new file mode 100644
index 00000000..00dd036c
--- /dev/null
+++ b/src/containers/modals/DeleteRackModal.js
@@ -0,0 +1,36 @@
+import React from "react";
+import {connect} from "react-redux";
+import {closeDeleteRackModal} from "../../actions/modals/topology";
+import {deleteRack} from "../../actions/topology";
+import ConfirmationModal from "../../components/modals/ConfirmationModal";
+
+const DeleteRackModalComponent = ({visible, callback}) => (
+ <ConfirmationModal title="Delete this rack"
+ message="Are you sure you want to delete this rack?"
+ show={visible}
+ callback={callback}/>
+);
+
+const mapStateToProps = state => {
+ return {
+ visible: state.modals.deleteRackModalVisible
+ };
+};
+
+const mapDispatchToProps = dispatch => {
+ return {
+ callback: (isConfirmed) => {
+ if (isConfirmed) {
+ dispatch(deleteRack());
+ }
+ dispatch(closeDeleteRackModal());
+ }
+ };
+};
+
+const DeleteRackModal = connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(DeleteRackModalComponent);
+
+export default DeleteRackModal;
diff --git a/src/containers/modals/EditRackNameModal.js b/src/containers/modals/EditRackNameModal.js
new file mode 100644
index 00000000..e793f146
--- /dev/null
+++ b/src/containers/modals/EditRackNameModal.js
@@ -0,0 +1,39 @@
+import React from "react";
+import {connect} from "react-redux";
+import {closeEditRackNameModal} from "../../actions/modals/topology";
+import {editRackName} from "../../actions/topology";
+import TextInputModal from "../../components/modals/TextInputModal";
+
+const EditRackNameModalComponent = ({visible, previousName, callback}) => (
+ <TextInputModal title="Edit rack name"
+ label="Rack name"
+ show={visible}
+ initialValue={previousName}
+ callback={callback}/>
+);
+
+const mapStateToProps = state => {
+ return {
+ visible: state.modals.editRackNameModalVisible,
+ previousName: state.interactionLevel.mode === "RACK" ?
+ state.objects.rack[state.objects.tile[state.interactionLevel.tileId].objectId].name : "",
+ };
+};
+
+const mapDispatchToProps = dispatch => {
+ return {
+ callback: (name) => {
+ if (name) {
+ dispatch(editRackName(name));
+ }
+ dispatch(closeEditRackNameModal());
+ }
+ };
+};
+
+const EditRackNameModal = connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(EditRackNameModalComponent);
+
+export default EditRackNameModal;
diff --git a/src/containers/sidebars/topology/rack/DeleteRackContainer.js b/src/containers/sidebars/topology/rack/DeleteRackContainer.js
new file mode 100644
index 00000000..f95c48b8
--- /dev/null
+++ b/src/containers/sidebars/topology/rack/DeleteRackContainer.js
@@ -0,0 +1,16 @@
+import {connect} from "react-redux";
+import {openDeleteRackModal} from "../../../../actions/modals/topology";
+import DeleteRackComponent from "../../../../components/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/sidebars/topology/rack/EmptySlotContainer.js b/src/containers/sidebars/topology/rack/EmptySlotContainer.js
new file mode 100644
index 00000000..01ec6529
--- /dev/null
+++ b/src/containers/sidebars/topology/rack/EmptySlotContainer.js
@@ -0,0 +1,16 @@
+import {connect} from "react-redux";
+import {addMachine} from "../../../../actions/topology";
+import EmptySlotComponent from "../../../../components/sidebars/topology/rack/EmptySlotComponent";
+
+const mapDispatchToProps = (dispatch, ownProps) => {
+ return {
+ onAdd: () => dispatch(addMachine(ownProps.position)),
+ };
+};
+
+const EmptySlotContainer = connect(
+ undefined,
+ mapDispatchToProps
+)(EmptySlotComponent);
+
+export default EmptySlotContainer;
diff --git a/src/containers/sidebars/topology/rack/MachineContainer.js b/src/containers/sidebars/topology/rack/MachineContainer.js
new file mode 100644
index 00000000..74a0bfbc
--- /dev/null
+++ b/src/containers/sidebars/topology/rack/MachineContainer.js
@@ -0,0 +1,21 @@
+import {connect} from "react-redux";
+import MachineComponent from "../../../../components/sidebars/topology/rack/MachineComponent";
+
+const mapStateToProps = (state, ownProps) => {
+ return {
+ machine: state.objects.machine[ownProps.machineId],
+ };
+};
+
+const mapDispatchToProps = dispatch => {
+ return {
+ onClick: () => undefined, // TODO implement transition to MACHINE mode
+ };
+};
+
+const MachineContainer = connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(MachineComponent);
+
+export default MachineContainer;
diff --git a/src/containers/sidebars/topology/rack/MachineListContainer.js b/src/containers/sidebars/topology/rack/MachineListContainer.js
new file mode 100644
index 00000000..eef2a4e1
--- /dev/null
+++ b/src/containers/sidebars/topology/rack/MachineListContainer.js
@@ -0,0 +1,14 @@
+import {connect} from "react-redux";
+import MachineListComponent from "../../../../components/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/sidebars/topology/rack/RackNameContainer.js b/src/containers/sidebars/topology/rack/RackNameContainer.js
new file mode 100644
index 00000000..34416938
--- /dev/null
+++ b/src/containers/sidebars/topology/rack/RackNameContainer.js
@@ -0,0 +1,22 @@
+import {connect} from "react-redux";
+import {openEditRackNameModal} from "../../../../actions/modals/topology";
+import RackNameComponent from "../../../../components/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/sidebars/topology/room/RackConstructionContainer.js b/src/containers/sidebars/topology/room/RackConstructionContainer.js
index e1a481e1..47ca43fc 100644
--- a/src/containers/sidebars/topology/room/RackConstructionContainer.js
+++ b/src/containers/sidebars/topology/room/RackConstructionContainer.js
@@ -1,17 +1,17 @@
import {connect} from "react-redux";
-import {startObjectConstruction, stopObjectConstruction} from "../../../../actions/topology";
+import {startRackConstruction, stopRackConstruction} from "../../../../actions/topology";
import RackConstructionComponent from "../../../../components/sidebars/topology/room/RackConstructionComponent";
const mapStateToProps = state => {
return {
- inObjectConstructionMode: state.construction.inObjectConstructionMode,
+ inRackConstructionMode: state.construction.inRackConstructionMode,
};
};
const mapDispatchToProps = dispatch => {
return {
- onStart: () => dispatch(startObjectConstruction()),
- onStop: () => dispatch(stopObjectConstruction()),
+ onStart: () => dispatch(startRackConstruction()),
+ onStop: () => dispatch(stopRackConstruction()),
};
};