diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-10-04 22:49:07 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-10-04 22:49:25 +0200 |
| commit | 751a9ef3a12c952fe179f256d854d0c4aa37e28e (patch) | |
| tree | 241fc22c592a277526e73cc70ea0f95d5a8a7b29 /src/actions | |
| parent | 9257d89ec2e22b65ffecc7dc7cf67b7a74c34d60 (diff) | |
Apply prettier to codebase
Diffstat (limited to 'src/actions')
| -rw-r--r-- | src/actions/auth.js | 22 | ||||
| -rw-r--r-- | src/actions/experiments.js | 37 | ||||
| -rw-r--r-- | src/actions/interaction-level.js | 66 | ||||
| -rw-r--r-- | src/actions/map.js | 109 | ||||
| -rw-r--r-- | src/actions/modals/experiments.js | 12 | ||||
| -rw-r--r-- | src/actions/modals/profile.js | 12 | ||||
| -rw-r--r-- | src/actions/modals/simulations.js | 12 | ||||
| -rw-r--r-- | src/actions/modals/topology.js | 60 | ||||
| -rw-r--r-- | src/actions/objects.js | 63 | ||||
| -rw-r--r-- | src/actions/profile.js | 3 | ||||
| -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 | ||||
| -rw-r--r-- | src/actions/simulations.js | 56 | ||||
| -rw-r--r-- | src/actions/states.js | 10 | ||||
| -rw-r--r-- | src/actions/topology/building.js | 113 | ||||
| -rw-r--r-- | src/actions/topology/machine.js | 26 | ||||
| -rw-r--r-- | src/actions/topology/rack.js | 22 | ||||
| -rw-r--r-- | src/actions/topology/room.js | 52 | ||||
| -rw-r--r-- | src/actions/users.js | 52 |
20 files changed, 428 insertions, 390 deletions
diff --git a/src/actions/auth.js b/src/actions/auth.js index 2ca6a986..45e2eb35 100644 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -3,21 +3,21 @@ export const LOG_IN_SUCCEEDED = "LOG_IN_SUCCEEDED"; export const LOG_OUT = "LOG_OUT"; export function logIn(payload) { - return { - type: LOG_IN, - payload - }; + return { + type: LOG_IN, + payload + }; } export function logInSucceeded(payload) { - return { - type: LOG_IN_SUCCEEDED, - payload - }; + return { + type: LOG_IN_SUCCEEDED, + payload + }; } export function logOut() { - return { - type: LOG_OUT - }; + return { + type: LOG_OUT + }; } diff --git a/src/actions/experiments.js b/src/actions/experiments.js index c64df019..b5709981 100644 --- a/src/actions/experiments.js +++ b/src/actions/experiments.js @@ -1,33 +1,34 @@ -export const FETCH_EXPERIMENTS_OF_SIMULATION = "FETCH_EXPERIMENTS_OF_SIMULATION"; +export const FETCH_EXPERIMENTS_OF_SIMULATION = + "FETCH_EXPERIMENTS_OF_SIMULATION"; export const ADD_EXPERIMENT = "ADD_EXPERIMENT"; export const DELETE_EXPERIMENT = "DELETE_EXPERIMENT"; export const OPEN_EXPERIMENT_SUCCEEDED = "OPEN_EXPERIMENT_SUCCEEDED"; export function fetchExperimentsOfSimulation(simulationId) { - return { - type: FETCH_EXPERIMENTS_OF_SIMULATION, - simulationId - }; + return { + type: FETCH_EXPERIMENTS_OF_SIMULATION, + simulationId + }; } export function addExperiment(experiment) { - return { - type: ADD_EXPERIMENT, - experiment - }; + return { + type: ADD_EXPERIMENT, + experiment + }; } export function deleteExperiment(id) { - return { - type: DELETE_EXPERIMENT, - id - }; + return { + type: DELETE_EXPERIMENT, + id + }; } export function openExperimentSucceeded(simulationId, experimentId) { - return { - type: OPEN_EXPERIMENT_SUCCEEDED, - simulationId, - experimentId - } + return { + type: OPEN_EXPERIMENT_SUCCEEDED, + simulationId, + experimentId + }; } diff --git a/src/actions/interaction-level.js b/src/actions/interaction-level.js index 2003f45e..31120146 100644 --- a/src/actions/interaction-level.js +++ b/src/actions/interaction-level.js @@ -4,47 +4,47 @@ export const GO_FROM_RACK_TO_MACHINE = "GO_FROM_RACK_TO_MACHINE"; export const GO_DOWN_ONE_INTERACTION_LEVEL = "GO_DOWN_ONE_INTERACTION_LEVEL"; export function goFromBuildingToRoom(roomId) { - return (dispatch, getState) => { - const {interactionLevel} = getState(); - if (interactionLevel.mode !== "BUILDING") { - return; - } + return (dispatch, getState) => { + const { interactionLevel } = getState(); + if (interactionLevel.mode !== "BUILDING") { + return; + } - dispatch({ - type: GO_FROM_BUILDING_TO_ROOM, - roomId - }); - }; + dispatch({ + type: GO_FROM_BUILDING_TO_ROOM, + roomId + }); + }; } export function goFromRoomToRack(tileId) { - return (dispatch, getState) => { - const {interactionLevel} = getState(); - if (interactionLevel.mode !== "ROOM") { - return; - } - dispatch({ - type: GO_FROM_ROOM_TO_RACK, - tileId - }); - }; + return (dispatch, getState) => { + const { interactionLevel } = getState(); + if (interactionLevel.mode !== "ROOM") { + return; + } + dispatch({ + type: GO_FROM_ROOM_TO_RACK, + tileId + }); + }; } export function goFromRackToMachine(position) { - return (dispatch, getState) => { - const {interactionLevel} = getState(); - if (interactionLevel.mode !== "RACK") { - return; - } - dispatch({ - type: GO_FROM_RACK_TO_MACHINE, - position - }); - }; + return (dispatch, getState) => { + const { interactionLevel } = getState(); + if (interactionLevel.mode !== "RACK") { + return; + } + dispatch({ + type: GO_FROM_RACK_TO_MACHINE, + position + }); + }; } export function goDownOneInteractionLevel() { - return { - type: GO_DOWN_ONE_INTERACTION_LEVEL - }; + return { + type: GO_DOWN_ONE_INTERACTION_LEVEL + }; } diff --git a/src/actions/map.js b/src/actions/map.js index 47d4714d..82546c00 100644 --- a/src/actions/map.js +++ b/src/actions/map.js @@ -1,8 +1,8 @@ import { - MAP_MAX_SCALE, - MAP_MIN_SCALE, - MAP_SCALE_PER_EVENT, - MAP_SIZE_IN_PIXELS + MAP_MAX_SCALE, + MAP_MIN_SCALE, + MAP_SCALE_PER_EVENT, + MAP_SIZE_IN_PIXELS } from "../components/app/map/MapConstants"; export const SET_MAP_POSITION = "SET_MAP_POSITION"; @@ -10,67 +10,84 @@ export const SET_MAP_DIMENSIONS = "SET_MAP_DIMENSIONS"; export const SET_MAP_SCALE = "SET_MAP_SCALE"; export function setMapPosition(x, y) { - return { - type: SET_MAP_POSITION, - x, - y - }; + return { + type: SET_MAP_POSITION, + x, + y + }; } export function setMapDimensions(width, height) { - return { - type: SET_MAP_DIMENSIONS, - width, - height - }; + return { + type: SET_MAP_DIMENSIONS, + width, + height + }; } export function setMapScale(scale) { - return { - type: SET_MAP_SCALE, - scale - }; + return { + type: SET_MAP_SCALE, + scale + }; } export function zoomInOnCenter(zoomIn) { - return (dispatch, getState) => { - const state = getState(); + return (dispatch, getState) => { + const state = getState(); - dispatch(zoomInOnPosition(zoomIn, state.map.dimensions.width / 2, state.map.dimensions.height / 2)); - } + dispatch( + zoomInOnPosition( + zoomIn, + state.map.dimensions.width / 2, + state.map.dimensions.height / 2 + ) + ); + }; } export function zoomInOnPosition(zoomIn, x, y) { - return (dispatch, getState) => { - const state = getState(); + return (dispatch, getState) => { + const state = getState(); - const centerPoint = { - x: x / state.map.scale - state.map.position.x / state.map.scale, - y: y / state.map.scale - state.map.position.y / state.map.scale, - }; - const newScale = zoomIn ? state.map.scale * MAP_SCALE_PER_EVENT : state.map.scale / MAP_SCALE_PER_EVENT; - const boundedScale = Math.min(Math.max(MAP_MIN_SCALE, newScale), MAP_MAX_SCALE); + const centerPoint = { + x: x / state.map.scale - state.map.position.x / state.map.scale, + y: y / state.map.scale - state.map.position.y / state.map.scale + }; + const newScale = zoomIn + ? state.map.scale * MAP_SCALE_PER_EVENT + : state.map.scale / MAP_SCALE_PER_EVENT; + const boundedScale = Math.min( + Math.max(MAP_MIN_SCALE, newScale), + MAP_MAX_SCALE + ); - const newX = -(centerPoint.x - x / boundedScale) * boundedScale; - const newY = -(centerPoint.y - y / boundedScale) * boundedScale; + const newX = -(centerPoint.x - x / boundedScale) * boundedScale; + const newY = -(centerPoint.y - y / boundedScale) * boundedScale; - dispatch(setMapPositionWithBoundsCheck(newX, newY)); - dispatch(setMapScale(boundedScale)); - } + dispatch(setMapPositionWithBoundsCheck(newX, newY)); + dispatch(setMapScale(boundedScale)); + }; } export function setMapPositionWithBoundsCheck(x, y) { - return (dispatch, getState) => { - const state = getState(); + return (dispatch, getState) => { + const state = getState(); - const scaledMapSize = MAP_SIZE_IN_PIXELS * state.map.scale; - const updatedX = x > 0 ? 0 : - (x < -scaledMapSize + state.map.dimensions.width - ? -scaledMapSize + state.map.dimensions.width : x); - const updatedY = y > 0 ? 0 : - (y < -scaledMapSize + state.map.dimensions.height - ? -scaledMapSize + state.map.dimensions.height : y); + const scaledMapSize = MAP_SIZE_IN_PIXELS * state.map.scale; + const updatedX = + x > 0 + ? 0 + : x < -scaledMapSize + state.map.dimensions.width + ? -scaledMapSize + state.map.dimensions.width + : x; + const updatedY = + y > 0 + ? 0 + : y < -scaledMapSize + state.map.dimensions.height + ? -scaledMapSize + state.map.dimensions.height + : y; - dispatch(setMapPosition(updatedX, updatedY)); - } + dispatch(setMapPosition(updatedX, updatedY)); + }; } diff --git a/src/actions/modals/experiments.js b/src/actions/modals/experiments.js index 43a53a3a..df939fa5 100644 --- a/src/actions/modals/experiments.js +++ b/src/actions/modals/experiments.js @@ -2,13 +2,13 @@ export const OPEN_NEW_EXPERIMENT_MODAL = "OPEN_NEW_EXPERIMENT_MODAL"; export const CLOSE_NEW_EXPERIMENT_MODAL = "CLOSE_EXPERIMENT_MODAL"; export function openNewExperimentModal() { - return { - type: OPEN_NEW_EXPERIMENT_MODAL - }; + return { + type: OPEN_NEW_EXPERIMENT_MODAL + }; } export function closeNewExperimentModal() { - return { - type: CLOSE_NEW_EXPERIMENT_MODAL - }; + return { + type: CLOSE_NEW_EXPERIMENT_MODAL + }; } diff --git a/src/actions/modals/profile.js b/src/actions/modals/profile.js index 421e7602..ee52610c 100644 --- a/src/actions/modals/profile.js +++ b/src/actions/modals/profile.js @@ -2,13 +2,13 @@ export const OPEN_DELETE_PROFILE_MODAL = "OPEN_DELETE_PROFILE_MODAL"; export const CLOSE_DELETE_PROFILE_MODAL = "CLOSE_DELETE_PROFILE_MODAL"; export function openDeleteProfileModal() { - return { - type: OPEN_DELETE_PROFILE_MODAL - }; + return { + type: OPEN_DELETE_PROFILE_MODAL + }; } export function closeDeleteProfileModal() { - return { - type: CLOSE_DELETE_PROFILE_MODAL - }; + return { + type: CLOSE_DELETE_PROFILE_MODAL + }; } diff --git a/src/actions/modals/simulations.js b/src/actions/modals/simulations.js index 8281238d..b11d356c 100644 --- a/src/actions/modals/simulations.js +++ b/src/actions/modals/simulations.js @@ -2,13 +2,13 @@ export const OPEN_NEW_SIMULATION_MODAL = "OPEN_NEW_SIMULATION_MODAL"; export const CLOSE_NEW_SIMULATION_MODAL = "CLOSE_SIMULATION_MODAL"; export function openNewSimulationModal() { - return { - type: OPEN_NEW_SIMULATION_MODAL - }; + return { + type: OPEN_NEW_SIMULATION_MODAL + }; } export function closeNewSimulationModal() { - return { - type: CLOSE_NEW_SIMULATION_MODAL - }; + return { + type: CLOSE_NEW_SIMULATION_MODAL + }; } diff --git a/src/actions/modals/topology.js b/src/actions/modals/topology.js index b8e297e0..7ee16522 100644 --- a/src/actions/modals/topology.js +++ b/src/actions/modals/topology.js @@ -10,61 +10,61 @@ export const OPEN_DELETE_MACHINE_MODAL = "OPEN_DELETE_MACHINE_MODAL"; export const CLOSE_DELETE_MACHINE_MODAL = "CLOSE_DELETE_MACHINE_MODAL"; export function openEditRoomNameModal() { - return { - type: OPEN_EDIT_ROOM_NAME_MODAL - }; + return { + type: OPEN_EDIT_ROOM_NAME_MODAL + }; } export function closeEditRoomNameModal() { - return { - type: CLOSE_EDIT_ROOM_NAME_MODAL - }; + return { + type: CLOSE_EDIT_ROOM_NAME_MODAL + }; } export function openDeleteRoomModal() { - return { - type: OPEN_DELETE_ROOM_MODAL - }; + return { + type: OPEN_DELETE_ROOM_MODAL + }; } export function closeDeleteRoomModal() { - return { - type: CLOSE_DELETE_ROOM_MODAL - }; + return { + type: CLOSE_DELETE_ROOM_MODAL + }; } export function openEditRackNameModal() { - return { - type: OPEN_EDIT_RACK_NAME_MODAL - }; + return { + type: OPEN_EDIT_RACK_NAME_MODAL + }; } export function closeEditRackNameModal() { - return { - type: CLOSE_EDIT_RACK_NAME_MODAL - }; + return { + type: CLOSE_EDIT_RACK_NAME_MODAL + }; } export function openDeleteRackModal() { - return { - type: OPEN_DELETE_RACK_MODAL - }; + return { + type: OPEN_DELETE_RACK_MODAL + }; } export function closeDeleteRackModal() { - return { - type: CLOSE_DELETE_RACK_MODAL - }; + return { + type: CLOSE_DELETE_RACK_MODAL + }; } export function openDeleteMachineModal() { - return { - type: OPEN_DELETE_MACHINE_MODAL - }; + return { + type: OPEN_DELETE_MACHINE_MODAL + }; } export function closeDeleteMachineModal() { - return { - type: CLOSE_DELETE_MACHINE_MODAL - }; + return { + type: CLOSE_DELETE_MACHINE_MODAL + }; } diff --git a/src/actions/objects.js b/src/actions/objects.js index 60885471..80b56c0c 100644 --- a/src/actions/objects.js +++ b/src/actions/objects.js @@ -1,41 +1,48 @@ export const ADD_TO_STORE = "ADD_TO_STORE"; export const ADD_PROP_TO_STORE_OBJECT = "ADD_PROP_TO_STORE_OBJECT"; -export const ADD_ID_TO_STORE_OBJECT_LIST_PROP = "ADD_ID_TO_STORE_OBJECT_LIST_PROP"; -export const REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP = "REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP"; +export const ADD_ID_TO_STORE_OBJECT_LIST_PROP = + "ADD_ID_TO_STORE_OBJECT_LIST_PROP"; +export const REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP = + "REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP"; export function addToStore(objectType, object) { - return { - type: ADD_TO_STORE, - objectType, - object - }; + return { + type: ADD_TO_STORE, + objectType, + object + }; } export function addPropToStoreObject(objectType, objectId, propObject) { - return { - type: ADD_PROP_TO_STORE_OBJECT, - objectType, - objectId, - propObject - }; + return { + type: ADD_PROP_TO_STORE_OBJECT, + objectType, + objectId, + propObject + }; } export function addIdToStoreObjectListProp(objectType, objectId, propName, id) { - return { - type: ADD_ID_TO_STORE_OBJECT_LIST_PROP, - objectType, - objectId, - propName, - id - }; + return { + type: ADD_ID_TO_STORE_OBJECT_LIST_PROP, + objectType, + objectId, + propName, + id + }; } -export function removeIdFromStoreObjectListProp(objectType, objectId, propName, id) { - return { - type: REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP, - objectType, - objectId, - propName, - id - }; +export function removeIdFromStoreObjectListProp( + objectType, + objectId, + propName, + id +) { + return { + type: REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP, + objectType, + objectId, + propName, + id + }; } diff --git a/src/actions/profile.js b/src/actions/profile.js index b28b04f6..e69de29b 100644 --- a/src/actions/profile.js +++ b/src/actions/profile.js @@ -1,3 +0,0 @@ - - - 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 + }; } diff --git a/src/actions/simulations.js b/src/actions/simulations.js index 145ceab2..6da7aa3a 100644 --- a/src/actions/simulations.js +++ b/src/actions/simulations.js @@ -6,47 +6,47 @@ export const DELETE_SIMULATION_SUCCEEDED = "DELETE_SIMULATION_SUCCEEDED"; export const OPEN_SIMULATION_SUCCEEDED = "OPEN_SIMULATION_SUCCEEDED"; export function setAuthVisibilityFilter(filter) { - return { - type: SET_AUTH_VISIBILITY_FILTER, - filter - }; + return { + type: SET_AUTH_VISIBILITY_FILTER, + filter + }; } export function addSimulation(name) { - return (dispatch, getState) => { - const {auth} = getState(); - dispatch({ - type: ADD_SIMULATION, - name, - userId: auth.userId - }); - }; + return (dispatch, getState) => { + const { auth } = getState(); + dispatch({ + type: ADD_SIMULATION, + name, + userId: auth.userId + }); + }; } export function addSimulationSucceeded(authorization) { - return { - type: ADD_SIMULATION_SUCCEEDED, - authorization - }; + return { + type: ADD_SIMULATION_SUCCEEDED, + authorization + }; } export function deleteSimulation(id) { - return { - type: DELETE_SIMULATION, - id - }; + return { + type: DELETE_SIMULATION, + id + }; } export function deleteSimulationSucceeded(id) { - return { - type: DELETE_SIMULATION_SUCCEEDED, - id - }; + return { + type: DELETE_SIMULATION_SUCCEEDED, + id + }; } export function openSimulationSucceeded(id) { - return { - type: OPEN_SIMULATION_SUCCEEDED, - id - }; + return { + type: OPEN_SIMULATION_SUCCEEDED, + id + }; } diff --git a/src/actions/states.js b/src/actions/states.js index 29baa326..b3a355a2 100644 --- a/src/actions/states.js +++ b/src/actions/states.js @@ -1,9 +1,9 @@ export const ADD_BATCH_TO_STATES = "ADD_BATCH_TO_STATES"; export function addBatchToStates(objectType, objects) { - return { - type: ADD_BATCH_TO_STATES, - objectType, - objects - }; + return { + type: ADD_BATCH_TO_STATES, + objectType, + objects + }; } diff --git a/src/actions/topology/building.js b/src/actions/topology/building.js index 019a473c..5aef2932 100644 --- a/src/actions/topology/building.js +++ b/src/actions/topology/building.js @@ -1,92 +1,99 @@ export const SET_CURRENT_DATACENTER = "SET_CURRENT_DATACENTER"; export const RESET_CURRENT_DATACENTER = "RESET_CURRENT_DATACENTER"; export const START_NEW_ROOM_CONSTRUCTION = "START_NEW_ROOM_CONSTRUCTION"; -export const START_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "START_NEW_ROOM_CONSTRUCTION_SUCCEEDED"; +export const START_NEW_ROOM_CONSTRUCTION_SUCCEEDED = + "START_NEW_ROOM_CONSTRUCTION_SUCCEEDED"; export const FINISH_NEW_ROOM_CONSTRUCTION = "FINISH_NEW_ROOM_CONSTRUCTION"; export const CANCEL_NEW_ROOM_CONSTRUCTION = "CANCEL_NEW_ROOM_CONSTRUCTION"; -export const CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED"; +export const CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED = + "CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED"; export const ADD_TILE = "ADD_TILE"; export const DELETE_TILE = "DELETE_TILE"; export function setCurrentDatacenter(datacenterId) { - return { - type: SET_CURRENT_DATACENTER, - datacenterId - }; + return { + type: SET_CURRENT_DATACENTER, + datacenterId + }; } export function resetCurrentDatacenter() { - return { - type: RESET_CURRENT_DATACENTER - }; + return { + type: RESET_CURRENT_DATACENTER + }; } export function startNewRoomConstruction() { - return { - type: START_NEW_ROOM_CONSTRUCTION - }; + return { + type: START_NEW_ROOM_CONSTRUCTION + }; } export function startNewRoomConstructionSucceeded(roomId) { - return { - type: START_NEW_ROOM_CONSTRUCTION_SUCCEEDED, - roomId - }; + return { + type: START_NEW_ROOM_CONSTRUCTION_SUCCEEDED, + roomId + }; } export function finishNewRoomConstruction() { - return (dispatch, getState) => { - const {objects, construction} = getState(); - if (objects.room[construction.currentRoomInConstruction].tileIds.length === 0) { - dispatch(cancelNewRoomConstruction()); - return; - } + return (dispatch, getState) => { + const { objects, construction } = getState(); + if ( + objects.room[construction.currentRoomInConstruction].tileIds.length === 0 + ) { + dispatch(cancelNewRoomConstruction()); + return; + } - dispatch({ - type: FINISH_NEW_ROOM_CONSTRUCTION - }); - }; + dispatch({ + type: FINISH_NEW_ROOM_CONSTRUCTION + }); + }; } export function cancelNewRoomConstruction() { - return { - type: CANCEL_NEW_ROOM_CONSTRUCTION - }; + return { + type: CANCEL_NEW_ROOM_CONSTRUCTION + }; } export function cancelNewRoomConstructionSucceeded() { - return { - type: CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED - }; + return { + type: CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED + }; } export function toggleTileAtLocation(positionX, positionY) { - return (dispatch, getState) => { - const {objects, construction} = getState(); + return (dispatch, getState) => { + const { objects, construction } = getState(); - const tileIds = objects.room[construction.currentRoomInConstruction].tileIds; - for (let index in tileIds) { - if (objects.tile[tileIds[index]].positionX === positionX - && objects.tile[tileIds[index]].positionY === positionY) { - dispatch(deleteTile(tileIds[index])); - return; - } - } - dispatch(addTile(positionX, positionY)); - }; + const tileIds = + objects.room[construction.currentRoomInConstruction].tileIds; + for (let index in tileIds) { + if ( + objects.tile[tileIds[index]].positionX === positionX && + objects.tile[tileIds[index]].positionY === positionY + ) { + dispatch(deleteTile(tileIds[index])); + return; + } + } + dispatch(addTile(positionX, positionY)); + }; } export function addTile(positionX, positionY) { - return { - type: ADD_TILE, - positionX, - positionY - }; + return { + type: ADD_TILE, + positionX, + positionY + }; } export function deleteTile(tileId) { - return { - type: DELETE_TILE, - tileId - } + return { + type: DELETE_TILE, + tileId + }; } diff --git a/src/actions/topology/machine.js b/src/actions/topology/machine.js index 48d88052..56968b7d 100644 --- a/src/actions/topology/machine.js +++ b/src/actions/topology/machine.js @@ -3,23 +3,23 @@ export const ADD_UNIT = "ADD_UNIT"; export const DELETE_UNIT = "DELETE_UNIT"; export function deleteMachine() { - return { - type: DELETE_MACHINE - }; + return { + type: DELETE_MACHINE + }; } export function addUnit(unitType, id) { - return { - type: ADD_UNIT, - unitType, - id - }; + return { + type: ADD_UNIT, + unitType, + id + }; } export function deleteUnit(unitType, index) { - return { - type: DELETE_UNIT, - unitType, - index - }; + return { + type: DELETE_UNIT, + unitType, + index + }; } diff --git a/src/actions/topology/rack.js b/src/actions/topology/rack.js index 043d6190..06988424 100644 --- a/src/actions/topology/rack.js +++ b/src/actions/topology/rack.js @@ -3,21 +3,21 @@ export const DELETE_RACK = "DELETE_RACK"; export const ADD_MACHINE = "ADD_MACHINE"; export function editRackName(name) { - return { - type: EDIT_RACK_NAME, - name - }; + return { + type: EDIT_RACK_NAME, + name + }; } export function deleteRack() { - return { - type: DELETE_RACK - }; + return { + type: DELETE_RACK + }; } export function addMachine(position) { - return { - type: ADD_MACHINE, - position - }; + return { + type: ADD_MACHINE, + position + }; } diff --git a/src/actions/topology/room.js b/src/actions/topology/room.js index 884c7e84..4e0fc3a2 100644 --- a/src/actions/topology/room.js +++ b/src/actions/topology/room.js @@ -1,4 +1,4 @@ -import {findTileWithPosition} from "../../util/tile-calculations"; +import { findTileWithPosition } from "../../util/tile-calculations"; export const EDIT_ROOM_NAME = "EDIT_ROOM_NAME"; export const DELETE_ROOM = "DELETE_ROOM"; @@ -7,42 +7,42 @@ export const STOP_RACK_CONSTRUCTION = "STOP_RACK_CONSTRUCTION"; export const ADD_RACK_TO_TILE = "ADD_RACK_TO_TILE"; export function editRoomName(name) { - return { - type: EDIT_ROOM_NAME, - name - }; + return { + type: EDIT_ROOM_NAME, + name + }; } export function startRackConstruction() { - return { - type: START_RACK_CONSTRUCTION - }; + return { + type: START_RACK_CONSTRUCTION + }; } export function stopRackConstruction() { - return { - type: STOP_RACK_CONSTRUCTION - }; + return { + type: STOP_RACK_CONSTRUCTION + }; } export function addRackToTile(positionX, positionY) { - return (dispatch, getState) => { - const {objects, interactionLevel} = getState(); - const currentRoom = objects.room[interactionLevel.roomId]; - const tiles = currentRoom.tileIds.map(tileId => objects.tile[tileId]); - const tile = findTileWithPosition(tiles, positionX, positionY); + return (dispatch, getState) => { + const { objects, interactionLevel } = getState(); + const currentRoom = objects.room[interactionLevel.roomId]; + const tiles = currentRoom.tileIds.map(tileId => objects.tile[tileId]); + const tile = findTileWithPosition(tiles, positionX, positionY); - if (tile !== null) { - dispatch({ - type: ADD_RACK_TO_TILE, - tileId: tile.id - }); - } - }; + if (tile !== null) { + dispatch({ + type: ADD_RACK_TO_TILE, + tileId: tile.id + }); + } + }; } export function deleteRoom() { - return { - type: DELETE_ROOM - }; + return { + type: DELETE_ROOM + }; } diff --git a/src/actions/users.js b/src/actions/users.js index 04a5b95a..dc393df9 100644 --- a/src/actions/users.js +++ b/src/actions/users.js @@ -1,37 +1,41 @@ -export const FETCH_AUTHORIZATIONS_OF_CURRENT_USER = "FETCH_AUTHORIZATIONS_OF_CURRENT_USER"; -export const FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED = "FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED"; +export const FETCH_AUTHORIZATIONS_OF_CURRENT_USER = + "FETCH_AUTHORIZATIONS_OF_CURRENT_USER"; +export const FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED = + "FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED"; export const DELETE_CURRENT_USER = "DELETE_CURRENT_USER"; export const DELETE_CURRENT_USER_SUCCEEDED = "DELETE_CURRENT_USER_SUCCEEDED"; export function fetchAuthorizationsOfCurrentUser() { - return (dispatch, getState) => { - const {auth} = getState(); - dispatch({ - type: FETCH_AUTHORIZATIONS_OF_CURRENT_USER, - userId: auth.userId - }); - }; + return (dispatch, getState) => { + const { auth } = getState(); + dispatch({ + type: FETCH_AUTHORIZATIONS_OF_CURRENT_USER, + userId: auth.userId + }); + }; } -export function fetchAuthorizationsOfCurrentUserSucceeded(authorizationsOfCurrentUser) { - return { - type: FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED, - authorizationsOfCurrentUser - }; +export function fetchAuthorizationsOfCurrentUserSucceeded( + authorizationsOfCurrentUser +) { + return { + type: FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED, + authorizationsOfCurrentUser + }; } export function deleteCurrentUser() { - return (dispatch, getState) => { - const {auth} = getState(); - dispatch({ - type: DELETE_CURRENT_USER, - userId: auth.userId - }); - }; + return (dispatch, getState) => { + const { auth } = getState(); + dispatch({ + type: DELETE_CURRENT_USER, + userId: auth.userId + }); + }; } export function deleteCurrentUserSucceeded() { - return { - type: DELETE_CURRENT_USER_SUCCEEDED - }; + return { + type: DELETE_CURRENT_USER_SUCCEEDED + }; } |
