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/topology.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'frontend/src/sagas/topology.js') diff --git a/frontend/src/sagas/topology.js b/frontend/src/sagas/topology.js index e915f9ff..14c1ed2d 100644 --- a/frontend/src/sagas/topology.js +++ b/frontend/src/sagas/topology.js @@ -44,7 +44,7 @@ export function* onAddTopology(action) { addTopology, Object.assign({}, action.topology, { projectId: currentProjectId, - }), + }) ) yield fetchAndStoreTopology(topology._id) @@ -52,7 +52,7 @@ export function* onAddTopology(action) { yield put( addPropToStoreObject('project', currentProjectId, { topologyIds: topologyIds.concat([topology._id]), - }), + }) ) yield put(setCurrentTopology(topology._id)) } catch (error) { @@ -74,7 +74,7 @@ export function* onDeleteTopology(action) { yield put( addPropToStoreObject('project', currentProjectId, { topologyIds: topologyIds.filter((id) => id !== action.id), - }), + }) ) } catch (error) { console.error(error) @@ -258,7 +258,7 @@ export function* onAddUnit(action) { const position = yield select((state) => state.interactionLevel.position) const machine = yield select( (state) => - state.objects.machine[state.objects.rack[state.objects.tile[tileId].rackId].machineIds[position - 1]], + state.objects.machine[state.objects.rack[state.objects.tile[tileId].rackId].machineIds[position - 1]] ) if (machine[action.unitType + 'Ids'].length >= MAX_NUM_UNITS_PER_MACHINE) { @@ -269,7 +269,7 @@ export function* onAddUnit(action) { yield put( addPropToStoreObject('machine', machine._id, { [action.unitType + 'Ids']: units, - }), + }) ) yield updateTopologyOnServer(topologyId) } catch (error) { @@ -284,7 +284,7 @@ export function* onDeleteUnit(action) { const position = yield select((state) => state.interactionLevel.position) const machine = yield select( (state) => - state.objects.machine[state.objects.rack[state.objects.tile[tileId].rackId].machineIds[position - 1]], + state.objects.machine[state.objects.rack[state.objects.tile[tileId].rackId].machineIds[position - 1]] ) const unitIds = machine[action.unitType + 'Ids'].slice() unitIds.splice(action.index, 1) @@ -292,7 +292,7 @@ export function* onDeleteUnit(action) { yield put( addPropToStoreObject('machine', machine._id, { [action.unitType + 'Ids']: unitIds, - }), + }) ) yield updateTopologyOnServer(topologyId) } catch (error) { -- 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/topology.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'frontend/src/sagas/topology.js') diff --git a/frontend/src/sagas/topology.js b/frontend/src/sagas/topology.js index 14c1ed2d..8b67c196 100644 --- a/frontend/src/sagas/topology.js +++ b/frontend/src/sagas/topology.js @@ -16,7 +16,7 @@ import { DEFAULT_RACK_SLOT_CAPACITY, MAX_NUM_UNITS_PER_MACHINE, } from '../components/app/map/MapConstants' -import { fetchAndStoreTopology, updateTopologyOnServer } from './objects' +import { fetchAndStoreTopology, getTopologyAsObject, updateTopologyOnServer } from './objects' import { uuid } from 'uuidv4' import { addTopology, deleteTopology } from '../api/routes/topologies' @@ -40,9 +40,16 @@ export function* onAddTopology(action) { try { const currentProjectId = yield select((state) => state.currentProjectId) + let topologyToBeCreated + if (action.duplicateId) { + topologyToBeCreated = yield getTopologyAsObject(action.duplicateId, false) + } else { + topologyToBeCreated = { name: action.name, rooms: [] } + } + const topology = yield call( addTopology, - Object.assign({}, action.topology, { + Object.assign({}, topologyToBeCreated, { projectId: currentProjectId, }) ) -- cgit v1.2.3 From dbb652a4c97a627a0c5969d1f75e4777e3efd06f Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 22 Jul 2020 14:58:02 +0200 Subject: Fix name of duplicate topology --- frontend/src/sagas/topology.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'frontend/src/sagas/topology.js') diff --git a/frontend/src/sagas/topology.js b/frontend/src/sagas/topology.js index 8b67c196..bba1ebb1 100644 --- a/frontend/src/sagas/topology.js +++ b/frontend/src/sagas/topology.js @@ -43,6 +43,9 @@ export function* onAddTopology(action) { let topologyToBeCreated if (action.duplicateId) { topologyToBeCreated = yield getTopologyAsObject(action.duplicateId, false) + topologyToBeCreated = Object.assign({}, topologyToBeCreated, { + name: action.name, + }) } else { topologyToBeCreated = { name: action.name, rooms: [] } } -- cgit v1.2.3