diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-02 18:39:28 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:47:21 +0200 |
| commit | f119fc78dda4d1e828dde04f378a63a93e3a0a7e (patch) | |
| tree | bea1eace5d47f21a7ccb835c6a6079bc92e48710 /frontend/src/actions | |
| parent | 7f27a6370a0af25e1bf6ff8f46360c6c26c21e0b (diff) | |
Add current progress on frontend port
Diffstat (limited to 'frontend/src/actions')
| -rw-r--r-- | frontend/src/actions/experiments.js | 3 | ||||
| -rw-r--r-- | frontend/src/actions/map.js | 17 | ||||
| -rw-r--r-- | frontend/src/actions/modals/topology.js | 14 | ||||
| -rw-r--r-- | frontend/src/actions/objects.js | 13 | ||||
| -rw-r--r-- | frontend/src/actions/profile.js | 0 | ||||
| -rw-r--r-- | frontend/src/actions/simulation/tick.js | 24 | ||||
| -rw-r--r-- | frontend/src/actions/topologies.js | 16 | ||||
| -rw-r--r-- | frontend/src/actions/topology/building.js | 14 | ||||
| -rw-r--r-- | frontend/src/actions/topology/room.js | 2 | ||||
| -rw-r--r-- | frontend/src/actions/users.js | 10 |
10 files changed, 48 insertions, 65 deletions
diff --git a/frontend/src/actions/experiments.js b/frontend/src/actions/experiments.js index d0eda331..5d384abf 100644 --- a/frontend/src/actions/experiments.js +++ b/frontend/src/actions/experiments.js @@ -1,5 +1,4 @@ -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' diff --git a/frontend/src/actions/map.js b/frontend/src/actions/map.js index 4ab767f7..0d49d849 100644 --- a/frontend/src/actions/map.js +++ b/frontend/src/actions/map.js @@ -36,13 +36,7 @@ export function zoomInOnCenter(zoomIn) { 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)) } } @@ -54,13 +48,8 @@ export function zoomInOnPosition(zoomIn, x, y) { 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 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 diff --git a/frontend/src/actions/modals/topology.js b/frontend/src/actions/modals/topology.js index bc59e579..7b74e820 100644 --- a/frontend/src/actions/modals/topology.js +++ b/frontend/src/actions/modals/topology.js @@ -1,3 +1,5 @@ +export const OPEN_CHANGE_TOPOLOGY_MODAL = 'OPEN_CHANGE_TOPOLOGY_MODAL' +export const CLOSE_CHANGE_TOPOLOGY_MODAL = 'CLOSE_CHANGE_TOPOLOGY_MODAL' export const OPEN_EDIT_ROOM_NAME_MODAL = 'OPEN_EDIT_ROOM_NAME_MODAL' export const CLOSE_EDIT_ROOM_NAME_MODAL = 'CLOSE_EDIT_ROOM_NAME_MODAL' export const OPEN_DELETE_ROOM_MODAL = 'OPEN_DELETE_ROOM_MODAL' @@ -9,6 +11,18 @@ export const CLOSE_DELETE_RACK_MODAL = 'CLOSE_DELETE_RACK_MODAL' export const OPEN_DELETE_MACHINE_MODAL = 'OPEN_DELETE_MACHINE_MODAL' export const CLOSE_DELETE_MACHINE_MODAL = 'CLOSE_DELETE_MACHINE_MODAL' +export function openChangeTopologyModal() { + return { + type: OPEN_CHANGE_TOPOLOGY_MODAL, + } +} + +export function closeChangeTopologyModal() { + return { + type: CLOSE_CHANGE_TOPOLOGY_MODAL, + } +} + export function openEditRoomNameModal() { return { type: OPEN_EDIT_ROOM_NAME_MODAL, diff --git a/frontend/src/actions/objects.js b/frontend/src/actions/objects.js index 2b445c9d..7b648b18 100644 --- a/frontend/src/actions/objects.js +++ b/frontend/src/actions/objects.js @@ -1,9 +1,7 @@ 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 { @@ -32,12 +30,7 @@ export function addIdToStoreObjectListProp(objectType, objectId, propName, id) { } } -export function removeIdFromStoreObjectListProp( - objectType, - objectId, - propName, - id, -) { +export function removeIdFromStoreObjectListProp(objectType, objectId, propName, id) { return { type: REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP, objectType, diff --git a/frontend/src/actions/profile.js b/frontend/src/actions/profile.js deleted file mode 100644 index e69de29b..00000000 --- a/frontend/src/actions/profile.js +++ /dev/null diff --git a/frontend/src/actions/simulation/tick.js b/frontend/src/actions/simulation/tick.js index 72387d24..ca2027a4 100644 --- a/frontend/src/actions/simulation/tick.js +++ b/frontend/src/actions/simulation/tick.js @@ -1,6 +1,3 @@ -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' @@ -13,27 +10,6 @@ export function incrementTick() { 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, diff --git a/frontend/src/actions/topologies.js b/frontend/src/actions/topologies.js new file mode 100644 index 00000000..c80ef6b2 --- /dev/null +++ b/frontend/src/actions/topologies.js @@ -0,0 +1,16 @@ +export const ADD_TOPOLOGY = 'ADD_TOPOLOGY' +export const DELETE_TOPOLOGY = 'DELETE_TOPOLOGY' + +export function addTopology(topology) { + return { + type: ADD_TOPOLOGY, + topology, + } +} + +export function deleteTopology(id) { + return { + type: DELETE_TOPOLOGY, + id, + } +} diff --git a/frontend/src/actions/topology/building.js b/frontend/src/actions/topology/building.js index 2d4d399c..da2dc311 100644 --- a/frontend/src/actions/topology/building.js +++ b/frontend/src/actions/topology/building.js @@ -1,5 +1,5 @@ -export const SET_CURRENT_DATACENTER = 'SET_CURRENT_DATACENTER' -export const RESET_CURRENT_DATACENTER = 'RESET_CURRENT_DATACENTER' +export const SET_CURRENT_TOPOLOGY = 'SET_CURRENT_TOPOLOGY' +export const RESET_CURRENT_TOPOLOGY = 'RESET_CURRENT_TOPOLOGY' export const START_NEW_ROOM_CONSTRUCTION = 'START_NEW_ROOM_CONSTRUCTION' export const START_NEW_ROOM_CONSTRUCTION_SUCCEEDED = 'START_NEW_ROOM_CONSTRUCTION_SUCCEEDED' @@ -12,16 +12,16 @@ export const FINISH_ROOM_EDIT = 'FINISH_ROOM_EDIT' export const ADD_TILE = 'ADD_TILE' export const DELETE_TILE = 'DELETE_TILE' -export function setCurrentDatacenter(datacenterId) { +export function setCurrentTopology(topologyId) { return { - type: SET_CURRENT_DATACENTER, - datacenterId, + type: SET_CURRENT_TOPOLOGY, + topologyId, } } -export function resetCurrentDatacenter() { +export function resetCurrentTopology() { return { - type: RESET_CURRENT_DATACENTER, + type: RESET_CURRENT_TOPOLOGY, } } diff --git a/frontend/src/actions/topology/room.js b/frontend/src/actions/topology/room.js index 3476f0b6..939b475a 100644 --- a/frontend/src/actions/topology/room.js +++ b/frontend/src/actions/topology/room.js @@ -35,7 +35,7 @@ export function addRackToTile(positionX, positionY) { if (tile !== null) { dispatch({ type: ADD_RACK_TO_TILE, - tileId: tile.id, + tileId: tile._id, }) } } diff --git a/frontend/src/actions/users.js b/frontend/src/actions/users.js index cae7e211..4868ac34 100644 --- a/frontend/src/actions/users.js +++ b/frontend/src/actions/users.js @@ -1,7 +1,5 @@ -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' @@ -15,9 +13,7 @@ export function fetchAuthorizationsOfCurrentUser() { } } -export function fetchAuthorizationsOfCurrentUserSucceeded( - authorizationsOfCurrentUser, -) { +export function fetchAuthorizationsOfCurrentUserSucceeded(authorizationsOfCurrentUser) { return { type: FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED, authorizationsOfCurrentUser, |
