summaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-22 08:48:38 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:06:06 +0200
commit3bf073f46e74667df4d2be9488a9f8f44ac84421 (patch)
tree75731c952d6965cf5075b03f504193936348780f /src/actions
parentd6455f1c9e57934b76ce95b3fb204072300a1991 (diff)
Make timeline clickable
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/simulation/tick.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/actions/simulation/tick.js b/src/actions/simulation/tick.js
index 68f226d7..06066662 100644
--- a/src/actions/simulation/tick.js
+++ b/src/actions/simulation/tick.js
@@ -1,3 +1,6 @@
+import {getDatacenterIdOfTick} from "../../util/timeline";
+import {setCurrentDatacenter} from "../topology/building";
+
export const GO_TO_TICK = "GO_TO_TICK";
export const SET_LAST_SIMULATED_TICK = "SET_LAST_SIMULATED_TICK";
@@ -9,9 +12,27 @@ export function incrementTick() {
}
export function goToTick(tick) {
- return {
- type: GO_TO_TICK,
- tick
+ return (dispatch, getState) => {
+ const state = getState();
+
+ let sections = [];
+ if (state.currentExperimentId !== -1) {
+ const sectionIds = state.objects.path[state.objects.experiment[state.currentExperimentId].pathId].sectionIds;
+
+ if (sectionIds) {
+ sections = sectionIds.map(sectionId => state.objects.section[sectionId]);
+ }
+ }
+
+ const newDatacenterId = getDatacenterIdOfTick(tick, sections);
+ if (state.currentDatacenterId !== newDatacenterId) {
+ dispatch(setCurrentDatacenter(newDatacenterId));
+ }
+
+ dispatch({
+ type: GO_TO_TICK,
+ tick
+ });
}
}