diff options
Diffstat (limited to 'src/sagas/topology.js')
| -rw-r--r-- | src/sagas/topology.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/sagas/topology.js b/src/sagas/topology.js index 763d4569..6a3e03af 100644 --- a/src/sagas/topology.js +++ b/src/sagas/topology.js @@ -8,7 +8,7 @@ import { } from "../actions/objects"; import { cancelNewRoomConstructionSucceeded, - fetchLatestDatacenterSucceeded, + setCurrentDatacenter, startNewRoomConstructionSucceeded } from "../actions/topology/building"; import {addRoomToDatacenter} from "../api/routes/datacenters"; @@ -38,6 +38,7 @@ import { fetchAndStoreGPU, fetchAndStoreMachinesOfTile, fetchAndStoreMemory, + fetchAndStorePath, fetchAndStorePathsOfSimulation, fetchAndStorePSU, fetchAndStoreRackOnTile, @@ -47,15 +48,31 @@ import { fetchAndStoreTilesOfRoom } from "./objects"; -export function* onFetchLatestDatacenter(action) { +export function* fetchLatestDatacenter(simulationId) { try { - const paths = yield fetchAndStorePathsOfSimulation(action.currentSimulationId); + const paths = yield fetchAndStorePathsOfSimulation(simulationId); const latestPath = paths[paths.length - 1]; const sections = yield fetchAndStoreSectionsOfPath(latestPath.id); const latestSection = sections[sections.length - 1]; yield fetchAllUnitSpecifications(); yield fetchDatacenter(latestSection.datacenterId); - yield put(fetchLatestDatacenterSucceeded(latestSection.datacenterId)); + yield put(setCurrentDatacenter(latestSection.datacenterId)); + } catch (error) { + console.error(error); + } +} + +export function* fetchAllDatacentersOfExperiment(experiment) { + try { + const path = yield fetchAndStorePath(experiment.pathId); + const sections = yield fetchAndStoreSectionsOfPath(path.id); + path.sectionIds = sections.map(section => section.id); + yield fetchAllUnitSpecifications(); + + for (let i in sections) { + yield fetchDatacenter(sections[i].datacenterId); + } + yield put(setCurrentDatacenter(sections[0].datacenterId)); } catch (error) { console.error(error); } |
