summaryrefslogtreecommitdiff
path: root/src/sagas
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-15 12:53:26 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:06:03 +0200
commita1d95b3685cffb6a9344d0d1e5505dd391193f16 (patch)
tree42851ec0726881dd9f82a3ea12a7987324a68ef8 /src/sagas
parentf604406453f95c82c3e5e4294a51245661868bbe (diff)
Implement experiment list and add
Diffstat (limited to 'src/sagas')
-rw-r--r--src/sagas/experiments.js32
-rw-r--r--src/sagas/index.js6
-rw-r--r--src/sagas/objects.js18
-rw-r--r--src/sagas/profile.js2
-rw-r--r--src/sagas/simulations.js15
-rw-r--r--src/sagas/topology.js32
-rw-r--r--src/sagas/users.js4
7 files changed, 56 insertions, 53 deletions
diff --git a/src/sagas/experiments.js b/src/sagas/experiments.js
index 0ac919f4..2c5395e8 100644
--- a/src/sagas/experiments.js
+++ b/src/sagas/experiments.js
@@ -2,13 +2,7 @@ import {call, put, select} from "redux-saga/effects";
import {addPropToStoreObject, addToStore} from "../actions/objects";
import {deleteExperiment} from "../api/routes/experiments";
import {addExperiment, getExperimentsOfSimulation} from "../api/routes/simulations";
-import {
- fetchAndStoreAllJobs,
- fetchAndStoreAllSchedulers,
- fetchAndStoreAllTasks,
- fetchAndStoreAllTraces,
- fetchAndStorePathsOfSimulation
-} from "./objects";
+import {fetchAndStoreAllSchedulers, fetchAndStoreAllTraces, fetchAndStorePathsOfSimulation} from "./objects";
export function* onFetchExperimentsOfSimulation() {
try {
@@ -22,21 +16,18 @@ export function* onFetchExperimentsOfSimulation() {
yield put(addPropToStoreObject("simulation", currentSimulationId,
{experimentIds: experiments.map(experiment => experiment.id)}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
function* fetchExperimentSpecifications() {
try {
const currentSimulationId = yield select(state => state.currentSimulationId);
-
yield fetchAndStorePathsOfSimulation(currentSimulationId);
- yield fetchAndStoreAllTasks();
- yield fetchAndStoreAllJobs();
yield fetchAndStoreAllTraces();
yield fetchAndStoreAllSchedulers();
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -44,17 +35,20 @@ export function* onAddExperiment(action) {
try {
const currentSimulationId = yield select(state => state.currentSimulationId);
- const experiment = yield call(addExperiment, currentSimulationId, Object.assign({}, action.experiment, {
- id: -1,
- simulationId: currentSimulationId
- }));
+ const experiment = yield call(addExperiment,
+ currentSimulationId,
+ Object.assign({}, action.experiment, {
+ id: -1,
+ simulationId: currentSimulationId
+ })
+ );
yield put(addToStore("experiment", experiment));
- const experimentIds = yield select(state => state.objects.simulation[currentSimulationId]);
+ const experimentIds = (yield select(state => state.objects.simulation[currentSimulationId])).experimentIds;
yield put(addPropToStoreObject("simulation", currentSimulationId,
{experimentIds: experimentIds.concat([experiment.id])}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -68,6 +62,6 @@ export function* onDeleteExperiment(action) {
yield put(addPropToStoreObject("simulation", currentSimulationId,
{experimentIds: experimentIds.filter(id => id !== action.id)}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
diff --git a/src/sagas/index.js b/src/sagas/index.js
index e86ef8a1..30ca2f89 100644
--- a/src/sagas/index.js
+++ b/src/sagas/index.js
@@ -1,7 +1,7 @@
import {takeEvery} from "redux-saga/effects";
import {LOG_IN} from "../actions/auth";
import {ADD_EXPERIMENT, DELETE_EXPERIMENT, FETCH_EXPERIMENTS_OF_SIMULATION} from "../actions/experiments";
-import {ADD_SIMULATION, DELETE_SIMULATION} from "../actions/simulations";
+import {ADD_SIMULATION, DELETE_SIMULATION, OPEN_SIMULATION_SUCCEEDED} from "../actions/simulations";
import {
ADD_TILE,
CANCEL_NEW_ROOM_CONSTRUCTION,
@@ -15,7 +15,7 @@ import {ADD_RACK_TO_TILE, DELETE_ROOM, EDIT_ROOM_NAME} from "../actions/topology
import {DELETE_CURRENT_USER, FETCH_AUTHORIZATIONS_OF_CURRENT_USER} from "../actions/users";
import {onAddExperiment, onDeleteExperiment, onFetchExperimentsOfSimulation} from "./experiments";
import {onDeleteCurrentUser} from "./profile";
-import {onSimulationAdd, onSimulationDelete} from "./simulations";
+import {onOpenSimulationSucceeded, onSimulationAdd, onSimulationDelete} from "./simulations";
import {
onAddMachine,
onAddRackToTile,
@@ -43,6 +43,8 @@ export default function* rootSaga() {
yield takeEvery(DELETE_CURRENT_USER, onDeleteCurrentUser);
+ yield takeEvery(OPEN_SIMULATION_SUCCEEDED, onOpenSimulationSucceeded);
+
yield takeEvery(FETCH_LATEST_DATACENTER, onFetchLatestDatacenter);
yield takeEvery(START_NEW_ROOM_CONSTRUCTION, onStartNewRoomConstruction);
yield takeEvery(CANCEL_NEW_ROOM_CONSTRUCTION, onCancelNewRoomConstruction);
diff --git a/src/sagas/objects.js b/src/sagas/objects.js
index 375781be..0a0154cc 100644
--- a/src/sagas/objects.js
+++ b/src/sagas/objects.js
@@ -1,7 +1,6 @@
import {call, put, select} from "redux-saga/effects";
import {addToStore} from "../actions/objects";
import {getDatacenter, getRoomsOfDatacenter} from "../api/routes/datacenters";
-import {getAllJobs} from "../api/routes/jobs";
import {getPath, getSectionsOfPath} from "../api/routes/paths";
import {getTilesOfRoom} from "../api/routes/rooms";
import {getAllSchedulers} from "../api/routes/schedulers";
@@ -20,7 +19,6 @@ import {
getPSU,
getStorage
} from "../api/routes/specifications";
-import {getAllTasks} from "../api/routes/tasks";
import {getMachinesOfRackByTile, getRackByTile} from "../api/routes/tiles";
import {getAllTraces} from "../api/routes/traces";
import {getUser} from "../api/routes/users";
@@ -132,11 +130,11 @@ export const fetchAndStorePathsOfSimulation = (simulationId) =>
export const fetchAndStoreAllTraces = () =>
fetchAndStoreObjects("trace", call(getAllTraces));
-export const fetchAndStoreAllJobs = () =>
- fetchAndStoreObjects("job", call(getAllJobs));
-
-export const fetchAndStoreAllTasks = () =>
- fetchAndStoreObjects("task", call(getAllTasks));
-
-export const fetchAndStoreAllSchedulers = () =>
- fetchAndStoreObjects("scheduler", call(getAllSchedulers));
+export const fetchAndStoreAllSchedulers = function* () {
+ const objects = yield call(getAllSchedulers);
+ for (let index in objects) {
+ objects[index].id = objects[index].name;
+ yield put(addToStore("scheduler", objects[index]));
+ }
+ return objects;
+};
diff --git a/src/sagas/profile.js b/src/sagas/profile.js
index 6a72e7c2..5eacbc73 100644
--- a/src/sagas/profile.js
+++ b/src/sagas/profile.js
@@ -7,6 +7,6 @@ export function* onDeleteCurrentUser(action) {
yield call(deleteUser, action.userId);
yield put(deleteCurrentUserSucceeded());
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
diff --git a/src/sagas/simulations.js b/src/sagas/simulations.js
index b699002e..57eb6bad 100644
--- a/src/sagas/simulations.js
+++ b/src/sagas/simulations.js
@@ -1,7 +1,16 @@
import {call, put} from "redux-saga/effects";
import {addToStore} from "../actions/objects";
import {addSimulationSucceeded, deleteSimulationSucceeded} from "../actions/simulations";
-import {addSimulation, deleteSimulation} from "../api/routes/simulations";
+import {addSimulation, deleteSimulation, getSimulation} from "../api/routes/simulations";
+
+export function* onOpenSimulationSucceeded(action) {
+ try {
+ const simulation = yield call(getSimulation, action.id);
+ yield put(addToStore("simulation", simulation));
+ } catch (error) {
+ console.error(error);
+ }
+}
export function* onSimulationAdd(action) {
try {
@@ -16,7 +25,7 @@ export function* onSimulationAdd(action) {
yield put(addToStore("authorization", authorization));
yield put(addSimulationSucceeded([authorization.userId, authorization.simulationId]));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -25,6 +34,6 @@ export function* onSimulationDelete(action) {
yield call(deleteSimulation, action.id);
yield put(deleteSimulationSucceeded(action.id));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
diff --git a/src/sagas/topology.js b/src/sagas/topology.js
index d1e42d70..763d4569 100644
--- a/src/sagas/topology.js
+++ b/src/sagas/topology.js
@@ -57,7 +57,7 @@ export function* onFetchLatestDatacenter(action) {
yield fetchDatacenter(latestSection.datacenterId);
yield put(fetchLatestDatacenterSucceeded(latestSection.datacenterId));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -71,7 +71,7 @@ function* fetchDatacenter(datacenterId) {
yield fetchRoom(rooms[index].id);
}
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -82,7 +82,7 @@ function* fetchAllUnitSpecifications() {
yield fetchAndStoreAllMemories();
yield fetchAndStoreAllStorages();
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -155,7 +155,7 @@ export function* onStartNewRoomConstruction() {
yield put(addIdToStoreObjectListProp("datacenter", datacenterId, "roomIds", room.id));
yield put(startNewRoomConstructionSucceeded(room.id));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -167,7 +167,7 @@ export function* onCancelNewRoomConstruction() {
yield put(removeIdFromStoreObjectListProp("datacenter", datacenterId, "roomIds", roomId));
yield put(cancelNewRoomConstructionSucceeded());
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -182,7 +182,7 @@ export function* onAddTile(action) {
yield put(addToStore("tile", tile));
yield put(addIdToStoreObjectListProp("room", roomId, "tileIds", tile.id));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -192,7 +192,7 @@ export function* onDeleteTile(action) {
yield call(deleteTile, action.tileId);
yield put(removeIdFromStoreObjectListProp("room", roomId, "tileIds", action.tileId));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -204,7 +204,7 @@ export function* onEditRoomName(action) {
yield call(updateRoom, room);
yield put(addPropToStoreObject("room", roomId, {name: action.name}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -216,7 +216,7 @@ export function* onDeleteRoom() {
yield put(goDownOneInteractionLevel());
yield put(removeIdFromStoreObjectListProp("datacenter", datacenterId, "roomIds", roomId));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -229,7 +229,7 @@ export function* onEditRackName(action) {
yield call(updateRackOnTile, tileId, rack);
yield put(addPropToStoreObject("rack", rackId, {name: action.name}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -241,7 +241,7 @@ export function* onDeleteRack() {
yield put(addPropToStoreObject("tile", tileId, {objectType: undefined}));
yield put(addPropToStoreObject("tile", tileId, {objectId: undefined}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -258,7 +258,7 @@ export function* onAddRackToTile(action) {
yield put(addPropToStoreObject("tile", action.tileId, {objectId: rack.id}));
yield put(addPropToStoreObject("tile", action.tileId, {objectType: "RACK"}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -284,7 +284,7 @@ export function* onAddMachine(action) {
machineIds[machine.position - 1] = machine.id;
yield put(addPropToStoreObject("rack", rackId, {machineIds}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -299,7 +299,7 @@ export function* onDeleteMachine() {
yield put(goDownOneInteractionLevel());
yield put(addPropToStoreObject("rack", rack.id, {machineIds}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -322,7 +322,7 @@ export function* onAddUnit(action) {
yield put(addPropToStoreObject("machine", machine.id, {[action.unitType + "Ids"]: units}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -339,6 +339,6 @@ export function* onDeleteUnit(action) {
yield call(updateMachineInRackOnTile, tileId, position, updatedMachine);
yield put(addPropToStoreObject("machine", machine.id, {[action.unitType + "Ids"]: unitIds}));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
diff --git a/src/sagas/users.js b/src/sagas/users.js
index 5f9bffa1..f1ee9823 100644
--- a/src/sagas/users.js
+++ b/src/sagas/users.js
@@ -20,7 +20,7 @@ export function* onFetchLoggedInUser(action) {
yield put(logInSucceeded(Object.assign({userId}, action.payload)));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}
@@ -41,6 +41,6 @@ export function* onFetchAuthorizationsOfCurrentUser(action) {
yield put(fetchAuthorizationsOfCurrentUserSucceeded(authorizationIds));
} catch (error) {
- console.log(error);
+ console.error(error);
}
}