From 107a48e1a7fa0ec56faad8d8e90f76521f39f3b2 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 3 Jul 2020 09:51:20 +0200 Subject: Get entire topology editing process working --- .../sidebars/topology/machine/UnitAddComponent.js | 8 +---- .../app/sidebars/topology/machine/UnitComponent.js | 34 ++++++++++------------ frontend/src/components/navigation/AppNavbar.js | 2 +- frontend/src/components/navigation/Navbar.sass | 1 + frontend/src/containers/auth/Login.js | 4 +-- frontend/src/sagas/objects.js | 30 +++++++++++-------- frontend/src/sagas/topology.js | 4 ++- 7 files changed, 42 insertions(+), 41 deletions(-) (limited to 'frontend') diff --git a/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js b/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js index e8722506..98238de7 100644 --- a/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js @@ -17,13 +17,7 @@ class UnitAddComponent extends React.Component { > {this.props.units.map(unit => ( ))} diff --git a/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js b/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js index 647c8e5c..bde6d444 100644 --- a/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js @@ -39,31 +39,29 @@ class UnitComponent extends React.Component { return (
  • - - {this.props.unit.name} - + + {this.props.unit.name} + - + {this.props.inSimulation ? ( undefined ) : ( - - + /> )} - +
  • ) } diff --git a/frontend/src/components/navigation/AppNavbar.js b/frontend/src/components/navigation/AppNavbar.js index da43a330..15f08b5f 100644 --- a/frontend/src/components/navigation/AppNavbar.js +++ b/frontend/src/components/navigation/AppNavbar.js @@ -30,7 +30,7 @@ const AppNavbar = ({ simulationId, inSimulation, fullWidth, onViewTopologies }) title="Topologies" onClick={onViewTopologies} > - + Topologies diff --git a/frontend/src/components/navigation/Navbar.sass b/frontend/src/components/navigation/Navbar.sass index a270bc6b..c9d2aad2 100644 --- a/frontend/src/components/navigation/Navbar.sass +++ b/frontend/src/components/navigation/Navbar.sass @@ -23,6 +23,7 @@ height: 40px background: $blue border: none + padding-top: 10px +clickable &:hover diff --git a/frontend/src/containers/auth/Login.js b/frontend/src/containers/auth/Login.js index 951f6b10..deb9a654 100644 --- a/frontend/src/containers/auth/Login.js +++ b/frontend/src/containers/auth/Login.js @@ -37,8 +37,8 @@ class LoginContainer extends React.Component { onFailure={this.onAuthFailure.bind(this)} render={renderProps => ( - Login with Google - + Login with Google + )} > 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]), })), }, })), diff --git a/frontend/src/sagas/topology.js b/frontend/src/sagas/topology.js index 0be619a9..e7ce9043 100644 --- a/frontend/src/sagas/topology.js +++ b/frontend/src/sagas/topology.js @@ -199,6 +199,7 @@ export function* onAddRackToTile(action) { const topologyId = yield select((state) => state.currentTopologyId) const rack = { _id: uuid(), + name: 'Rack', capacity: DEFAULT_RACK_SLOT_CAPACITY, powerCapacityW: DEFAULT_RACK_POWER_CAPACITY, } @@ -218,7 +219,8 @@ export function* onAddMachine(action) { const rack = yield select((state) => state.objects.rack[rackId]) const machine = { - _id: -1, + _id: uuid(), + rackId, position: action.position, cpuIds: [], gpuIds: [], -- cgit v1.2.3