diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-08-25 23:03:05 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:44 +0200 |
| commit | 8302923a08728d36746af3560ebc35685c2b9da5 (patch) | |
| tree | 028b0e0db8f7e8e60d9127a522ceea49ec395952 /src/components/map/groups | |
| parent | 8f5e6d1e73f16e3cdd523f961d06e4b4eb5a8cef (diff) | |
Enable going from building to room and back
Diffstat (limited to 'src/components/map/groups')
| -rw-r--r-- | src/components/map/groups/DatacenterGroup.js | 37 | ||||
| -rw-r--r-- | src/components/map/groups/RoomGroup.js | 6 |
2 files changed, 32 insertions, 11 deletions
diff --git a/src/components/map/groups/DatacenterGroup.js b/src/components/map/groups/DatacenterGroup.js index d7e349be..cd4baaa5 100644 --- a/src/components/map/groups/DatacenterGroup.js +++ b/src/components/map/groups/DatacenterGroup.js @@ -1,23 +1,42 @@ import React from "react"; import {Group} from "react-konva"; +import GrayContainer from "../../../containers/map/GrayContainer"; +import RoomContainer from "../../../containers/map/RoomContainer"; import Shapes from "../../../shapes/index"; -import RoomGroup from "./RoomGroup"; -const DatacenterGroup = ({datacenter}) => { +const DatacenterGroup = ({datacenter, interactionLevel}) => { if (!datacenter) { return <Group/>; } - return ( - <Group> - {datacenter.rooms.map(room => ( - <RoomGroup key={room.id} room={room}/> - ))} - </Group> - ); + + if (interactionLevel.mode === "ROOM") { + return ( + <Group> + {datacenter.rooms + .filter(room => room.id !== interactionLevel.roomId) + .map(room => <RoomContainer key={room.id} room={room}/>) + } + <GrayContainer/> + {datacenter.rooms + .filter(room => room.id === interactionLevel.roomId) + .map(room => <RoomContainer key={room.id} room={room}/>) + } + </Group> + ); + } else { + return ( + <Group> + {datacenter.rooms.map(room => ( + <RoomContainer key={room.id} room={room}/> + ))} + </Group> + ); + } }; DatacenterGroup.propTypes = { datacenter: Shapes.Datacenter, + interactionLevel: Shapes.InteractionLevel, }; export default DatacenterGroup; diff --git a/src/components/map/groups/RoomGroup.js b/src/components/map/groups/RoomGroup.js index 5f349e3c..179a24a2 100644 --- a/src/components/map/groups/RoomGroup.js +++ b/src/components/map/groups/RoomGroup.js @@ -5,8 +5,10 @@ import {deriveWallLocations} from "../../../util/tile-calculations"; import WallSegment from "../elements/WallSegment"; import TileGroup from "./TileGroup"; -const RoomGroup = ({room}) => ( - <Group> +const RoomGroup = ({room, onClick}) => ( + <Group + onClick={onClick} + > {room.tiles.map(tile => ( <TileGroup key={tile.id} tile={tile}/> ))} |
