summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-28 22:48:38 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-28 22:48:38 +0200
commitbcf119f2c4ac587cc8263db8a9fc0581521fdec7 (patch)
treec7c78a13d575b8345d729bb5aa44022d7f0715d4
parentf29305d4c966af83a0a842f78dcb7adb7128b37c (diff)
Implement batch state adding
Also fixes the 'hidden states' bug.
-rw-r--r--src/actions/states.js9
-rw-r--r--src/components/app/map/groups/RackGroup.js2
-rw-r--r--src/components/app/map/groups/TileGroup.js2
-rw-r--r--src/components/app/sidebars/topology/rack/MachineComponent.js2
-rw-r--r--src/components/app/timeline/Timeline.sass2
-rw-r--r--src/reducers/states.js22
-rw-r--r--src/sagas/experiments.js16
-rw-r--r--src/util/simulation-load.js2
8 files changed, 28 insertions, 29 deletions
diff --git a/src/actions/states.js b/src/actions/states.js
index 6887a1b3..29baa326 100644
--- a/src/actions/states.js
+++ b/src/actions/states.js
@@ -1,10 +1,9 @@
-export const ADD_TO_STATES = "ADD_TO_STATES";
+export const ADD_BATCH_TO_STATES = "ADD_BATCH_TO_STATES";
-export function addToStates(objectType, tick, object) {
+export function addBatchToStates(objectType, objects) {
return {
- type: ADD_TO_STATES,
+ type: ADD_BATCH_TO_STATES,
objectType,
- tick,
- object
+ objects
};
}
diff --git a/src/components/app/map/groups/RackGroup.js b/src/components/app/map/groups/RackGroup.js
index 233d0c20..b31575a6 100644
--- a/src/components/app/map/groups/RackGroup.js
+++ b/src/components/app/map/groups/RackGroup.js
@@ -9,7 +9,7 @@ import TileObject from "../elements/TileObject";
const RackGroup = ({tile, inSimulation, rackLoad}) => {
let color = RACK_BACKGROUND_COLOR;
- if (inSimulation && rackLoad) {
+ if (inSimulation && rackLoad >= 0) {
color = convertLoadToSimulationColor(rackLoad);
}
diff --git a/src/components/app/map/groups/TileGroup.js b/src/components/app/map/groups/TileGroup.js
index c41e78a4..0cd4ea59 100644
--- a/src/components/app/map/groups/TileGroup.js
+++ b/src/components/app/map/groups/TileGroup.js
@@ -20,7 +20,7 @@ const TileGroup = ({tile, newTile, inSimulation, roomLoad, onClick}) => {
let color = ROOM_DEFAULT_COLOR;
if (newTile) {
color = ROOM_IN_CONSTRUCTION_COLOR;
- } else if (inSimulation && roomLoad) {
+ } else if (inSimulation && roomLoad >= 0) {
color = convertLoadToSimulationColor(roomLoad);
}
diff --git a/src/components/app/sidebars/topology/rack/MachineComponent.js b/src/components/app/sidebars/topology/rack/MachineComponent.js
index 545bb916..0ba4503d 100644
--- a/src/components/app/sidebars/topology/rack/MachineComponent.js
+++ b/src/components/app/sidebars/topology/rack/MachineComponent.js
@@ -15,7 +15,7 @@ const UnitIcon = ({id, type}) => (
const MachineComponent = ({position, machine, inSimulation, machineLoad, onClick}) => {
let color = "white";
- if (inSimulation && machineLoad) {
+ if (inSimulation && machineLoad >= 0) {
color = convertLoadToSimulationColor(machineLoad);
}
const hasNoUnits = machine.cpuIds.length + machine.gpuIds.length + machine.memoryIds.length
diff --git a/src/components/app/timeline/Timeline.sass b/src/components/app/timeline/Timeline.sass
index 5003e80d..a5485bfd 100644
--- a/src/components/app/timeline/Timeline.sass
+++ b/src/components/app/timeline/Timeline.sass
@@ -110,3 +110,5 @@ $timeline-border: $border-width solid $gray-semi-dark
background: #222222
z-index: 504
+
+ pointer-events: none
diff --git a/src/reducers/states.js b/src/reducers/states.js
index d74c924c..81f078af 100644
--- a/src/reducers/states.js
+++ b/src/reducers/states.js
@@ -1,5 +1,5 @@
import {combineReducers} from "redux";
-import {ADD_TO_STATES} from "../actions/states";
+import {ADD_BATCH_TO_STATES} from "../actions/states";
export const states = combineReducers({
task: objectStates("task"),
@@ -14,17 +14,21 @@ function objectStates(type) {
return state;
}
- if (action.type === ADD_TO_STATES) {
+ 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,
- {
- [action.tick]: Object.assign(
- {},
- state[action.tick],
- {[action.object[action.objectType + "Id"]]: action.object}
- )
- }
+ batch
);
}
diff --git a/src/sagas/experiments.js b/src/sagas/experiments.js
index 84a748da..f21bb336 100644
--- a/src/sagas/experiments.js
+++ b/src/sagas/experiments.js
@@ -2,7 +2,7 @@ import {delay} from "redux-saga";
import {call, put, select} from "redux-saga/effects";
import {addPropToStoreObject, addToStore} from "../actions/objects";
import {setLastSimulatedTick} from "../actions/simulation/tick";
-import {addToStates} from "../actions/states";
+import {addBatchToStates} from "../actions/states";
import {
deleteExperiment,
getAllMachineStates,
@@ -48,10 +48,10 @@ function* startStateFetchLoop(experimentId) {
const rackStates = yield call(getAllRackStates, experimentId);
const roomStates = yield call(getAllRoomStates, experimentId);
- yield addAllStates("task", taskStates);
- yield addAllStates("machine", machineStates);
- yield addAllStates("rack", rackStates);
- yield addAllStates("room", roomStates);
+ yield put(addBatchToStates("task", taskStates));
+ yield put(addBatchToStates("machine", machineStates));
+ yield put(addBatchToStates("rack", rackStates));
+ yield put(addBatchToStates("room", roomStates));
yield delay(5000);
} else {
@@ -63,12 +63,6 @@ function* startStateFetchLoop(experimentId) {
}
}
-function* addAllStates(objectType, states) {
- for (let i in states) {
- yield put(addToStates(objectType, states[i].tick, states[i]));
- }
-}
-
export function* onFetchExperimentsOfSimulation() {
try {
const currentSimulationId = yield select(state => state.currentSimulationId);
diff --git a/src/util/simulation-load.js b/src/util/simulation-load.js
index c81bb406..4b6233be 100644
--- a/src/util/simulation-load.js
+++ b/src/util/simulation-load.js
@@ -27,6 +27,6 @@ export function getStateLoad(loadMetric, state) {
case "MEMORY":
return state.inUseMemoryMb / 10000.0;
default:
- return 0;
+ return -1;
}
}