diff options
| author | Georgios Andreadis <G.Andreadis@student.tudelft.nl> | 2017-10-04 23:23:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-04 23:23:09 +0200 |
| commit | fcaaae65d34003874c76e0c01134dedf94248e09 (patch) | |
| tree | 2aae1422168651e832a1904623f6f5b100fc17ec /src/actions/simulation | |
| parent | 0a62dfb55c5700013d42a589b930c7448e5bff71 (diff) | |
| parent | 606d1de0be09f3597165248f65d54e158a13860c (diff) | |
Merge pull request #42 from atlarge-research/auto-reformat
Standardize code format
Diffstat (limited to 'src/actions/simulation')
| -rw-r--r-- | src/actions/simulation/load-metric.js | 8 | ||||
| -rw-r--r-- | src/actions/simulation/playback.js | 16 | ||||
| -rw-r--r-- | src/actions/simulation/tick.js | 67 |
3 files changed, 48 insertions, 43 deletions
diff --git a/src/actions/simulation/load-metric.js b/src/actions/simulation/load-metric.js index e426a7d2..c59e3596 100644 --- a/src/actions/simulation/load-metric.js +++ b/src/actions/simulation/load-metric.js @@ -1,8 +1,8 @@ export const CHANGE_LOAD_METRIC = "CHANGE_LOAD_METRIC"; export function changeLoadMetric(metric) { - return { - type: CHANGE_LOAD_METRIC, - metric - }; + return { + type: CHANGE_LOAD_METRIC, + metric + }; } diff --git a/src/actions/simulation/playback.js b/src/actions/simulation/playback.js index bddb9a0a..8e913914 100644 --- a/src/actions/simulation/playback.js +++ b/src/actions/simulation/playback.js @@ -1,15 +1,15 @@ export const SET_PLAYING = "SET_PLAYING"; export function playSimulation() { - return { - type: SET_PLAYING, - playing: true - } + return { + type: SET_PLAYING, + playing: true + }; } export function pauseSimulation() { - return { - type: SET_PLAYING, - playing: false - } + return { + type: SET_PLAYING, + playing: false + }; } diff --git a/src/actions/simulation/tick.js b/src/actions/simulation/tick.js index 06066662..a629b340 100644 --- a/src/actions/simulation/tick.js +++ b/src/actions/simulation/tick.js @@ -1,44 +1,49 @@ -import {getDatacenterIdOfTick} from "../../util/timeline"; -import {setCurrentDatacenter} from "../topology/building"; +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"; export function incrementTick() { - return (dispatch, getState) => { - const {currentTick} = getState(); - dispatch(goToTick(currentTick + 1)); - } + return (dispatch, getState) => { + const { currentTick } = getState(); + dispatch(goToTick(currentTick + 1)); + }; } export function goToTick(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 - }); + 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 + }); + }; } export function setLastSimulatedTick(tick) { - return { - type: SET_LAST_SIMULATED_TICK, - tick - } + return { + type: SET_LAST_SIMULATED_TICK, + tick + }; } |
