summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/actions/prefabs.js1
-rw-r--r--frontend/src/reducers/objects.js3
-rw-r--r--frontend/src/sagas/objects.js43
-rw-r--r--frontend/src/sagas/prefabs.js1
4 files changed, 24 insertions, 24 deletions
diff --git a/frontend/src/actions/prefabs.js b/frontend/src/actions/prefabs.js
index 8d262772..c112feed 100644
--- a/frontend/src/actions/prefabs.js
+++ b/frontend/src/actions/prefabs.js
@@ -3,7 +3,6 @@ export const DELETE_PREFAB = 'DELETE_PREFAB'
export const DELETE_PREFAB_SUCCEEDED = 'DELETE_PREFAB_SUCCEEDED'
export const OPEN_PREFAB_SUCCEEDED = 'OPEN_PREFAB_SUCCEEDED'
-//infer rackID from state in saga later
export function addPrefab(name) {
return {
type: ADD_PREFAB,
diff --git a/frontend/src/reducers/objects.js b/frontend/src/reducers/objects.js
index dd2b61cb..1f721b2e 100644
--- a/frontend/src/reducers/objects.js
+++ b/frontend/src/reducers/objects.js
@@ -1,6 +1,3 @@
-//TODO: add prefabs
-
-
import { combineReducers } from 'redux'
import {
ADD_ID_TO_STORE_OBJECT_LIST_PROP,
diff --git a/frontend/src/sagas/objects.js b/frontend/src/sagas/objects.js
index a10fdcbe..9c9b19b8 100644
--- a/frontend/src/sagas/objects.js
+++ b/frontend/src/sagas/objects.js
@@ -146,38 +146,43 @@ export const updateTopologyOnServer = function* (id) {
yield call(updateTopology, topology)
}
+export const getTopologyAsObject = function* (id, keepIds) {
+ const topologyStore = yield select(OBJECT_SELECTORS['topology'])
+
+ const rooms = yield call(getAllRooms, topologyStore[id].roomIds, keepIds)
+ return {
+ _id: keepIds ? id : undefined,
+ name: topologyStore[id].name,
+ rooms: rooms,
+ }
+}
+
export const getAllRooms = function* (roomIds, keepIds) {
const roomStore = yield select(OBJECT_SELECTORS['room'])
+
+ console.log("DEBUG: roomIds has value " + roomIds)
+ console.log("DEBUG: roomStore has value " + roomStore)
+ console.log("DEBUG: size of roomStore is " + roomStore.length)
let rooms = []
for(let i in roomIds){
- let tiles = yield call(getAllRoomTiles, roomStore[i].tileIds, keepIds)
+ console.log("DEBUG: on iteration " + i + ", roomStore has value = " + roomStore[i])
+ let tiles = yield call(getAllRoomTiles, roomStore[i], keepIds)
rooms.push({
- _id: keepIds ? i : undefined,
- name: roomStore[i].name,
- tiles: tiles,
+ _id: keepIds ? i : undefined,
+ name: roomStore[i].name,
+ tiles: tiles,
}
)
}
return rooms
}
-export const getTopologyAsObject = function* (id, keepIds) {
- const topologyStore = yield select(OBJECT_SELECTORS['topology'])
-
- const rooms = yield call(getAllRooms, topologyStore[id].roomIds, keepIds)
- return {
- _id: keepIds ? id : undefined,
- name: topologyStore[id].name,
- rooms: rooms,
- }
-}
-
-export const getAllRoomTiles = function* (room, keepIds) {
+export const getAllRoomTiles = function* (roomStore, keepIds) {
let tiles = []
-
- for(let i in room.tileIds){
- tiles.push(yield call(getTileById, i, keepIds))
+ console.log("DEBUG: roomStore = " + roomStore)
+ for(let i in roomStore.tileIds){
+ tiles.push(yield call(getTileById, roomStore.tileIds[i], keepIds))
}
return tiles
}
diff --git a/frontend/src/sagas/prefabs.js b/frontend/src/sagas/prefabs.js
index 80ba2f80..93af105a 100644
--- a/frontend/src/sagas/prefabs.js
+++ b/frontend/src/sagas/prefabs.js
@@ -9,7 +9,6 @@ export function* onAddPrefab(action) {
console.log("DEBUG: " + state.objects.tile[state.interactionLevel.tileId].rack._id)
const currentRackId = yield select((state) => state.objects.tile[state.interactionLevel.tileId].rack._id)
const currentRackJson = yield call(getTopologyAsObject, currentRackId)
- //TODO: yield call the function in saga to export the specific part of the topology
const prefab = yield call(addPrefab, { name: action.name, rack: currentRackJson })
yield put(addToStore('prefab', prefab))