summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-22 14:57:21 +0200
committerGitHub <noreply@github.com>2021-07-22 14:57:21 +0200
commitb0c5681b28d1c3c87b7d24d8b8d166f5566e7699 (patch)
tree4f7269996928ea480499e3cbe912b15ba994e43f /opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
parent51c759e74b088d405b63fdb3e374822308d21366 (diff)
parent7f083b47c2e2333819823fd7835332a0f486b626 (diff)
merge: Address technical debt in topology view v2 (#163)
This pull request aims to address some of the technical debt in the topology view of the OpenDC frontend (v2). * Perform Saga mutations through React Query * Add table view for topology view * Extract topology construction out of Sagas * Toggle to Floor Plan on room select
Diffstat (limited to 'opendc-web/opendc-web-ui/src/redux/actions/topology/room.js')
-rw-r--r--opendc-web/opendc-web-ui/src/redux/actions/topology/room.js32
1 files changed, 28 insertions, 4 deletions
diff --git a/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js b/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
index e584af89..bd447db5 100644
--- a/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
+++ b/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
@@ -1,11 +1,28 @@
+import { uuid } from 'uuidv4'
+import {
+ DEFAULT_RACK_SLOT_CAPACITY,
+ DEFAULT_RACK_POWER_CAPACITY,
+} from '../../../components/topologies/map/MapConstants'
import { findTileWithPosition } from '../../../util/tile-calculations'
+export const ADD_ROOM = 'ADD_ROOM'
export const EDIT_ROOM_NAME = 'EDIT_ROOM_NAME'
export const DELETE_ROOM = 'DELETE_ROOM'
export const START_RACK_CONSTRUCTION = 'START_RACK_CONSTRUCTION'
export const STOP_RACK_CONSTRUCTION = 'STOP_RACK_CONSTRUCTION'
export const ADD_RACK_TO_TILE = 'ADD_RACK_TO_TILE'
+export function addRoom(topologyId, room) {
+ return {
+ type: ADD_ROOM,
+ room: {
+ _id: uuid(),
+ topologyId,
+ ...room,
+ },
+ }
+}
+
export function editRoomName(roomId, name) {
return {
type: EDIT_ROOM_NAME,
@@ -28,15 +45,22 @@ export function stopRackConstruction() {
export function addRackToTile(positionX, positionY) {
return (dispatch, getState) => {
- const { objects, interactionLevel } = getState()
- const currentRoom = objects.room[interactionLevel.roomId]
- const tiles = currentRoom.tiles.map((tileId) => objects.tile[tileId])
+ const { topology, interactionLevel } = getState()
+ const currentRoom = topology.rooms[interactionLevel.roomId]
+ const tiles = currentRoom.tiles.map((tileId) => topology.tiles[tileId])
const tile = findTileWithPosition(tiles, positionX, positionY)
if (tile !== null) {
dispatch({
type: ADD_RACK_TO_TILE,
- tileId: tile._id,
+ rack: {
+ _id: uuid(),
+ name: 'Rack',
+ tileId: tile._id,
+ capacity: DEFAULT_RACK_SLOT_CAPACITY,
+ powerCapacityW: DEFAULT_RACK_POWER_CAPACITY,
+ machines: [],
+ },
})
}
}