diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-18 16:52:11 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:06:04 +0200 |
| commit | f8f617c97fcb2df3dbefc9527d974151e367cb60 (patch) | |
| tree | f6405aa54f73b66220f36e3a388725f71d023cfb /src/sagas/topology.js | |
| parent | 9f86ae6de969baa625e3341c796c64f63b5153ce (diff) | |
Implement basic experiment mode with timeline
The timeline doesn't trigger anything yet, but the visual element is in place and connected.
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); } |
