summaryrefslogtreecommitdiff
path: root/frontend/src/sagas/objects.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-01 13:33:31 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:47:17 +0200
commitde8f12d74faef5fa3f9e38d1340948cab2d06ea3 (patch)
tree678bf1af3e5fa2334f0df43388d45294785bbf1e /frontend/src/sagas/objects.js
parent44236756c4cf689806dc17c6950a2cff3e9227bf (diff)
Manually generate IDs
Diffstat (limited to 'frontend/src/sagas/objects.js')
-rw-r--r--frontend/src/sagas/objects.js170
1 files changed, 85 insertions, 85 deletions
diff --git a/frontend/src/sagas/objects.js b/frontend/src/sagas/objects.js
index 3cfd43a6..faa75be2 100644
--- a/frontend/src/sagas/objects.js
+++ b/frontend/src/sagas/objects.js
@@ -1,140 +1,140 @@
-import { call, put, select } from "redux-saga/effects";
-import { addToStore } from "../actions/objects";
-import { getDatacenter, getRoomsOfDatacenter } from "../api/routes/datacenters";
-import { getPath, getSectionsOfPath } from "../api/routes/paths";
-import { getTilesOfRoom } from "../api/routes/rooms";
-import { getAllSchedulers } from "../api/routes/schedulers";
-import { getSection } from "../api/routes/sections";
-import { getPathsOfSimulation, getSimulation } from "../api/routes/simulations";
+import { call, put, select } from 'redux-saga/effects'
+import { addToStore } from '../actions/objects'
+import { getDatacenter, getRoomsOfDatacenter } from '../api/routes/datacenters'
+import { getPath, getSectionsOfPath } from '../api/routes/paths'
+import { getTilesOfRoom } from '../api/routes/rooms'
+import { getAllSchedulers } from '../api/routes/schedulers'
+import { getSection } from '../api/routes/sections'
+import { getPathsOfSimulation, getSimulation } from '../api/routes/simulations'
import {
- getAllCPUs,
- getAllGPUs,
- getAllMemories,
- getAllStorages,
- getCoolingItem,
- getCPU,
- getFailureModel,
- getGPU,
- getMemory,
- getPSU,
- getStorage
-} from "../api/routes/specifications";
-import { getMachinesOfRackByTile, getRackByTile } from "../api/routes/tiles";
-import { getAllTraces } from "../api/routes/traces";
-import { getUser } from "../api/routes/users";
+ getAllCPUs,
+ getAllGPUs,
+ getAllMemories,
+ getAllStorages,
+ getCoolingItem,
+ getCPU,
+ getFailureModel,
+ getGPU,
+ getMemory,
+ getPSU,
+ getStorage,
+} from '../api/routes/specifications'
+import { getMachinesOfRackByTile, getRackByTile } from '../api/routes/tiles'
+import { getAllTraces } from '../api/routes/traces'
+import { getUser } from '../api/routes/users'
export const OBJECT_SELECTORS = {
- simulation: state => state.objects.simulation,
- user: state => state.objects.user,
- authorization: state => state.objects.authorization,
- failureModel: state => state.objects.failureModel,
- cpu: state => state.objects.cpu,
- gpu: state => state.objects.gpu,
- memory: state => state.objects.memory,
- storage: state => state.objects.storage,
- machine: state => state.objects.machine,
- rack: state => state.objects.rack,
- coolingItem: state => state.objects.coolingItem,
- psu: state => state.objects.psu,
- tile: state => state.objects.tile,
- room: state => state.objects.room,
- datacenter: state => state.objects.datacenter,
- section: state => state.objects.section,
- path: state => state.objects.path
-};
+ simulation: state => state.objects.simulation,
+ user: state => state.objects.user,
+ authorization: state => state.objects.authorization,
+ failureModel: state => state.objects.failureModel,
+ cpu: state => state.objects.cpu,
+ gpu: state => state.objects.gpu,
+ memory: state => state.objects.memory,
+ storage: state => state.objects.storage,
+ machine: state => state.objects.machine,
+ rack: state => state.objects.rack,
+ coolingItem: state => state.objects.coolingItem,
+ psu: state => state.objects.psu,
+ tile: state => state.objects.tile,
+ room: state => state.objects.room,
+ datacenter: state => state.objects.datacenter,
+ section: state => state.objects.section,
+ path: state => state.objects.path,
+}
function* fetchAndStoreObject(objectType, id, apiCall) {
- const objectStore = yield select(OBJECT_SELECTORS[objectType]);
- let object = objectStore[id];
- if (!object) {
- object = yield apiCall;
- yield put(addToStore(objectType, object));
- }
- return object;
+ const objectStore = yield select(OBJECT_SELECTORS[objectType])
+ let object = objectStore[id]
+ if (!object) {
+ object = yield apiCall
+ yield put(addToStore(objectType, object))
+ }
+ return object
}
function* fetchAndStoreObjects(objectType, apiCall) {
- const objects = yield apiCall;
- for (let index in objects) {
- yield put(addToStore(objectType, objects[index]));
- }
- return objects;
+ const objects = yield apiCall
+ for (let index in objects) {
+ yield put(addToStore(objectType, objects[index]))
+ }
+ return objects
}
export const fetchAndStoreSimulation = id =>
- fetchAndStoreObject("simulation", id, call(getSimulation, id));
+ fetchAndStoreObject('simulation', id, call(getSimulation, id))
export const fetchAndStoreUser = id =>
- fetchAndStoreObject("user", id, call(getUser, id));
+ fetchAndStoreObject('user', id, call(getUser, id))
export const fetchAndStoreFailureModel = id =>
- fetchAndStoreObject("failureModel", id, call(getFailureModel, id));
+ fetchAndStoreObject('failureModel', id, call(getFailureModel, id))
export const fetchAndStoreAllCPUs = () =>
- fetchAndStoreObjects("cpu", call(getAllCPUs));
+ fetchAndStoreObjects('cpu', call(getAllCPUs))
export const fetchAndStoreCPU = id =>
- fetchAndStoreObject("cpu", id, call(getCPU, id));
+ fetchAndStoreObject('cpu', id, call(getCPU, id))
export const fetchAndStoreAllGPUs = () =>
- fetchAndStoreObjects("gpu", call(getAllGPUs));
+ fetchAndStoreObjects('gpu', call(getAllGPUs))
export const fetchAndStoreGPU = id =>
- fetchAndStoreObject("gpu", id, call(getGPU, id));
+ fetchAndStoreObject('gpu', id, call(getGPU, id))
export const fetchAndStoreAllMemories = () =>
- fetchAndStoreObjects("memory", call(getAllMemories));
+ fetchAndStoreObjects('memory', call(getAllMemories))
export const fetchAndStoreMemory = id =>
- fetchAndStoreObject("memory", id, call(getMemory, id));
+ fetchAndStoreObject('memory', id, call(getMemory, id))
export const fetchAndStoreAllStorages = () =>
- fetchAndStoreObjects("storage", call(getAllStorages));
+ fetchAndStoreObjects('storage', call(getAllStorages))
export const fetchAndStoreStorage = id =>
- fetchAndStoreObject("storage", id, call(getStorage, id));
+ fetchAndStoreObject('storage', id, call(getStorage, id))
export const fetchAndStoreMachinesOfTile = tileId =>
- fetchAndStoreObjects("machine", call(getMachinesOfRackByTile, tileId));
+ fetchAndStoreObjects('machine', call(getMachinesOfRackByTile, tileId))
export const fetchAndStoreRackOnTile = (id, tileId) =>
- fetchAndStoreObject("rack", id, call(getRackByTile, tileId));
+ fetchAndStoreObject('rack', id, call(getRackByTile, tileId))
export const fetchAndStoreCoolingItem = id =>
- fetchAndStoreObject("coolingItem", id, call(getCoolingItem, id));
+ fetchAndStoreObject('coolingItem', id, call(getCoolingItem, id))
export const fetchAndStorePSU = id =>
- fetchAndStoreObject("psu", id, call(getPSU, id));
+ fetchAndStoreObject('psu', id, call(getPSU, id))
export const fetchAndStoreTilesOfRoom = roomId =>
- fetchAndStoreObjects("tile", call(getTilesOfRoom, roomId));
+ fetchAndStoreObjects('tile', call(getTilesOfRoom, roomId))
export const fetchAndStoreRoomsOfDatacenter = datacenterId =>
- fetchAndStoreObjects("room", call(getRoomsOfDatacenter, datacenterId));
+ fetchAndStoreObjects('room', call(getRoomsOfDatacenter, datacenterId))
export const fetchAndStoreDatacenter = id =>
- fetchAndStoreObject("datacenter", id, call(getDatacenter, id));
+ fetchAndStoreObject('datacenter', id, call(getDatacenter, id))
export const fetchAndStoreSection = id =>
- fetchAndStoreObject("section", id, call(getSection, id));
+ fetchAndStoreObject('section', id, call(getSection, id))
export const fetchAndStoreSectionsOfPath = pathId =>
- fetchAndStoreObjects("section", call(getSectionsOfPath, pathId));
+ fetchAndStoreObjects('section', call(getSectionsOfPath, pathId))
export const fetchAndStorePath = id =>
- fetchAndStoreObject("path", id, call(getPath, id));
+ fetchAndStoreObject('path', id, call(getPath, id))
export const fetchAndStorePathsOfSimulation = simulationId =>
- fetchAndStoreObjects("path", call(getPathsOfSimulation, simulationId));
+ fetchAndStoreObjects('path', call(getPathsOfSimulation, simulationId))
export const fetchAndStoreAllTraces = () =>
- fetchAndStoreObjects("trace", call(getAllTraces));
-
-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;
-};
+ fetchAndStoreObjects('trace', call(getAllTraces))
+
+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
+}