summaryrefslogtreecommitdiff
path: root/src/containers
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-08-31 17:59:51 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:05:50 +0200
commit3f736cd3db63f106eac02f220477b4a0f3b0eceb (patch)
tree80afa73f8c4d281b2fccba8ad2baa7c10f7e7e84 /src/containers
parentb17f1d8cb4815f57a4b7043cc91b867ec3cbc867 (diff)
Implement room creation
Diffstat (limited to 'src/containers')
-rw-r--r--src/containers/map/DatacenterContainer.js5
-rw-r--r--src/containers/map/RoomContainer.js8
-rw-r--r--src/containers/map/TileContainer.js13
-rw-r--r--src/containers/map/WallContainer.js14
-rw-r--r--src/containers/map/layers/HoverTileLayer.js23
-rw-r--r--src/containers/sidebars/topology/TopologySidebar.js (renamed from src/containers/sidebars/TopologySidebar.js)2
-rw-r--r--src/containers/sidebars/topology/building/BuildingSidebarContent.js14
-rw-r--r--src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js16
-rw-r--r--src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js16
-rw-r--r--src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js16
-rw-r--r--src/containers/simulations/SimulationActions.js2
11 files changed, 114 insertions, 15 deletions
diff --git a/src/containers/map/DatacenterContainer.js b/src/containers/map/DatacenterContainer.js
index 00b6e79f..8c80146d 100644
--- a/src/containers/map/DatacenterContainer.js
+++ b/src/containers/map/DatacenterContainer.js
@@ -1,16 +1,13 @@
import {connect} from "react-redux";
import DatacenterGroup from "../../components/map/groups/DatacenterGroup";
-import {denormalize} from "../../store/denormalizer";
const mapStateToProps = state => {
if (state.currentDatacenterId === -1) {
return {};
}
- const datacenter = denormalize(state, "datacenter", state.currentDatacenterId);
-
return {
- datacenter,
+ datacenter: state.objects.datacenter[state.currentDatacenterId],
interactionLevel: state.interactionLevel
};
};
diff --git a/src/containers/map/RoomContainer.js b/src/containers/map/RoomContainer.js
index d46324b2..2d078e09 100644
--- a/src/containers/map/RoomContainer.js
+++ b/src/containers/map/RoomContainer.js
@@ -2,15 +2,17 @@ import {connect} from "react-redux";
import {goFromBuildingToRoom} from "../../actions/interaction-level";
import RoomGroup from "../../components/map/groups/RoomGroup";
-const mapStateToProps = state => {
+const mapStateToProps = (state, ownProps) => {
return {
- interactionLevel: state.interactionLevel
+ interactionLevel: state.interactionLevel,
+ currentRoomInConstruction: state.currentRoomInConstruction,
+ room: state.objects.room[ownProps.roomId],
};
};
const mapDispatchToProps = (dispatch, ownProps) => {
return {
- onClick: () => dispatch(goFromBuildingToRoom(ownProps.room.id))
+ onClick: () => dispatch(goFromBuildingToRoom(ownProps.roomId)),
};
};
diff --git a/src/containers/map/TileContainer.js b/src/containers/map/TileContainer.js
index 0456c423..d00c3611 100644
--- a/src/containers/map/TileContainer.js
+++ b/src/containers/map/TileContainer.js
@@ -2,17 +2,18 @@ import {connect} from "react-redux";
import {goFromRoomToObject} from "../../actions/interaction-level";
import TileGroup from "../../components/map/groups/TileGroup";
-const mapStateToProps = state => {
+const mapStateToProps = (state, ownProps) => {
return {
- interactionLevel: state.interactionLevel
+ interactionLevel: state.interactionLevel,
+ tile: state.objects.tile[ownProps.tileId],
};
};
-const mapDispatchToProps = (dispatch, ownProps) => {
+const mapDispatchToProps = dispatch => {
return {
- onClick: () => {
- if (ownProps.tile.objectType) {
- dispatch(goFromRoomToObject(ownProps.tile.id))
+ onClick: tile => {
+ if (tile.objectType) {
+ dispatch(goFromRoomToObject(tile.id))
}
}
};
diff --git a/src/containers/map/WallContainer.js b/src/containers/map/WallContainer.js
new file mode 100644
index 00000000..f8ccb2e9
--- /dev/null
+++ b/src/containers/map/WallContainer.js
@@ -0,0 +1,14 @@
+import {connect} from "react-redux";
+import WallGroup from "../../components/map/groups/WallGroup";
+
+const mapStateToProps = (state, ownProps) => {
+ return {
+ tiles: state.objects.room[ownProps.roomId].tileIds.map(tileId => state.objects.tile[tileId]),
+ };
+};
+
+const WallContainer = connect(
+ mapStateToProps
+)(WallGroup);
+
+export default WallContainer;
diff --git a/src/containers/map/layers/HoverTileLayer.js b/src/containers/map/layers/HoverTileLayer.js
new file mode 100644
index 00000000..b8868233
--- /dev/null
+++ b/src/containers/map/layers/HoverTileLayer.js
@@ -0,0 +1,23 @@
+import {connect} from "react-redux";
+import {toggleTileAtLocation} from "../../../actions/topology";
+import HoverTileLayerComponent from "../../../components/map/layers/HoverTileLayerComponent";
+
+const mapStateToProps = state => {
+ return {
+ currentRoomInConstruction: state.currentRoomInConstruction,
+ isValid: (x, y) => true, // TODO implement proper validation
+ };
+};
+
+const mapDispatchToProps = dispatch => {
+ return {
+ onClick: (x, y) => dispatch(toggleTileAtLocation(x, y)),
+ };
+};
+
+const HoverTileLayer = connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(HoverTileLayerComponent);
+
+export default HoverTileLayer;
diff --git a/src/containers/sidebars/TopologySidebar.js b/src/containers/sidebars/topology/TopologySidebar.js
index 1909443a..6ed836da 100644
--- a/src/containers/sidebars/TopologySidebar.js
+++ b/src/containers/sidebars/topology/TopologySidebar.js
@@ -1,5 +1,5 @@
import {connect} from "react-redux";
-import TopologySidebarComponent from "../../components/sidebars/TopologySidebarComponent";
+import TopologySidebarComponent from "../../../components/sidebars/topology/TopologySidebarComponent";
const mapStateToProps = state => {
return {
diff --git a/src/containers/sidebars/topology/building/BuildingSidebarContent.js b/src/containers/sidebars/topology/building/BuildingSidebarContent.js
new file mode 100644
index 00000000..c70c6982
--- /dev/null
+++ b/src/containers/sidebars/topology/building/BuildingSidebarContent.js
@@ -0,0 +1,14 @@
+import {connect} from "react-redux";
+import BuildingSidebarContentComponent from "../../../../components/sidebars/topology/building/BuildingSidebarContentComponent";
+
+const mapStateToProps = state => {
+ return {
+ currentRoomInConstruction: state.currentRoomInConstruction
+ };
+};
+
+const BuildingSidebarContent = connect(
+ mapStateToProps
+)(BuildingSidebarContentComponent);
+
+export default BuildingSidebarContent;
diff --git a/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js
new file mode 100644
index 00000000..6061da96
--- /dev/null
+++ b/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js
@@ -0,0 +1,16 @@
+import {connect} from "react-redux";
+import {cancelNewRoomConstruction} from "../../../../actions/topology";
+import CancelNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/CancelNewRoomConstructionComponent";
+
+const mapDispatchToProps = dispatch => {
+ return {
+ onClick: () => dispatch(cancelNewRoomConstruction()),
+ };
+};
+
+const CancelNewRoomConstructionButton = connect(
+ null,
+ mapDispatchToProps
+)(CancelNewRoomConstructionComponent);
+
+export default CancelNewRoomConstructionButton;
diff --git a/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js
new file mode 100644
index 00000000..ca34dcc3
--- /dev/null
+++ b/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js
@@ -0,0 +1,16 @@
+import {connect} from "react-redux";
+import {finishNewRoomConstruction} from "../../../../actions/topology";
+import FinishNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/FinishNewRoomConstructionComponent";
+
+const mapDispatchToProps = dispatch => {
+ return {
+ onClick: () => dispatch(finishNewRoomConstruction()),
+ };
+};
+
+const FinishNewRoomConstructionButton = connect(
+ null,
+ mapDispatchToProps
+)(FinishNewRoomConstructionComponent);
+
+export default FinishNewRoomConstructionButton;
diff --git a/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js
new file mode 100644
index 00000000..f26eb5d4
--- /dev/null
+++ b/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js
@@ -0,0 +1,16 @@
+import {connect} from "react-redux";
+import {startNewRoomConstruction} from "../../../../actions/topology";
+import StartNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/StartNewRoomConstructionComponent";
+
+const mapDispatchToProps = dispatch => {
+ return {
+ onClick: () => dispatch(startNewRoomConstruction()),
+ };
+};
+
+const StartNewRoomConstructionButton = connect(
+ null,
+ mapDispatchToProps
+)(StartNewRoomConstructionComponent);
+
+export default StartNewRoomConstructionButton;
diff --git a/src/containers/simulations/SimulationActions.js b/src/containers/simulations/SimulationActions.js
index 01ccaa91..4dc93c77 100644
--- a/src/containers/simulations/SimulationActions.js
+++ b/src/containers/simulations/SimulationActions.js
@@ -10,7 +10,7 @@ const mapStateToProps = (state, ownProps) => {
const mapDispatchToProps = dispatch => {
return {
- onViewUsers: (id) => {},
+ onViewUsers: (id) => {}, // TODO implement user viewing
onDelete: (id) => dispatch(deleteSimulation(id)),
};
};