summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/actions
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-18 20:34:13 +0200
committerGitHub <noreply@github.com>2021-05-18 20:34:13 +0200
commit56bd2ef6b0583fee1dd2da5dceaf57feb07649c9 (patch)
tree6d4cfbc44c97cd3ec1e30aa977cd08f404b41b0d /opendc-web/opendc-web-ui/src/actions
parent02776c958a3254735b2be7d9fb1627f75e7f80cd (diff)
parentce95cfdf803043e66e2279d0f76c6bfc64e7864e (diff)
Migrate to Auth0 as Identity Provider
This pull request removes the hard dependency on Google for authenticating users and migrates to Auth0 as Identity Provider for OpenDC. This has as benefit that we can authenticate users without having to manage user data ourselves and do not have a dependency on Google accounts anymore. - Frontend cleanup: - Use CSS modules everywhere to encapsulate the styling of React components. - Perform all communication in the frontend via the REST API (as opposed to WebSockets). The original approach was aimed at collaborative editing, but made normal operations harder to implement and debug. If we want to implement collaborative editing in the future, we can expose only a small WebSocket API specifically for collaborative editing. - Move to FontAwesome 5 (using the official React libraries) - Use Reactstrap where possible. Previously, we mixed raw Bootstrap classes with Reactstrap, which is confusing. - Reduce the scope of the Redux state. Some state in the frontend application can be kept locally and does not need to be managed by Redux. - Migrate from Create React App (CRA) to Next.js since it allows us to pre-render multiple pages as well as opt-in to Server Side Rendering. - Remove the Google login and use Auth0 for authentication now. - Use Node 16 - Backend cleanup: - Remove Socket.IO endpoint from backend, since it is not needed by the frontend anymore. Removing it reduces the attack surface of OpenDC as well as the maintenance efforts. - Use Auth0 JWT token for authorizing API accesses - Refactor API endpoints to use Flask Restful as opposed to our custom in-house routing logic. Previously, this was needed to support the Socket.IO endpoint, but increases maintenance effort. - Expose Swagger UI from API - Use Python 3.9 and uwsgi to host Flask application - Actualize OpenAPI schema and update to version 3.0. **Breaking API Changes** * This pull request removes the users collection from the database table. Instead, we now use the user identifier passed by Auth0 to identify the data that belongs to a user.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/actions')
-rw-r--r--opendc-web/opendc-web-ui/src/actions/auth.js23
-rw-r--r--opendc-web/opendc-web-ui/src/actions/interaction-level.js50
-rw-r--r--opendc-web/opendc-web-ui/src/actions/map.js82
-rw-r--r--opendc-web/opendc-web-ui/src/actions/modals/portfolios.js14
-rw-r--r--opendc-web/opendc-web-ui/src/actions/modals/prefabs.js14
-rw-r--r--opendc-web/opendc-web-ui/src/actions/modals/profile.js14
-rw-r--r--opendc-web/opendc-web-ui/src/actions/modals/projects.js14
-rw-r--r--opendc-web/opendc-web-ui/src/actions/modals/scenarios.js14
-rw-r--r--opendc-web/opendc-web-ui/src/actions/modals/topology.js84
-rw-r--r--opendc-web/opendc-web-ui/src/actions/objects.js41
-rw-r--r--opendc-web/opendc-web-ui/src/actions/portfolios.js41
-rw-r--r--opendc-web/opendc-web-ui/src/actions/prefabs.js32
-rw-r--r--opendc-web/opendc-web-ui/src/actions/projects.js52
-rw-r--r--opendc-web/opendc-web-ui/src/actions/scenarios.js43
-rw-r--r--opendc-web/opendc-web-ui/src/actions/topologies.js17
-rw-r--r--opendc-web/opendc-web-ui/src/actions/topology/building.js105
-rw-r--r--opendc-web/opendc-web-ui/src/actions/topology/machine.js25
-rw-r--r--opendc-web/opendc-web-ui/src/actions/topology/rack.js23
-rw-r--r--opendc-web/opendc-web-ui/src/actions/topology/room.js48
-rw-r--r--opendc-web/opendc-web-ui/src/actions/users.js37
20 files changed, 0 insertions, 773 deletions
diff --git a/opendc-web/opendc-web-ui/src/actions/auth.js b/opendc-web/opendc-web-ui/src/actions/auth.js
deleted file mode 100644
index 38c1a782..00000000
--- a/opendc-web/opendc-web-ui/src/actions/auth.js
+++ /dev/null
@@ -1,23 +0,0 @@
-export const LOG_IN = 'LOG_IN'
-export const LOG_IN_SUCCEEDED = 'LOG_IN_SUCCEEDED'
-export const LOG_OUT = 'LOG_OUT'
-
-export function logIn(payload) {
- return {
- type: LOG_IN,
- payload,
- }
-}
-
-export function logInSucceeded(payload) {
- return {
- type: LOG_IN_SUCCEEDED,
- payload,
- }
-}
-
-export function logOut() {
- return {
- type: LOG_OUT,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/interaction-level.js b/opendc-web/opendc-web-ui/src/actions/interaction-level.js
deleted file mode 100644
index ff6b1fa3..00000000
--- a/opendc-web/opendc-web-ui/src/actions/interaction-level.js
+++ /dev/null
@@ -1,50 +0,0 @@
-export const GO_FROM_BUILDING_TO_ROOM = 'GO_FROM_BUILDING_TO_ROOM'
-export const GO_FROM_ROOM_TO_RACK = 'GO_FROM_ROOM_TO_RACK'
-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
- }
-
- 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,
- })
- }
-}
-
-export function goFromRackToMachine(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,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/map.js b/opendc-web/opendc-web-ui/src/actions/map.js
deleted file mode 100644
index 0d49d849..00000000
--- a/opendc-web/opendc-web-ui/src/actions/map.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import {
- 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'
-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,
- }
-}
-
-export function setMapDimensions(width, height) {
- return {
- type: SET_MAP_DIMENSIONS,
- width,
- height,
- }
-}
-
-export function setMapScale(scale) {
- return {
- type: SET_MAP_SCALE,
- scale,
- }
-}
-
-export function zoomInOnCenter(zoomIn) {
- return (dispatch, getState) => {
- const state = getState()
-
- 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()
-
- 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
-
- dispatch(setMapPositionWithBoundsCheck(newX, newY))
- dispatch(setMapScale(boundedScale))
- }
-}
-
-export function setMapPositionWithBoundsCheck(x, y) {
- 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
-
- dispatch(setMapPosition(updatedX, updatedY))
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/modals/portfolios.js b/opendc-web/opendc-web-ui/src/actions/modals/portfolios.js
deleted file mode 100644
index f6dce2e3..00000000
--- a/opendc-web/opendc-web-ui/src/actions/modals/portfolios.js
+++ /dev/null
@@ -1,14 +0,0 @@
-export const OPEN_NEW_PORTFOLIO_MODAL = 'OPEN_NEW_PORTFOLIO_MODAL'
-export const CLOSE_NEW_PORTFOLIO_MODAL = 'CLOSE_PORTFOLIO_MODAL'
-
-export function openNewPortfolioModal() {
- return {
- type: OPEN_NEW_PORTFOLIO_MODAL,
- }
-}
-
-export function closeNewPortfolioModal() {
- return {
- type: CLOSE_NEW_PORTFOLIO_MODAL,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/modals/prefabs.js b/opendc-web/opendc-web-ui/src/actions/modals/prefabs.js
deleted file mode 100644
index 826565d2..00000000
--- a/opendc-web/opendc-web-ui/src/actions/modals/prefabs.js
+++ /dev/null
@@ -1,14 +0,0 @@
-export const OPEN_NEW_PREFAB_MODAL = 'OPEN_NEW_PREFAB_MODAL'
-export const CLOSE_NEW_PREFAB_MODAL = 'CLOSE_PREFAB_MODAL'
-
-export function openNewPrefabModal() {
- return {
- type: OPEN_NEW_PREFAB_MODAL,
- }
-}
-
-export function closeNewPrefabModal() {
- return {
- type: CLOSE_NEW_PREFAB_MODAL,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/modals/profile.js b/opendc-web/opendc-web-ui/src/actions/modals/profile.js
deleted file mode 100644
index 39c72c03..00000000
--- a/opendc-web/opendc-web-ui/src/actions/modals/profile.js
+++ /dev/null
@@ -1,14 +0,0 @@
-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,
- }
-}
-
-export function closeDeleteProfileModal() {
- return {
- type: CLOSE_DELETE_PROFILE_MODAL,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/modals/projects.js b/opendc-web/opendc-web-ui/src/actions/modals/projects.js
deleted file mode 100644
index d1043cbb..00000000
--- a/opendc-web/opendc-web-ui/src/actions/modals/projects.js
+++ /dev/null
@@ -1,14 +0,0 @@
-export const OPEN_NEW_PROJECT_MODAL = 'OPEN_NEW_PROJECT_MODAL'
-export const CLOSE_NEW_PROJECT_MODAL = 'CLOSE_PROJECT_MODAL'
-
-export function openNewProjectModal() {
- return {
- type: OPEN_NEW_PROJECT_MODAL,
- }
-}
-
-export function closeNewProjectModal() {
- return {
- type: CLOSE_NEW_PROJECT_MODAL,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/modals/scenarios.js b/opendc-web/opendc-web-ui/src/actions/modals/scenarios.js
deleted file mode 100644
index b71cb27b..00000000
--- a/opendc-web/opendc-web-ui/src/actions/modals/scenarios.js
+++ /dev/null
@@ -1,14 +0,0 @@
-export const OPEN_NEW_SCENARIO_MODAL = 'OPEN_NEW_SCENARIO_MODAL'
-export const CLOSE_NEW_SCENARIO_MODAL = 'CLOSE_SCENARIO_MODAL'
-
-export function openNewScenarioModal() {
- return {
- type: OPEN_NEW_SCENARIO_MODAL,
- }
-}
-
-export function closeNewScenarioModal() {
- return {
- type: CLOSE_NEW_SCENARIO_MODAL,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/modals/topology.js b/opendc-web/opendc-web-ui/src/actions/modals/topology.js
deleted file mode 100644
index b5fecac1..00000000
--- a/opendc-web/opendc-web-ui/src/actions/modals/topology.js
+++ /dev/null
@@ -1,84 +0,0 @@
-export const OPEN_NEW_TOPOLOGY_MODAL = 'OPEN_NEW_TOPOLOGY_MODAL'
-export const CLOSE_NEW_TOPOLOGY_MODAL = 'CLOSE_NEW_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'
-export const CLOSE_DELETE_ROOM_MODAL = 'CLOSE_DELETE_ROOM_MODAL'
-export const OPEN_EDIT_RACK_NAME_MODAL = 'OPEN_EDIT_RACK_NAME_MODAL'
-export const CLOSE_EDIT_RACK_NAME_MODAL = 'CLOSE_EDIT_RACK_NAME_MODAL'
-export const OPEN_DELETE_RACK_MODAL = 'OPEN_DELETE_RACK_MODAL'
-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 openNewTopologyModal() {
- return {
- type: OPEN_NEW_TOPOLOGY_MODAL,
- }
-}
-
-export function closeNewTopologyModal() {
- return {
- type: CLOSE_NEW_TOPOLOGY_MODAL,
- }
-}
-
-export function openEditRoomNameModal() {
- return {
- type: OPEN_EDIT_ROOM_NAME_MODAL,
- }
-}
-
-export function closeEditRoomNameModal() {
- return {
- type: CLOSE_EDIT_ROOM_NAME_MODAL,
- }
-}
-
-export function openDeleteRoomModal() {
- return {
- type: OPEN_DELETE_ROOM_MODAL,
- }
-}
-
-export function closeDeleteRoomModal() {
- return {
- type: CLOSE_DELETE_ROOM_MODAL,
- }
-}
-
-export function openEditRackNameModal() {
- return {
- type: OPEN_EDIT_RACK_NAME_MODAL,
- }
-}
-
-export function closeEditRackNameModal() {
- return {
- type: CLOSE_EDIT_RACK_NAME_MODAL,
- }
-}
-
-export function openDeleteRackModal() {
- return {
- type: OPEN_DELETE_RACK_MODAL,
- }
-}
-
-export function closeDeleteRackModal() {
- return {
- type: CLOSE_DELETE_RACK_MODAL,
- }
-}
-
-export function openDeleteMachineModal() {
- return {
- type: OPEN_DELETE_MACHINE_MODAL,
- }
-}
-
-export function closeDeleteMachineModal() {
- return {
- type: CLOSE_DELETE_MACHINE_MODAL,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/objects.js b/opendc-web/opendc-web-ui/src/actions/objects.js
deleted file mode 100644
index 7b648b18..00000000
--- a/opendc-web/opendc-web-ui/src/actions/objects.js
+++ /dev/null
@@ -1,41 +0,0 @@
-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 function addToStore(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,
- }
-}
-
-export function addIdToStoreObjectListProp(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,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/portfolios.js b/opendc-web/opendc-web-ui/src/actions/portfolios.js
deleted file mode 100644
index d37886d8..00000000
--- a/opendc-web/opendc-web-ui/src/actions/portfolios.js
+++ /dev/null
@@ -1,41 +0,0 @@
-export const ADD_PORTFOLIO = 'ADD_PORTFOLIO'
-export const UPDATE_PORTFOLIO = 'UPDATE_PORTFOLIO'
-export const DELETE_PORTFOLIO = 'DELETE_PORTFOLIO'
-export const OPEN_PORTFOLIO_SUCCEEDED = 'OPEN_PORTFOLIO_SUCCEEDED'
-export const SET_CURRENT_PORTFOLIO = 'SET_CURRENT_PORTFOLIO'
-
-export function addPortfolio(portfolio) {
- return {
- type: ADD_PORTFOLIO,
- portfolio,
- }
-}
-
-export function updatePortfolio(portfolio) {
- return {
- type: UPDATE_PORTFOLIO,
- portfolio,
- }
-}
-
-export function deletePortfolio(id) {
- return {
- type: DELETE_PORTFOLIO,
- id,
- }
-}
-
-export function openPortfolioSucceeded(projectId, portfolioId) {
- return {
- type: OPEN_PORTFOLIO_SUCCEEDED,
- projectId,
- portfolioId,
- }
-}
-
-export function setCurrentPortfolio(portfolioId) {
- return {
- type: SET_CURRENT_PORTFOLIO,
- portfolioId,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/prefabs.js b/opendc-web/opendc-web-ui/src/actions/prefabs.js
deleted file mode 100644
index c112feed..00000000
--- a/opendc-web/opendc-web-ui/src/actions/prefabs.js
+++ /dev/null
@@ -1,32 +0,0 @@
-export const ADD_PREFAB = 'ADD_PREFAB'
-export const DELETE_PREFAB = 'DELETE_PREFAB'
-export const DELETE_PREFAB_SUCCEEDED = 'DELETE_PREFAB_SUCCEEDED'
-export const OPEN_PREFAB_SUCCEEDED = 'OPEN_PREFAB_SUCCEEDED'
-
-export function addPrefab(name) {
- return {
- type: ADD_PREFAB,
- name,
- }
-}
-
-export function deletePrefab(id) {
- return {
- type: DELETE_PREFAB,
- id,
- }
-}
-
-export function deletePrefabSucceeded(id) {
- return {
- type: DELETE_PREFAB_SUCCEEDED,
- id,
- }
-}
-
-export function openPrefabSucceeded(id) {
- return {
- type: OPEN_PREFAB_SUCCEEDED,
- id,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/projects.js b/opendc-web/opendc-web-ui/src/actions/projects.js
deleted file mode 100644
index add0f242..00000000
--- a/opendc-web/opendc-web-ui/src/actions/projects.js
+++ /dev/null
@@ -1,52 +0,0 @@
-export const SET_AUTH_VISIBILITY_FILTER = 'SET_AUTH_VISIBILITY_FILTER'
-export const ADD_PROJECT = 'ADD_PROJECT'
-export const ADD_PROJECT_SUCCEEDED = 'ADD_PROJECT_SUCCEEDED'
-export const DELETE_PROJECT = 'DELETE_PROJECT'
-export const DELETE_PROJECT_SUCCEEDED = 'DELETE_PROJECT_SUCCEEDED'
-export const OPEN_PROJECT_SUCCEEDED = 'OPEN_PROJECT_SUCCEEDED'
-
-export function setAuthVisibilityFilter(filter) {
- return {
- type: SET_AUTH_VISIBILITY_FILTER,
- filter,
- }
-}
-
-export function addProject(name) {
- return (dispatch, getState) => {
- const { auth } = getState()
- dispatch({
- type: ADD_PROJECT,
- name,
- userId: auth.userId,
- })
- }
-}
-
-export function addProjectSucceeded(authorization) {
- return {
- type: ADD_PROJECT_SUCCEEDED,
- authorization,
- }
-}
-
-export function deleteProject(id) {
- return {
- type: DELETE_PROJECT,
- id,
- }
-}
-
-export function deleteProjectSucceeded(id) {
- return {
- type: DELETE_PROJECT_SUCCEEDED,
- id,
- }
-}
-
-export function openProjectSucceeded(id) {
- return {
- type: OPEN_PROJECT_SUCCEEDED,
- id,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/scenarios.js b/opendc-web/opendc-web-ui/src/actions/scenarios.js
deleted file mode 100644
index c8a90762..00000000
--- a/opendc-web/opendc-web-ui/src/actions/scenarios.js
+++ /dev/null
@@ -1,43 +0,0 @@
-export const ADD_SCENARIO = 'ADD_SCENARIO'
-export const UPDATE_SCENARIO = 'UPDATE_SCENARIO'
-export const DELETE_SCENARIO = 'DELETE_SCENARIO'
-export const OPEN_SCENARIO_SUCCEEDED = 'OPEN_SCENARIO_SUCCEEDED'
-export const SET_CURRENT_SCENARIO = 'SET_CURRENT_SCENARIO'
-
-export function addScenario(scenario) {
- return {
- type: ADD_SCENARIO,
- scenario,
- }
-}
-
-export function updateScenario(scenario) {
- return {
- type: UPDATE_SCENARIO,
- scenario,
- }
-}
-
-export function deleteScenario(id) {
- return {
- type: DELETE_SCENARIO,
- id,
- }
-}
-
-export function openScenarioSucceeded(projectId, portfolioId, scenarioId) {
- return {
- type: OPEN_SCENARIO_SUCCEEDED,
- projectId,
- portfolioId,
- scenarioId,
- }
-}
-
-export function setCurrentScenario(portfolioId, scenarioId) {
- return {
- type: SET_CURRENT_SCENARIO,
- portfolioId,
- scenarioId,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/topologies.js b/opendc-web/opendc-web-ui/src/actions/topologies.js
deleted file mode 100644
index dcce3b7d..00000000
--- a/opendc-web/opendc-web-ui/src/actions/topologies.js
+++ /dev/null
@@ -1,17 +0,0 @@
-export const ADD_TOPOLOGY = 'ADD_TOPOLOGY'
-export const DELETE_TOPOLOGY = 'DELETE_TOPOLOGY'
-
-export function addTopology(name, duplicateId) {
- return {
- type: ADD_TOPOLOGY,
- name,
- duplicateId,
- }
-}
-
-export function deleteTopology(id) {
- return {
- type: DELETE_TOPOLOGY,
- id,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/topology/building.js b/opendc-web/opendc-web-ui/src/actions/topology/building.js
deleted file mode 100644
index 72deda6f..00000000
--- a/opendc-web/opendc-web-ui/src/actions/topology/building.js
+++ /dev/null
@@ -1,105 +0,0 @@
-export const SET_CURRENT_TOPOLOGY = 'SET_CURRENT_TOPOLOGY'
-export const START_NEW_ROOM_CONSTRUCTION = 'START_NEW_ROOM_CONSTRUCTION'
-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 START_ROOM_EDIT = 'START_ROOM_EDIT'
-export const FINISH_ROOM_EDIT = 'FINISH_ROOM_EDIT'
-export const ADD_TILE = 'ADD_TILE'
-export const DELETE_TILE = 'DELETE_TILE'
-
-export function setCurrentTopology(topologyId) {
- return {
- type: SET_CURRENT_TOPOLOGY,
- topologyId,
- }
-}
-
-export function startNewRoomConstruction() {
- return {
- type: START_NEW_ROOM_CONSTRUCTION,
- }
-}
-
-export function startNewRoomConstructionSucceeded(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
- }
-
- dispatch({
- type: FINISH_NEW_ROOM_CONSTRUCTION,
- })
- }
-}
-
-export function cancelNewRoomConstruction() {
- return {
- type: CANCEL_NEW_ROOM_CONSTRUCTION,
- }
-}
-
-export function cancelNewRoomConstructionSucceeded() {
- return {
- type: CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
- }
-}
-
-export function startRoomEdit() {
- return (dispatch, getState) => {
- const { interactionLevel } = getState()
- dispatch({
- type: START_ROOM_EDIT,
- roomId: interactionLevel.roomId,
- })
- }
-}
-
-export function finishRoomEdit() {
- return {
- type: FINISH_ROOM_EDIT,
- }
-}
-
-export function toggleTileAtLocation(positionX, positionY) {
- 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))
- }
-}
-
-export function addTile(positionX, positionY) {
- return {
- type: ADD_TILE,
- positionX,
- positionY,
- }
-}
-
-export function deleteTile(tileId) {
- return {
- type: DELETE_TILE,
- tileId,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/topology/machine.js b/opendc-web/opendc-web-ui/src/actions/topology/machine.js
deleted file mode 100644
index 17ccce5d..00000000
--- a/opendc-web/opendc-web-ui/src/actions/topology/machine.js
+++ /dev/null
@@ -1,25 +0,0 @@
-export const DELETE_MACHINE = 'DELETE_MACHINE'
-export const ADD_UNIT = 'ADD_UNIT'
-export const DELETE_UNIT = 'DELETE_UNIT'
-
-export function deleteMachine() {
- return {
- type: DELETE_MACHINE,
- }
-}
-
-export function addUnit(unitType, id) {
- return {
- type: ADD_UNIT,
- unitType,
- id,
- }
-}
-
-export function deleteUnit(unitType, index) {
- return {
- type: DELETE_UNIT,
- unitType,
- index,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/topology/rack.js b/opendc-web/opendc-web-ui/src/actions/topology/rack.js
deleted file mode 100644
index b117402e..00000000
--- a/opendc-web/opendc-web-ui/src/actions/topology/rack.js
+++ /dev/null
@@ -1,23 +0,0 @@
-export const EDIT_RACK_NAME = 'EDIT_RACK_NAME'
-export const DELETE_RACK = 'DELETE_RACK'
-export const ADD_MACHINE = 'ADD_MACHINE'
-
-export function editRackName(name) {
- return {
- type: EDIT_RACK_NAME,
- name,
- }
-}
-
-export function deleteRack() {
- return {
- type: DELETE_RACK,
- }
-}
-
-export function addMachine(position) {
- return {
- type: ADD_MACHINE,
- position,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/topology/room.js b/opendc-web/opendc-web-ui/src/actions/topology/room.js
deleted file mode 100644
index 52cba680..00000000
--- a/opendc-web/opendc-web-ui/src/actions/topology/room.js
+++ /dev/null
@@ -1,48 +0,0 @@
-import { findTileWithPosition } from '../../util/tile-calculations'
-
-export const EDIT_ROOM_NAME = 'EDIT_ROOM_NAME'
-export const DELETE_ROOM = 'DELETE_ROOM'
-export const START_RACK_CONSTRUCTION = 'START_RACK_CONSTRUCTION'
-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,
- }
-}
-
-export function startRackConstruction() {
- return {
- type: START_RACK_CONSTRUCTION,
- }
-}
-
-export function stopRackConstruction() {
- 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)
-
- if (tile !== null) {
- dispatch({
- type: ADD_RACK_TO_TILE,
- tileId: tile._id,
- })
- }
- }
-}
-
-export function deleteRoom() {
- return {
- type: DELETE_ROOM,
- }
-}
diff --git a/opendc-web/opendc-web-ui/src/actions/users.js b/opendc-web/opendc-web-ui/src/actions/users.js
deleted file mode 100644
index 4868ac34..00000000
--- a/opendc-web/opendc-web-ui/src/actions/users.js
+++ /dev/null
@@ -1,37 +0,0 @@
-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,
- })
- }
-}
-
-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,
- })
- }
-}
-
-export function deleteCurrentUserSucceeded() {
- return {
- type: DELETE_CURRENT_USER_SUCCEEDED,
- }
-}