summaryrefslogtreecommitdiff
path: root/frontend/src/reducers
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-07 09:55:10 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:47:25 +0200
commitb4bdf9fde013bb7ff9579693b64ff575f7b00e44 (patch)
tree5e05ceba918849391a639bbeeab37d290a86523c /frontend/src/reducers
parent7331e9baf2cfe7bdfb24effcf0a4801da1e7ea4d (diff)
Rename simulations to projects and remove experiment view
Diffstat (limited to 'frontend/src/reducers')
-rw-r--r--frontend/src/reducers/construction-mode.js3
-rw-r--r--frontend/src/reducers/current-ids.js8
-rw-r--r--frontend/src/reducers/index.js16
-rw-r--r--frontend/src/reducers/interaction-level.js4
-rw-r--r--frontend/src/reducers/modals.js6
-rw-r--r--frontend/src/reducers/objects.js4
-rw-r--r--frontend/src/reducers/project-list.js (renamed from frontend/src/reducers/simulation-list.js)12
-rw-r--r--frontend/src/reducers/simulation-mode.js58
-rw-r--r--frontend/src/reducers/states.js32
9 files changed, 21 insertions, 122 deletions
diff --git a/frontend/src/reducers/construction-mode.js b/frontend/src/reducers/construction-mode.js
index fb33da72..b15ac834 100644
--- a/frontend/src/reducers/construction-mode.js
+++ b/frontend/src/reducers/construction-mode.js
@@ -4,7 +4,8 @@ import { GO_DOWN_ONE_INTERACTION_LEVEL } from '../actions/interaction-level'
import {
CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
FINISH_NEW_ROOM_CONSTRUCTION,
- FINISH_ROOM_EDIT, SET_CURRENT_TOPOLOGY,
+ FINISH_ROOM_EDIT,
+ SET_CURRENT_TOPOLOGY,
START_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
START_ROOM_EDIT,
} from '../actions/topology/building'
diff --git a/frontend/src/reducers/current-ids.js b/frontend/src/reducers/current-ids.js
index b80d2ecf..0726da6d 100644
--- a/frontend/src/reducers/current-ids.js
+++ b/frontend/src/reducers/current-ids.js
@@ -1,5 +1,5 @@
import { OPEN_EXPERIMENT_SUCCEEDED } from '../actions/experiments'
-import { OPEN_SIMULATION_SUCCEEDED } from '../actions/simulations'
+import { OPEN_PROJECT_SUCCEEDED } from '../actions/projects'
import { RESET_CURRENT_TOPOLOGY, SET_CURRENT_TOPOLOGY } from '../actions/topology/building'
export function currentTopologyId(state = '-1', action) {
@@ -13,12 +13,12 @@ export function currentTopologyId(state = '-1', action) {
}
}
-export function currentSimulationId(state = '-1', action) {
+export function currentProjectId(state = '-1', action) {
switch (action.type) {
- case OPEN_SIMULATION_SUCCEEDED:
+ case OPEN_PROJECT_SUCCEEDED:
return action.id
case OPEN_EXPERIMENT_SUCCEEDED:
- return action.simulationId
+ return action.projectId
default:
return state
}
diff --git a/frontend/src/reducers/index.js b/frontend/src/reducers/index.js
index 1c3ee145..6ca95ec6 100644
--- a/frontend/src/reducers/index.js
+++ b/frontend/src/reducers/index.js
@@ -1,29 +1,21 @@
import { combineReducers } from 'redux'
import { auth } from './auth'
import { construction } from './construction-mode'
-import { currentTopologyId, currentSimulationId } from './current-ids'
+import { currentProjectId, currentTopologyId } from './current-ids'
import { interactionLevel } from './interaction-level'
import { map } from './map'
import { modals } from './modals'
import { objects } from './objects'
-import { simulationList } from './simulation-list'
-import { currentExperimentId, currentTick, isPlaying, lastSimulatedTick, loadMetric } from './simulation-mode'
-import { states } from './states'
+import { projectList } from './project-list'
const rootReducer = combineReducers({
objects,
- states,
modals,
- simulationList,
+ projectList: projectList,
construction,
map,
- currentSimulationId,
+ currentProjectId,
currentTopologyId,
- currentExperimentId,
- currentTick,
- lastSimulatedTick,
- loadMetric,
- isPlaying,
interactionLevel,
auth,
})
diff --git a/frontend/src/reducers/interaction-level.js b/frontend/src/reducers/interaction-level.js
index 88c3b30e..21aba715 100644
--- a/frontend/src/reducers/interaction-level.js
+++ b/frontend/src/reducers/interaction-level.js
@@ -5,13 +5,13 @@ import {
GO_FROM_RACK_TO_MACHINE,
GO_FROM_ROOM_TO_RACK,
} from '../actions/interaction-level'
-import { OPEN_SIMULATION_SUCCEEDED } from '../actions/simulations'
+import { OPEN_PROJECT_SUCCEEDED } from '../actions/projects'
import { SET_CURRENT_TOPOLOGY } from '../actions/topology/building'
export function interactionLevel(state = { mode: 'BUILDING' }, action) {
switch (action.type) {
case OPEN_EXPERIMENT_SUCCEEDED:
- case OPEN_SIMULATION_SUCCEEDED:
+ case OPEN_PROJECT_SUCCEEDED:
case SET_CURRENT_TOPOLOGY:
return {
mode: 'BUILDING',
diff --git a/frontend/src/reducers/modals.js b/frontend/src/reducers/modals.js
index 81a0660e..a042aaea 100644
--- a/frontend/src/reducers/modals.js
+++ b/frontend/src/reducers/modals.js
@@ -2,7 +2,7 @@ import { combineReducers } from 'redux'
import { OPEN_EXPERIMENT_SUCCEEDED } from '../actions/experiments'
import { CLOSE_NEW_EXPERIMENT_MODAL, OPEN_NEW_EXPERIMENT_MODAL } from '../actions/modals/experiments'
import { CLOSE_DELETE_PROFILE_MODAL, OPEN_DELETE_PROFILE_MODAL } from '../actions/modals/profile'
-import { CLOSE_NEW_SIMULATION_MODAL, OPEN_NEW_SIMULATION_MODAL } from '../actions/modals/simulations'
+import { CLOSE_NEW_PROJECT_MODAL, OPEN_NEW_PROJECT_MODAL } from '../actions/modals/projects'
import {
CLOSE_CHANGE_TOPOLOGY_MODAL,
CLOSE_DELETE_MACHINE_MODAL,
@@ -19,7 +19,7 @@ import {
} from '../actions/modals/topology'
function modal(openAction, closeAction) {
- return function (state = false, action) {
+ return function(state = false, action) {
switch (action.type) {
case openAction:
return true
@@ -33,7 +33,7 @@ function modal(openAction, closeAction) {
}
export const modals = combineReducers({
- newSimulationModalVisible: modal(OPEN_NEW_SIMULATION_MODAL, CLOSE_NEW_SIMULATION_MODAL),
+ newProjectModalVisible: modal(OPEN_NEW_PROJECT_MODAL, CLOSE_NEW_PROJECT_MODAL),
deleteProfileModalVisible: modal(OPEN_DELETE_PROFILE_MODAL, CLOSE_DELETE_PROFILE_MODAL),
changeTopologyModalVisible: modal(OPEN_CHANGE_TOPOLOGY_MODAL, CLOSE_CHANGE_TOPOLOGY_MODAL),
editRoomNameModalVisible: modal(OPEN_EDIT_ROOM_NAME_MODAL, CLOSE_EDIT_ROOM_NAME_MODAL),
diff --git a/frontend/src/reducers/objects.js b/frontend/src/reducers/objects.js
index f52ca369..d25eb136 100644
--- a/frontend/src/reducers/objects.js
+++ b/frontend/src/reducers/objects.js
@@ -8,9 +8,9 @@ import {
import { CPU_UNITS, GPU_UNITS, MEMORY_UNITS, STORAGE_UNITS } from '../util/unit-specifications'
export const objects = combineReducers({
- simulation: object('simulation'),
+ project: object('project'),
user: object('user'),
- authorization: objectWithId('authorization', (object) => [object.userId, object.simulationId]),
+ authorization: objectWithId('authorization', (object) => [object.userId, object.projectId]),
cpu: object('cpu', CPU_UNITS),
gpu: object('gpu', GPU_UNITS),
memory: object('memory', MEMORY_UNITS),
diff --git a/frontend/src/reducers/simulation-list.js b/frontend/src/reducers/project-list.js
index 383f4b35..1f1aa8d0 100644
--- a/frontend/src/reducers/simulation-list.js
+++ b/frontend/src/reducers/project-list.js
@@ -1,18 +1,14 @@
import { combineReducers } from 'redux'
-import {
- ADD_SIMULATION_SUCCEEDED,
- DELETE_SIMULATION_SUCCEEDED,
- SET_AUTH_VISIBILITY_FILTER,
-} from '../actions/simulations'
+import { ADD_PROJECT_SUCCEEDED, DELETE_PROJECT_SUCCEEDED, SET_AUTH_VISIBILITY_FILTER } from '../actions/projects'
import { FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED } from '../actions/users'
export function authorizationsOfCurrentUser(state = [], action) {
switch (action.type) {
case FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED:
return action.authorizationsOfCurrentUser
- case ADD_SIMULATION_SUCCEEDED:
+ case ADD_PROJECT_SUCCEEDED:
return [...state, action.authorization]
- case DELETE_SIMULATION_SUCCEEDED:
+ case DELETE_PROJECT_SUCCEEDED:
return state.filter((authorization) => authorization[1] !== action.id)
default:
return state
@@ -28,7 +24,7 @@ export function authVisibilityFilter(state = 'SHOW_ALL', action) {
}
}
-export const simulationList = combineReducers({
+export const projectList = combineReducers({
authorizationsOfCurrentUser,
authVisibilityFilter,
})
diff --git a/frontend/src/reducers/simulation-mode.js b/frontend/src/reducers/simulation-mode.js
deleted file mode 100644
index 5f938ec8..00000000
--- a/frontend/src/reducers/simulation-mode.js
+++ /dev/null
@@ -1,58 +0,0 @@
-import { OPEN_EXPERIMENT_SUCCEEDED } from '../actions/experiments'
-import { CHANGE_LOAD_METRIC } from '../actions/simulation/load-metric'
-import { SET_PLAYING } from '../actions/simulation/playback'
-import { GO_TO_TICK, SET_LAST_SIMULATED_TICK } from '../actions/simulation/tick'
-import { OPEN_SIMULATION_SUCCEEDED } from '../actions/simulations'
-
-export function currentExperimentId(state = '-1', action) {
- switch (action.type) {
- case OPEN_EXPERIMENT_SUCCEEDED:
- return action.experimentId
- case OPEN_SIMULATION_SUCCEEDED:
- return '-1'
- default:
- return state
- }
-}
-
-export function currentTick(state = 0, action) {
- switch (action.type) {
- case GO_TO_TICK:
- return action.tick
- case OPEN_EXPERIMENT_SUCCEEDED:
- return 0
- default:
- return state
- }
-}
-
-export function loadMetric(state = 'LOAD', action) {
- switch (action.type) {
- case CHANGE_LOAD_METRIC:
- return action.metric
- default:
- return state
- }
-}
-
-export function isPlaying(state = false, action) {
- switch (action.type) {
- case SET_PLAYING:
- return action.playing
- case OPEN_EXPERIMENT_SUCCEEDED:
- return false
- default:
- return state
- }
-}
-
-export function lastSimulatedTick(state = -1, action) {
- switch (action.type) {
- case SET_LAST_SIMULATED_TICK:
- return action.tick
- case OPEN_EXPERIMENT_SUCCEEDED:
- return -1
- default:
- return state
- }
-}
diff --git a/frontend/src/reducers/states.js b/frontend/src/reducers/states.js
deleted file mode 100644
index c9bb4158..00000000
--- a/frontend/src/reducers/states.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import { combineReducers } from 'redux'
-import { ADD_BATCH_TO_STATES } from '../actions/states'
-
-export const states = combineReducers({
- room: objectStates('room'),
- rack: objectStates('rack'),
- machine: objectStates('machine'),
-})
-
-function objectStates(type) {
- return (state = {}, action) => {
- if (action.objectType !== type) {
- return state
- }
-
- if (action.type === ADD_BATCH_TO_STATES) {
- const batch = {}
- for (let i in action.objects) {
- batch[action.objects[i].tick] = Object.assign(
- {},
- state[action.objects[i].tick],
- batch[action.objects[i].tick],
- { [action.objects[i][action.objectType + 'Id']]: action.objects[i] }
- )
- }
-
- return Object.assign({}, state, batch)
- }
-
- return state
- }
-}