diff options
Diffstat (limited to 'frontend/src/api')
| -rw-r--r-- | frontend/src/api/index.js | 2 | ||||
| -rw-r--r-- | frontend/src/api/routes/datacenters.js | 26 | ||||
| -rw-r--r-- | frontend/src/api/routes/experiments.js | 27 | ||||
| -rw-r--r-- | frontend/src/api/routes/jobs.js | 5 | ||||
| -rw-r--r-- | frontend/src/api/routes/paths.js | 30 | ||||
| -rw-r--r-- | frontend/src/api/routes/room-types.js | 9 | ||||
| -rw-r--r-- | frontend/src/api/routes/rooms.js | 46 | ||||
| -rw-r--r-- | frontend/src/api/routes/sections.js | 5 | ||||
| -rw-r--r-- | frontend/src/api/routes/simulations.js | 14 | ||||
| -rw-r--r-- | frontend/src/api/routes/specifications.js | 57 | ||||
| -rw-r--r-- | frontend/src/api/routes/tiles.js | 146 | ||||
| -rw-r--r-- | frontend/src/api/routes/topologies.js | 42 | ||||
| -rw-r--r-- | frontend/src/api/routes/traces.js | 6 | ||||
| -rw-r--r-- | frontend/src/api/routes/users.js | 25 | ||||
| -rw-r--r-- | frontend/src/api/socket.js | 4 |
15 files changed, 63 insertions, 381 deletions
diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js index 6f6c924c..cefcb2c5 100644 --- a/frontend/src/api/index.js +++ b/frontend/src/api/index.js @@ -2,7 +2,7 @@ import { sendSocketRequest } from './socket' export function sendRequest(request) { return new Promise((resolve, reject) => { - sendSocketRequest(request, response => { + sendSocketRequest(request, (response) => { if (response.status.code === 200) { resolve(response.content) } else { diff --git a/frontend/src/api/routes/datacenters.js b/frontend/src/api/routes/datacenters.js deleted file mode 100644 index d041b6ae..00000000 --- a/frontend/src/api/routes/datacenters.js +++ /dev/null @@ -1,26 +0,0 @@ -import { sendRequest } from '../index' -import { getById } from './util' - -export function getDatacenter(datacenterId) { - return getById('/datacenters/{datacenterId}', { datacenterId }) -} - -export function getRoomsOfDatacenter(datacenterId) { - return getById('/datacenters/{datacenterId}/rooms', { datacenterId }) -} - -export function addRoomToDatacenter(room) { - return sendRequest({ - path: '/datacenters/{datacenterId}/rooms', - method: 'POST', - parameters: { - body: { - room, - }, - path: { - datacenterId: room.datacenterId, - }, - query: {}, - }, - }) -} diff --git a/frontend/src/api/routes/experiments.js b/frontend/src/api/routes/experiments.js index 75dab7af..ab85613c 100644 --- a/frontend/src/api/routes/experiments.js +++ b/frontend/src/api/routes/experiments.js @@ -1,4 +1,21 @@ import { deleteById, getById } from './util' +import { sendRequest } from '../index' + +export function addExperiment(simulationId, experiment) { + return sendRequest({ + path: '/simulations/{simulationId}/experiments', + method: 'POST', + parameters: { + body: { + experiment, + }, + path: { + simulationId, + }, + query: {}, + }, + }) +} export function getExperiment(experimentId) { return getById('/experiments/{experimentId}', { experimentId }) @@ -8,12 +25,6 @@ export function deleteExperiment(experimentId) { return deleteById('/experiments/{experimentId}', { experimentId }) } -export function getLastSimulatedTick(experimentId) { - return getById('/experiments/{experimentId}/last-simulated-tick', { - experimentId, - }) -} - export function getAllMachineStates(experimentId) { return getById('/experiments/{experimentId}/machine-states', { experimentId, @@ -27,7 +38,3 @@ export function getAllRackStates(experimentId) { export function getAllRoomStates(experimentId) { return getById('/experiments/{experimentId}/room-states', { experimentId }) } - -export function getAllTaskStates(experimentId) { - return getById('/experiments/{experimentId}/task-states', { experimentId }) -} diff --git a/frontend/src/api/routes/jobs.js b/frontend/src/api/routes/jobs.js deleted file mode 100644 index 205c1777..00000000 --- a/frontend/src/api/routes/jobs.js +++ /dev/null @@ -1,5 +0,0 @@ -import { getById } from './util' - -export function getTasksOfJob(jobId) { - return getById('/jobs/{jobId}/tasks', { jobId }) -} diff --git a/frontend/src/api/routes/paths.js b/frontend/src/api/routes/paths.js deleted file mode 100644 index 74811ab2..00000000 --- a/frontend/src/api/routes/paths.js +++ /dev/null @@ -1,30 +0,0 @@ -import { sendRequest } from '../index' -import { getById } from './util' - -export function getPath(pathId) { - return getById('/paths/{pathId}', { pathId }) -} - -export function getBranchesOfPath(pathId) { - return getById('/paths/{pathId}/branches', { pathId }) -} - -export function branchFromPath(pathId, section) { - return sendRequest({ - path: '/paths/{pathId}/branches', - method: 'POST', - parameters: { - body: { - section, - }, - path: { - pathId, - }, - query: {}, - }, - }) -} - -export function getSectionsOfPath(pathId) { - return getById('/paths/{pathId}/sections', { pathId }) -} diff --git a/frontend/src/api/routes/room-types.js b/frontend/src/api/routes/room-types.js deleted file mode 100644 index 6c964e93..00000000 --- a/frontend/src/api/routes/room-types.js +++ /dev/null @@ -1,9 +0,0 @@ -import { getAll, getById } from './util' - -export function getAvailableRoomTypes() { - return getAll('/room-types') -} - -export function getAllowedObjectsOfRoomType(name) { - return getById('/room-types/{name}/allowed-objects', { name }) -} diff --git a/frontend/src/api/routes/rooms.js b/frontend/src/api/routes/rooms.js deleted file mode 100644 index f87d1298..00000000 --- a/frontend/src/api/routes/rooms.js +++ /dev/null @@ -1,46 +0,0 @@ -import { sendRequest } from '../index' -import { deleteById, getById } from './util' - -export function getRoom(roomId) { - return getById('/rooms/{roomId}', { roomId }) -} - -export function updateRoom(room) { - return sendRequest({ - path: '/rooms/{roomId}', - method: 'PUT', - parameters: { - body: { - room, - }, - path: { - roomId: room.id, - }, - query: {}, - }, - }) -} - -export function deleteRoom(roomId) { - return deleteById('/rooms/{roomId}', { roomId }) -} - -export function getTilesOfRoom(roomId) { - return getById('/rooms/{roomId}/tiles', { roomId }) -} - -export function addTileToRoom(tile) { - return sendRequest({ - path: '/rooms/{roomId}/tiles', - method: 'POST', - parameters: { - body: { - tile, - }, - path: { - roomId: tile.roomId, - }, - query: {}, - }, - }) -} diff --git a/frontend/src/api/routes/sections.js b/frontend/src/api/routes/sections.js deleted file mode 100644 index 1ee8a22a..00000000 --- a/frontend/src/api/routes/sections.js +++ /dev/null @@ -1,5 +0,0 @@ -import { getById } from './util' - -export function getSection(sectionId) { - return getById('/sections/{sectionId}', { sectionId }) -} diff --git a/frontend/src/api/routes/simulations.js b/frontend/src/api/routes/simulations.js index aec89dcc..e22fbc07 100644 --- a/frontend/src/api/routes/simulations.js +++ b/frontend/src/api/routes/simulations.js @@ -39,20 +39,6 @@ export function deleteSimulation(simulationId) { return deleteById('/simulations/{simulationId}', { simulationId }) } -export function getAuthorizationsBySimulation(simulationId) { - return getById('/simulations/{simulationId}/authorizations', { - simulationId, - }) -} - -export function getPathsOfSimulation(simulationId) { - return getById('/simulations/{simulationId}/paths', { simulationId }) -} - -export function getExperimentsOfSimulation(simulationId) { - return getById('/simulations/{simulationId}/experiments', { simulationId }) -} - export function addExperiment(simulationId, experiment) { return sendRequest({ path: '/simulations/{simulationId}/experiments', diff --git a/frontend/src/api/routes/specifications.js b/frontend/src/api/routes/specifications.js deleted file mode 100644 index 167fdce5..00000000 --- a/frontend/src/api/routes/specifications.js +++ /dev/null @@ -1,57 +0,0 @@ -import { getAll, getById } from './util' - -export function getAllCoolingItems() { - return getAll('/specifications/cooling-items') -} - -export function getCoolingItem(id) { - return getById('/specifications/cooling-items/{id}', { id }) -} - -export function getAllCPUs() { - return getAll('/specifications/cpus') -} - -export function getCPU(id) { - return getById('/specifications/cpus/{id}', { id }) -} - -export function getAllFailureModels() { - return getAll('/specifications/failure-models') -} - -export function getFailureModel(id) { - return getById('/specifications/failure-models/{id}', { id }) -} - -export function getAllGPUs() { - return getAll('/specifications/gpus') -} - -export function getGPU(id) { - return getById('/specifications/gpus/{id}', { id }) -} - -export function getAllMemories() { - return getAll('/specifications/memories') -} - -export function getMemory(id) { - return getById('/specifications/memories/{id}', { id }) -} - -export function getAllPSUs() { - return getAll('/specifications/psus') -} - -export function getPSU(id) { - return getById('/specifications/psus/{id}', { id }) -} - -export function getAllStorages() { - return getAll('/specifications/storages') -} - -export function getStorage(id) { - return getById('/specifications/storages/{id}', { id }) -} diff --git a/frontend/src/api/routes/tiles.js b/frontend/src/api/routes/tiles.js deleted file mode 100644 index 170fe462..00000000 --- a/frontend/src/api/routes/tiles.js +++ /dev/null @@ -1,146 +0,0 @@ -import { sendRequest } from '../index' -import { deleteById, getById } from './util' - -export function getTile(tileId) { - return getById('/tiles/{tileId}', { tileId }) -} - -export function deleteTile(tileId) { - return deleteById('/tiles/{tileId}', { tileId }) -} - -export function getRackByTile(tileId) { - return getTileObject(tileId, '/rack') -} - -export function addRackToTile(tileId, rack) { - return addTileObject(tileId, { rack }, '/rack') -} - -export function updateRackOnTile(tileId, rack) { - return updateTileObject(tileId, { rack }, '/rack') -} - -export function deleteRackFromTile(tileId) { - return deleteTileObject(tileId, '/rack') -} - -export function getMachinesOfRackByTile(tileId) { - return getById('/tiles/{tileId}/rack/machines', { tileId }) -} - -export function addMachineToRackOnTile(tileId, machine) { - return sendRequest({ - path: '/tiles/{tileId}/rack/machines', - method: 'POST', - parameters: { - body: { - machine, - }, - path: { - tileId, - }, - query: {}, - }, - }) -} - -export function updateMachineInRackOnTile(tileId, position, machine) { - return sendRequest({ - path: '/tiles/{tileId}/rack/machines/{position}', - method: 'PUT', - parameters: { - body: { - machine, - }, - path: { - tileId, - position, - }, - query: {}, - }, - }) -} - -export function deleteMachineInRackOnTile(tileId, position) { - return sendRequest({ - path: '/tiles/{tileId}/rack/machines/{position}', - method: 'DELETE', - parameters: { - body: {}, - path: { - tileId, - position, - }, - query: {}, - }, - }) -} - -export function getCoolingItemByTile(tileId) { - return getTileObject(tileId, '/cooling-item') -} - -export function addCoolingItemToTile(tileId, coolingItemId) { - return addTileObject(tileId, { coolingItemId }, '/cooling-item') -} - -export function updateCoolingItemOnTile(tileId, coolingItemId) { - return updateTileObject(tileId, { coolingItemId }, '/cooling-item') -} - -export function deleteCoolingItemFromTile(tileId) { - return deleteTileObject(tileId, '/cooling-item') -} - -export function getPSUByTile(tileId) { - return getTileObject(tileId, '/psu') -} - -export function addPSUToTile(tileId, psuId) { - return addTileObject(tileId, { psuId }, '/psu') -} - -export function updatePSUOnTile(tileId, psuId) { - return updateTileObject(tileId, { psuId }, '/psu') -} - -export function deletePSUFromTile(tileId) { - return deleteTileObject(tileId, '/psu') -} - -function getTileObject(tileId, endpoint) { - return getById('/tiles/{tileId}' + endpoint, { tileId }) -} - -function addTileObject(tileId, objectBody, endpoint) { - return sendRequest({ - path: '/tiles/{tileId}' + endpoint, - method: 'POST', - parameters: { - body: objectBody, - path: { - tileId, - }, - query: {}, - }, - }) -} - -function updateTileObject(tileId, objectBody, endpoint) { - return sendRequest({ - path: '/tiles/{tileId}' + endpoint, - method: 'PUT', - parameters: { - body: objectBody, - path: { - tileId, - }, - query: {}, - }, - }) -} - -function deleteTileObject(tileId, endpoint) { - return deleteById('/tiles/{tileId}' + endpoint, { tileId }) -} diff --git a/frontend/src/api/routes/topologies.js b/frontend/src/api/routes/topologies.js new file mode 100644 index 00000000..307ea7ab --- /dev/null +++ b/frontend/src/api/routes/topologies.js @@ -0,0 +1,42 @@ +import { deleteById, getById } from './util' +import { sendRequest } from '../index' + +export function addTopology(topology) { + return sendRequest({ + path: '/simulations/{simulationId}/topologies', + method: 'POST', + parameters: { + body: { + topology, + }, + path: { + simulationId: topology.simulationId, + }, + query: {}, + }, + }) +} + +export function getTopology(topologyId) { + return getById('/topologies/{topologyId}', { topologyId }) +} + +export function updateTopology(topology) { + return sendRequest({ + path: '/topologies/{topologyId}', + method: 'PUT', + parameters: { + body: { + topology, + }, + path: { + topologyId: topology._id, + }, + query: {}, + }, + }) +} + +export function deleteTopology(topologyId) { + return deleteById('/topologies/{topologyId}', { topologyId }) +} diff --git a/frontend/src/api/routes/traces.js b/frontend/src/api/routes/traces.js index 140408b1..67895a87 100644 --- a/frontend/src/api/routes/traces.js +++ b/frontend/src/api/routes/traces.js @@ -1,9 +1,5 @@ -import { getAll, getById } from './util' +import { getAll } from './util' export function getAllTraces() { return getAll('/traces') } - -export function getJobsOfTrace(traceId) { - return getById('/traces/{traceId}/jobs', { traceId }) -} diff --git a/frontend/src/api/routes/users.js b/frontend/src/api/routes/users.js index 4cb194ce..3028f3f7 100644 --- a/frontend/src/api/routes/users.js +++ b/frontend/src/api/routes/users.js @@ -1,5 +1,5 @@ import { sendRequest } from '../index' -import { deleteById, getById } from './util' +import { deleteById } from './util' export function getUserByEmail(email) { return sendRequest({ @@ -43,29 +43,6 @@ export function getUser(userId) { }) } -export function updateUser(userId, user) { - return sendRequest({ - path: '/users/{userId}', - method: 'PUT', - parameters: { - body: { - user: { - givenName: user.givenName, - familyName: user.familyName, - }, - }, - path: { - userId, - }, - query: {}, - }, - }) -} - export function deleteUser(userId) { return deleteById('/users/{userId}', { userId }) } - -export function getAuthorizationsByUser(userId) { - return getById('/users/{userId}/authorizations', { userId }) -} diff --git a/frontend/src/api/socket.js b/frontend/src/api/socket.js index ce5f7587..93ce8fa8 100644 --- a/frontend/src/api/socket.js +++ b/frontend/src/api/socket.js @@ -10,9 +10,7 @@ export function setupSocketConnection(onConnect) { if (process.env.NODE_ENV !== 'production') { port = 8081 } - socket = io.connect( - window.location.protocol + '//' + window.location.hostname + ':' + port, - ) + socket = io.connect(window.location.protocol + '//' + window.location.hostname + ':' + port) socket.on('connect', onConnect) socket.on('response', onSocketResponse) } |
