summaryrefslogtreecommitdiff
path: root/frontend/src/sagas/objects.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-03 09:51:20 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:47:22 +0200
commit107a48e1a7fa0ec56faad8d8e90f76521f39f3b2 (patch)
treebd14a9d7a19c4e6ae371f819404949c35d0f3b4f /frontend/src/sagas/objects.js
parentf119fc78dda4d1e828dde04f378a63a93e3a0a7e (diff)
Get entire topology editing process working
Diffstat (limited to 'frontend/src/sagas/objects.js')
-rw-r--r--frontend/src/sagas/objects.js30
1 files changed, 18 insertions, 12 deletions
diff --git a/frontend/src/sagas/objects.js b/frontend/src/sagas/objects.js
index 174f9c3e..1a31c195 100644
--- a/frontend/src/sagas/objects.js
+++ b/frontend/src/sagas/objects.js
@@ -70,23 +70,23 @@ export const fetchAndStoreTopology = function* (id) {
if (fullTile.rack) {
const fullRack = fullTile.rack
- generateIdIfNotPresent(fullTile)
+ generateIdIfNotPresent(fullRack)
if (!rackStore[fullRack._id]) {
for (let machineIdx in fullRack.machines) {
- const fullMachine = fullRoom.machines[machineIdx]
+ const fullMachine = fullRack.machines[machineIdx]
generateIdIfNotPresent(fullMachine)
if (!machineStore[fullMachine._id]) {
- let machine = (({ _id, position, cpuIds, gpuIds, memoryIds, storageIds }) => ({
+ let machine = (({ _id, position, cpus, gpus, memories, storages }) => ({
_id,
rackId: fullRack._id,
position,
- cpuIds,
- gpuIds,
- memoryIds,
- storageIds,
+ cpuIds: cpus.map((u) => u._id),
+ gpuIds: gpus.map((u) => u._id),
+ memoryIds: memories.map((u) => u._id),
+ storageIds: storages.map((u) => u._id),
}))(fullMachine)
yield put(addToStore('machine', machine))
}
@@ -96,8 +96,9 @@ export const fetchAndStoreTopology = function* (id) {
fullRack.machines.forEach(
(machine) => (filledSlots[machine.position - 1] = machine._id)
)
- let rack = (({ _id, capacity, powerCapacityW }) => ({
+ let rack = (({ _id, name, capacity, powerCapacityW }) => ({
_id,
+ name,
capacity,
powerCapacityW,
machineIds: filledSlots,
@@ -144,6 +145,10 @@ export const updateTopologyOnServer = function* (id) {
const tileStore = yield select(OBJECT_SELECTORS['tile'])
const rackStore = yield select(OBJECT_SELECTORS['rack'])
const machineStore = yield select(OBJECT_SELECTORS['machine'])
+ const cpuStore = yield select(OBJECT_SELECTORS['cpu'])
+ const gpuStore = yield select(OBJECT_SELECTORS['gpu'])
+ const memoryStore = yield select(OBJECT_SELECTORS['memory'])
+ const storageStore = yield select(OBJECT_SELECTORS['storage'])
const topology = {
_id: id,
@@ -159,6 +164,7 @@ export const updateTopologyOnServer = function* (id) {
? undefined
: {
_id: rackStore[tileStore[tileId].rackId]._id,
+ name: rackStore[tileStore[tileId].rackId].name,
capacity: rackStore[tileStore[tileId].rackId].capacity,
powerCapacityW: rackStore[tileStore[tileId].rackId].powerCapacityW,
machines: rackStore[tileStore[tileId].rackId].machineIds
@@ -166,10 +172,10 @@ export const updateTopologyOnServer = function* (id) {
.map((machineId) => ({
_id: machineId,
position: machineStore[machineId].position,
- cpuIds: machineStore[machineId].cpuIds,
- gpuIds: machineStore[machineId].gpuIds,
- memoryIds: machineStore[machineId].memoryIds,
- storageIds: machineStore[machineId].storageIds,
+ cpus: machineStore[machineId].cpuIds.map((id) => cpuStore[id]),
+ gpus: machineStore[machineId].gpuIds.map((id) => gpuStore[id]),
+ memories: machineStore[machineId].memoryIds.map((id) => memoryStore[id]),
+ storages: machineStore[machineId].storageIds.map((id) => storageStore[id]),
})),
},
})),