From 912e1b96bfa7d6c022d854fa744f719b49ca98d0 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 21 Jul 2020 15:33:37 +0200 Subject: Add first plotting attempts for portfolios --- frontend/src/sagas/objects.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'frontend/src/sagas/objects.js') diff --git a/frontend/src/sagas/objects.js b/frontend/src/sagas/objects.js index 17b28d02..1dbc7903 100644 --- a/frontend/src/sagas/objects.js +++ b/frontend/src/sagas/objects.js @@ -96,7 +96,7 @@ export const fetchAndStoreTopology = function* (id) { const filledSlots = new Array(fullRack.capacity).fill(null) fullRack.machines.forEach( - (machine) => (filledSlots[machine.position - 1] = machine._id), + (machine) => (filledSlots[machine.position - 1] = machine._id) ) let rack = (({ _id, name, capacity, powerCapacityW }) => ({ _id, @@ -165,21 +165,21 @@ export const updateTopologyOnServer = function* (id) { rack: !tileStore[tileId].rackId ? 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 - .filter((m) => m !== null) - .map((machineId) => ({ - _id: machineId, - position: machineStore[machineId].position, - 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]), - })), - }, + _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 + .filter((m) => m !== null) + .map((machineId) => ({ + _id: machineId, + position: machineStore[machineId].position, + 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]), + })), + }, })), })), } -- cgit v1.2.3 From d8eb2d7fd4cf15706bced6c6ceca320cfaecb2f7 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 22 Jul 2020 14:31:03 +0200 Subject: Implement topology duplication --- frontend/src/sagas/objects.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'frontend/src/sagas/objects.js') diff --git a/frontend/src/sagas/objects.js b/frontend/src/sagas/objects.js index 1dbc7903..9dc65be1 100644 --- a/frontend/src/sagas/objects.js +++ b/frontend/src/sagas/objects.js @@ -142,6 +142,12 @@ const generateIdIfNotPresent = (obj) => { } export const updateTopologyOnServer = function* (id) { + const topology = yield getTopologyAsObject(id, true) + + yield call(updateTopology, topology) +} + +export const getTopologyAsObject = function* (id, keepIds) { const topologyStore = yield select(OBJECT_SELECTORS['topology']) const roomStore = yield select(OBJECT_SELECTORS['room']) const tileStore = yield select(OBJECT_SELECTORS['tile']) @@ -152,27 +158,27 @@ export const updateTopologyOnServer = function* (id) { const memoryStore = yield select(OBJECT_SELECTORS['memory']) const storageStore = yield select(OBJECT_SELECTORS['storage']) - const topology = { - _id: id, + return { + _id: keepIds ? id : undefined, name: topologyStore[id].name, rooms: topologyStore[id].roomIds.map((roomId) => ({ - _id: roomId, + _id: keepIds ? roomId : undefined, name: roomStore[roomId].name, tiles: roomStore[roomId].tileIds.map((tileId) => ({ - _id: tileId, + _id: keepIds ? tileId : undefined, positionX: tileStore[tileId].positionX, positionY: tileStore[tileId].positionY, rack: !tileStore[tileId].rackId ? undefined : { - _id: rackStore[tileStore[tileId].rackId]._id, + _id: keepIds ? rackStore[tileStore[tileId].rackId]._id : undefined, name: rackStore[tileStore[tileId].rackId].name, capacity: rackStore[tileStore[tileId].rackId].capacity, powerCapacityW: rackStore[tileStore[tileId].rackId].powerCapacityW, machines: rackStore[tileStore[tileId].rackId].machineIds .filter((m) => m !== null) .map((machineId) => ({ - _id: machineId, + _id: keepIds ? machineId : undefined, position: machineStore[machineId].position, cpus: machineStore[machineId].cpuIds.map((id) => cpuStore[id]), gpus: machineStore[machineId].gpuIds.map((id) => gpuStore[id]), @@ -183,8 +189,6 @@ export const updateTopologyOnServer = function* (id) { })), })), } - - yield call(updateTopology, topology) } export const fetchAndStoreAllTraces = () => fetchAndStoreObjects('trace', call(getAllTraces)) -- cgit v1.2.3 From 1b09fadbd14ba69a6adff57c87a1a7998e68f06e Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 22 Jul 2020 15:20:19 +0200 Subject: Remove topology print --- frontend/src/sagas/objects.js | 1 - 1 file changed, 1 deletion(-) (limited to 'frontend/src/sagas/objects.js') diff --git a/frontend/src/sagas/objects.js b/frontend/src/sagas/objects.js index 9dc65be1..83d71a42 100644 --- a/frontend/src/sagas/objects.js +++ b/frontend/src/sagas/objects.js @@ -128,7 +128,6 @@ export const fetchAndStoreTopology = function* (id) { topology = (({ _id, name, rooms }) => ({ _id, name, roomIds: rooms.map((r) => r._id) }))(fullTopology) yield put(addToStore('topology', topology)) - console.log('Full topology after insertion', fullTopology) // TODO consider pushing the IDs } -- cgit v1.2.3