summaryrefslogtreecommitdiff
path: root/frontend/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/api')
-rw-r--r--frontend/src/api/index.js20
-rw-r--r--frontend/src/api/routes/datacenters.js34
-rw-r--r--frontend/src/api/routes/experiments.js24
-rw-r--r--frontend/src/api/routes/jobs.js4
-rw-r--r--frontend/src/api/routes/paths.js36
-rw-r--r--frontend/src/api/routes/room-types.js6
-rw-r--r--frontend/src/api/routes/rooms.js62
-rw-r--r--frontend/src/api/routes/schedulers.js4
-rw-r--r--frontend/src/api/routes/sections.js4
-rw-r--r--frontend/src/api/routes/simulations.js92
-rw-r--r--frontend/src/api/routes/specifications.js30
-rw-r--r--frontend/src/api/routes/tiles.js160
-rw-r--r--frontend/src/api/routes/token-signin.js10
-rw-r--r--frontend/src/api/routes/traces.js6
-rw-r--r--frontend/src/api/routes/users.js106
-rw-r--r--frontend/src/api/routes/util.js56
-rw-r--r--frontend/src/api/socket.js70
17 files changed, 362 insertions, 362 deletions
diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js
index 37c288a3..6f6c924c 100644
--- a/frontend/src/api/index.js
+++ b/frontend/src/api/index.js
@@ -1,13 +1,13 @@
-import { sendSocketRequest } from "./socket";
+import { sendSocketRequest } from './socket'
export function sendRequest(request) {
- return new Promise((resolve, reject) => {
- sendSocketRequest(request, response => {
- if (response.status.code === 200) {
- resolve(response.content);
- } else {
- reject(response);
- }
- });
- });
+ return new Promise((resolve, reject) => {
+ sendSocketRequest(request, response => {
+ if (response.status.code === 200) {
+ resolve(response.content)
+ } else {
+ reject(response)
+ }
+ })
+ })
}
diff --git a/frontend/src/api/routes/datacenters.js b/frontend/src/api/routes/datacenters.js
index 20cf4935..d041b6ae 100644
--- a/frontend/src/api/routes/datacenters.js
+++ b/frontend/src/api/routes/datacenters.js
@@ -1,26 +1,26 @@
-import { sendRequest } from "../index";
-import { getById } from "./util";
+import { sendRequest } from '../index'
+import { getById } from './util'
export function getDatacenter(datacenterId) {
- return getById("/datacenters/{datacenterId}", { datacenterId });
+ return getById('/datacenters/{datacenterId}', { datacenterId })
}
export function getRoomsOfDatacenter(datacenterId) {
- return getById("/datacenters/{datacenterId}/rooms", { 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: {}
- }
- });
+ 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 f61698c5..75dab7af 100644
--- a/frontend/src/api/routes/experiments.js
+++ b/frontend/src/api/routes/experiments.js
@@ -1,33 +1,33 @@
-import { deleteById, getById } from "./util";
+import { deleteById, getById } from './util'
export function getExperiment(experimentId) {
- return getById("/experiments/{experimentId}", { experimentId });
+ return getById('/experiments/{experimentId}', { experimentId })
}
export function deleteExperiment(experimentId) {
- return deleteById("/experiments/{experimentId}", { experimentId });
+ return deleteById('/experiments/{experimentId}', { experimentId })
}
export function getLastSimulatedTick(experimentId) {
- return getById("/experiments/{experimentId}/last-simulated-tick", {
- experimentId
- });
+ return getById('/experiments/{experimentId}/last-simulated-tick', {
+ experimentId,
+ })
}
export function getAllMachineStates(experimentId) {
- return getById("/experiments/{experimentId}/machine-states", {
- experimentId
- });
+ return getById('/experiments/{experimentId}/machine-states', {
+ experimentId,
+ })
}
export function getAllRackStates(experimentId) {
- return getById("/experiments/{experimentId}/rack-states", { experimentId });
+ return getById('/experiments/{experimentId}/rack-states', { experimentId })
}
export function getAllRoomStates(experimentId) {
- return getById("/experiments/{experimentId}/room-states", { experimentId });
+ return getById('/experiments/{experimentId}/room-states', { experimentId })
}
export function getAllTaskStates(experimentId) {
- return getById("/experiments/{experimentId}/task-states", { experimentId });
+ return getById('/experiments/{experimentId}/task-states', { experimentId })
}
diff --git a/frontend/src/api/routes/jobs.js b/frontend/src/api/routes/jobs.js
index 355acc32..205c1777 100644
--- a/frontend/src/api/routes/jobs.js
+++ b/frontend/src/api/routes/jobs.js
@@ -1,5 +1,5 @@
-import { getById } from "./util";
+import { getById } from './util'
export function getTasksOfJob(jobId) {
- return getById("/jobs/{jobId}/tasks", { jobId });
+ return getById('/jobs/{jobId}/tasks', { jobId })
}
diff --git a/frontend/src/api/routes/paths.js b/frontend/src/api/routes/paths.js
index 78ef7d6e..74811ab2 100644
--- a/frontend/src/api/routes/paths.js
+++ b/frontend/src/api/routes/paths.js
@@ -1,30 +1,30 @@
-import { sendRequest } from "../index";
-import { getById } from "./util";
+import { sendRequest } from '../index'
+import { getById } from './util'
export function getPath(pathId) {
- return getById("/paths/{pathId}", { pathId });
+ return getById('/paths/{pathId}', { pathId })
}
export function getBranchesOfPath(pathId) {
- return getById("/paths/{pathId}/branches", { 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: {}
- }
- });
+ return sendRequest({
+ path: '/paths/{pathId}/branches',
+ method: 'POST',
+ parameters: {
+ body: {
+ section,
+ },
+ path: {
+ pathId,
+ },
+ query: {},
+ },
+ })
}
export function getSectionsOfPath(pathId) {
- return getById("/paths/{pathId}/sections", { 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
index 8a3eac58..6c964e93 100644
--- a/frontend/src/api/routes/room-types.js
+++ b/frontend/src/api/routes/room-types.js
@@ -1,9 +1,9 @@
-import { getAll, getById } from "./util";
+import { getAll, getById } from './util'
export function getAvailableRoomTypes() {
- return getAll("/room-types");
+ return getAll('/room-types')
}
export function getAllowedObjectsOfRoomType(name) {
- return getById("/room-types/{name}/allowed-objects", { 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
index 56395d7f..f87d1298 100644
--- a/frontend/src/api/routes/rooms.js
+++ b/frontend/src/api/routes/rooms.js
@@ -1,46 +1,46 @@
-import { sendRequest } from "../index";
-import { deleteById, getById } from "./util";
+import { sendRequest } from '../index'
+import { deleteById, getById } from './util'
export function getRoom(roomId) {
- return getById("/rooms/{roomId}", { 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: {}
- }
- });
+ return sendRequest({
+ path: '/rooms/{roomId}',
+ method: 'PUT',
+ parameters: {
+ body: {
+ room,
+ },
+ path: {
+ roomId: room.id,
+ },
+ query: {},
+ },
+ })
}
export function deleteRoom(roomId) {
- return deleteById("/rooms/{roomId}", { roomId });
+ return deleteById('/rooms/{roomId}', { roomId })
}
export function getTilesOfRoom(roomId) {
- return getById("/rooms/{roomId}/tiles", { 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: {}
- }
- });
+ return sendRequest({
+ path: '/rooms/{roomId}/tiles',
+ method: 'POST',
+ parameters: {
+ body: {
+ tile,
+ },
+ path: {
+ roomId: tile.roomId,
+ },
+ query: {},
+ },
+ })
}
diff --git a/frontend/src/api/routes/schedulers.js b/frontend/src/api/routes/schedulers.js
index ea360967..4481fb2a 100644
--- a/frontend/src/api/routes/schedulers.js
+++ b/frontend/src/api/routes/schedulers.js
@@ -1,5 +1,5 @@
-import { getAll } from "./util";
+import { getAll } from './util'
export function getAllSchedulers() {
- return getAll("/schedulers");
+ return getAll('/schedulers')
}
diff --git a/frontend/src/api/routes/sections.js b/frontend/src/api/routes/sections.js
index 5e1a077d..1ee8a22a 100644
--- a/frontend/src/api/routes/sections.js
+++ b/frontend/src/api/routes/sections.js
@@ -1,5 +1,5 @@
-import { getById } from "./util";
+import { getById } from './util'
export function getSection(sectionId) {
- return getById("/sections/{sectionId}", { sectionId });
+ return getById('/sections/{sectionId}', { sectionId })
}
diff --git a/frontend/src/api/routes/simulations.js b/frontend/src/api/routes/simulations.js
index dcb9ac5f..aec89dcc 100644
--- a/frontend/src/api/routes/simulations.js
+++ b/frontend/src/api/routes/simulations.js
@@ -1,70 +1,70 @@
-import { sendRequest } from "../index";
-import { deleteById, getById } from "./util";
+import { sendRequest } from '../index'
+import { deleteById, getById } from './util'
export function getSimulation(simulationId) {
- return getById("/simulations/{simulationId}", { simulationId });
+ return getById('/simulations/{simulationId}', { simulationId })
}
export function addSimulation(simulation) {
- return sendRequest({
- path: "/simulations",
- method: "POST",
- parameters: {
- body: {
- simulation
- },
- path: {},
- query: {}
- }
- });
+ return sendRequest({
+ path: '/simulations',
+ method: 'POST',
+ parameters: {
+ body: {
+ simulation,
+ },
+ path: {},
+ query: {},
+ },
+ })
}
export function updateSimulation(simulation) {
- return sendRequest({
- path: "/simulations/{simulationId}",
- method: "PUT",
- parameters: {
- body: {
- simulation
- },
- path: {
- simulationId: simulation.id
- },
- query: {}
- }
- });
+ return sendRequest({
+ path: '/simulations/{simulationId}',
+ method: 'PUT',
+ parameters: {
+ body: {
+ simulation,
+ },
+ path: {
+ simulationId: simulation._id,
+ },
+ query: {},
+ },
+ })
}
export function deleteSimulation(simulationId) {
- return deleteById("/simulations/{simulationId}", { simulationId });
+ return deleteById('/simulations/{simulationId}', { simulationId })
}
export function getAuthorizationsBySimulation(simulationId) {
- return getById("/simulations/{simulationId}/authorizations", {
- simulationId
- });
+ return getById('/simulations/{simulationId}/authorizations', {
+ simulationId,
+ })
}
export function getPathsOfSimulation(simulationId) {
- return getById("/simulations/{simulationId}/paths", { simulationId });
+ return getById('/simulations/{simulationId}/paths', { simulationId })
}
export function getExperimentsOfSimulation(simulationId) {
- return getById("/simulations/{simulationId}/experiments", { simulationId });
+ return getById('/simulations/{simulationId}/experiments', { simulationId })
}
export function addExperiment(simulationId, experiment) {
- return sendRequest({
- path: "/simulations/{simulationId}/experiments",
- method: "POST",
- parameters: {
- body: {
- experiment
- },
- path: {
- simulationId
- },
- query: {}
- }
- });
+ return sendRequest({
+ path: '/simulations/{simulationId}/experiments',
+ method: 'POST',
+ parameters: {
+ body: {
+ experiment,
+ },
+ path: {
+ simulationId,
+ },
+ query: {},
+ },
+ })
}
diff --git a/frontend/src/api/routes/specifications.js b/frontend/src/api/routes/specifications.js
index 0f60b571..167fdce5 100644
--- a/frontend/src/api/routes/specifications.js
+++ b/frontend/src/api/routes/specifications.js
@@ -1,57 +1,57 @@
-import { getAll, getById } from "./util";
+import { getAll, getById } from './util'
export function getAllCoolingItems() {
- return getAll("/specifications/cooling-items");
+ return getAll('/specifications/cooling-items')
}
export function getCoolingItem(id) {
- return getById("/specifications/cooling-items/{id}", { id });
+ return getById('/specifications/cooling-items/{id}', { id })
}
export function getAllCPUs() {
- return getAll("/specifications/cpus");
+ return getAll('/specifications/cpus')
}
export function getCPU(id) {
- return getById("/specifications/cpus/{id}", { id });
+ return getById('/specifications/cpus/{id}', { id })
}
export function getAllFailureModels() {
- return getAll("/specifications/failure-models");
+ return getAll('/specifications/failure-models')
}
export function getFailureModel(id) {
- return getById("/specifications/failure-models/{id}", { id });
+ return getById('/specifications/failure-models/{id}', { id })
}
export function getAllGPUs() {
- return getAll("/specifications/gpus");
+ return getAll('/specifications/gpus')
}
export function getGPU(id) {
- return getById("/specifications/gpus/{id}", { id });
+ return getById('/specifications/gpus/{id}', { id })
}
export function getAllMemories() {
- return getAll("/specifications/memories");
+ return getAll('/specifications/memories')
}
export function getMemory(id) {
- return getById("/specifications/memories/{id}", { id });
+ return getById('/specifications/memories/{id}', { id })
}
export function getAllPSUs() {
- return getAll("/specifications/psus");
+ return getAll('/specifications/psus')
}
export function getPSU(id) {
- return getById("/specifications/psus/{id}", { id });
+ return getById('/specifications/psus/{id}', { id })
}
export function getAllStorages() {
- return getAll("/specifications/storages");
+ return getAll('/specifications/storages')
}
export function getStorage(id) {
- return getById("/specifications/storages/{id}", { id });
+ return getById('/specifications/storages/{id}', { id })
}
diff --git a/frontend/src/api/routes/tiles.js b/frontend/src/api/routes/tiles.js
index 08481ef4..170fe462 100644
--- a/frontend/src/api/routes/tiles.js
+++ b/frontend/src/api/routes/tiles.js
@@ -1,146 +1,146 @@
-import { sendRequest } from "../index";
-import { deleteById, getById } from "./util";
+import { sendRequest } from '../index'
+import { deleteById, getById } from './util'
export function getTile(tileId) {
- return getById("/tiles/{tileId}", { tileId });
+ return getById('/tiles/{tileId}', { tileId })
}
export function deleteTile(tileId) {
- return deleteById("/tiles/{tileId}", { tileId });
+ return deleteById('/tiles/{tileId}', { tileId })
}
export function getRackByTile(tileId) {
- return getTileObject(tileId, "/rack");
+ return getTileObject(tileId, '/rack')
}
export function addRackToTile(tileId, rack) {
- return addTileObject(tileId, { rack }, "/rack");
+ return addTileObject(tileId, { rack }, '/rack')
}
export function updateRackOnTile(tileId, rack) {
- return updateTileObject(tileId, { rack }, "/rack");
+ return updateTileObject(tileId, { rack }, '/rack')
}
export function deleteRackFromTile(tileId) {
- return deleteTileObject(tileId, "/rack");
+ return deleteTileObject(tileId, '/rack')
}
export function getMachinesOfRackByTile(tileId) {
- return getById("/tiles/{tileId}/rack/machines", { 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: {}
- }
- });
+ 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: {}
- }
- });
+ 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: {}
- }
- });
+ 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");
+ return getTileObject(tileId, '/cooling-item')
}
export function addCoolingItemToTile(tileId, coolingItemId) {
- return addTileObject(tileId, { coolingItemId }, "/cooling-item");
+ return addTileObject(tileId, { coolingItemId }, '/cooling-item')
}
export function updateCoolingItemOnTile(tileId, coolingItemId) {
- return updateTileObject(tileId, { coolingItemId }, "/cooling-item");
+ return updateTileObject(tileId, { coolingItemId }, '/cooling-item')
}
export function deleteCoolingItemFromTile(tileId) {
- return deleteTileObject(tileId, "/cooling-item");
+ return deleteTileObject(tileId, '/cooling-item')
}
export function getPSUByTile(tileId) {
- return getTileObject(tileId, "/psu");
+ return getTileObject(tileId, '/psu')
}
export function addPSUToTile(tileId, psuId) {
- return addTileObject(tileId, { psuId }, "/psu");
+ return addTileObject(tileId, { psuId }, '/psu')
}
export function updatePSUOnTile(tileId, psuId) {
- return updateTileObject(tileId, { psuId }, "/psu");
+ return updateTileObject(tileId, { psuId }, '/psu')
}
export function deletePSUFromTile(tileId) {
- return deleteTileObject(tileId, "/psu");
+ return deleteTileObject(tileId, '/psu')
}
function getTileObject(tileId, endpoint) {
- return getById("/tiles/{tileId}" + endpoint, { tileId });
+ 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: {}
- }
- });
+ 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: {}
- }
- });
+ return sendRequest({
+ path: '/tiles/{tileId}' + endpoint,
+ method: 'PUT',
+ parameters: {
+ body: objectBody,
+ path: {
+ tileId,
+ },
+ query: {},
+ },
+ })
}
function deleteTileObject(tileId, endpoint) {
- return deleteById("/tiles/{tileId}" + endpoint, { tileId });
+ return deleteById('/tiles/{tileId}' + endpoint, { tileId })
}
diff --git a/frontend/src/api/routes/token-signin.js b/frontend/src/api/routes/token-signin.js
index 26875606..7cff093a 100644
--- a/frontend/src/api/routes/token-signin.js
+++ b/frontend/src/api/routes/token-signin.js
@@ -1,7 +1,7 @@
export function performTokenSignIn(token) {
- return new Promise(resolve => {
- window["jQuery"].post("/tokensignin", { idtoken: token }, data =>
- resolve(data)
- );
- });
+ return new Promise(resolve => {
+ window['jQuery'].post('/tokensignin', { idtoken: token }, data =>
+ resolve(data),
+ )
+ })
}
diff --git a/frontend/src/api/routes/traces.js b/frontend/src/api/routes/traces.js
index a9ee4fae..140408b1 100644
--- a/frontend/src/api/routes/traces.js
+++ b/frontend/src/api/routes/traces.js
@@ -1,9 +1,9 @@
-import { getAll, getById } from "./util";
+import { getAll, getById } from './util'
export function getAllTraces() {
- return getAll("/traces");
+ return getAll('/traces')
}
export function getJobsOfTrace(traceId) {
- return getById("/traces/{traceId}/jobs", { traceId });
+ return getById('/traces/{traceId}/jobs', { traceId })
}
diff --git a/frontend/src/api/routes/users.js b/frontend/src/api/routes/users.js
index f8d8039c..4cb194ce 100644
--- a/frontend/src/api/routes/users.js
+++ b/frontend/src/api/routes/users.js
@@ -1,71 +1,71 @@
-import { sendRequest } from "../index";
-import { deleteById, getById } from "./util";
+import { sendRequest } from '../index'
+import { deleteById, getById } from './util'
export function getUserByEmail(email) {
- return sendRequest({
- path: "/users",
- method: "GET",
- parameters: {
- body: {},
- path: {},
- query: {
- email
- }
- }
- });
+ return sendRequest({
+ path: '/users',
+ method: 'GET',
+ parameters: {
+ body: {},
+ path: {},
+ query: {
+ email,
+ },
+ },
+ })
}
export function addUser(user) {
- return sendRequest({
- path: "/users",
- method: "POST",
- parameters: {
- body: {
- user: user
- },
- path: {},
- query: {}
- }
- });
+ return sendRequest({
+ path: '/users',
+ method: 'POST',
+ parameters: {
+ body: {
+ user,
+ },
+ path: {},
+ query: {},
+ },
+ })
}
export function getUser(userId) {
- return sendRequest({
- path: "/users/{userId}",
- method: "GET",
- parameters: {
- body: {},
- path: {
- userId
- },
- query: {}
- }
- });
+ return sendRequest({
+ path: '/users/{userId}',
+ method: 'GET',
+ parameters: {
+ body: {},
+ path: {
+ userId,
+ },
+ query: {},
+ },
+ })
}
export function updateUser(userId, user) {
- return sendRequest({
- path: "/users/{userId}",
- method: "PUT",
- parameters: {
- body: {
- user: {
- givenName: user.givenName,
- familyName: user.familyName
- }
- },
- path: {
- userId
- },
- query: {}
- }
- });
+ 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 });
+ return deleteById('/users/{userId}', { userId })
}
export function getAuthorizationsByUser(userId) {
- return getById("/users/{userId}/authorizations", { userId });
+ return getById('/users/{userId}/authorizations', { userId })
}
diff --git a/frontend/src/api/routes/util.js b/frontend/src/api/routes/util.js
index 35a40333..67e7173b 100644
--- a/frontend/src/api/routes/util.js
+++ b/frontend/src/api/routes/util.js
@@ -1,37 +1,37 @@
-import { sendRequest } from "../index";
+import { sendRequest } from '../index'
export function getAll(path) {
- return sendRequest({
- path,
- method: "GET",
- parameters: {
- body: {},
- path: {},
- query: {}
- }
- });
+ return sendRequest({
+ path,
+ method: 'GET',
+ parameters: {
+ body: {},
+ path: {},
+ query: {},
+ },
+ })
}
export function getById(path, pathObject) {
- return sendRequest({
- path,
- method: "GET",
- parameters: {
- body: {},
- path: pathObject,
- query: {}
- }
- });
+ return sendRequest({
+ path,
+ method: 'GET',
+ parameters: {
+ body: {},
+ path: pathObject,
+ query: {},
+ },
+ })
}
export function deleteById(path, pathObject) {
- return sendRequest({
- path,
- method: "DELETE",
- parameters: {
- body: {},
- path: pathObject,
- query: {}
- }
- });
+ return sendRequest({
+ path,
+ method: 'DELETE',
+ parameters: {
+ body: {},
+ path: pathObject,
+ query: {},
+ },
+ })
}
diff --git a/frontend/src/api/socket.js b/frontend/src/api/socket.js
index fadb77ad..ce5f7587 100644
--- a/frontend/src/api/socket.js
+++ b/frontend/src/api/socket.js
@@ -1,52 +1,52 @@
-import io from "socket.io-client";
-import { getAuthToken } from "../auth/index";
+import io from 'socket.io-client'
+import { getAuthToken } from '../auth/index'
-let socket;
-let requestIdCounter = 0;
-const callbacks = {};
+let socket
+let requestIdCounter = 0
+const callbacks = {}
export function setupSocketConnection(onConnect) {
- let port = window.location.port;
- if (process.env.NODE_ENV !== "production") {
- port = 8081;
- }
- socket = io.connect(
- window.location.protocol + "//" + window.location.hostname + ":" + port
- );
- socket.on("connect", onConnect);
- socket.on("response", onSocketResponse);
+ let port = window.location.port
+ if (process.env.NODE_ENV !== 'production') {
+ port = 8081
+ }
+ socket = io.connect(
+ window.location.protocol + '//' + window.location.hostname + ':' + port,
+ )
+ socket.on('connect', onConnect)
+ socket.on('response', onSocketResponse)
}
export function sendSocketRequest(request, callback) {
- if (!socket.connected) {
- console.error("Attempted to send request over unconnected socket");
- return;
- }
+ if (!socket.connected) {
+ console.error('Attempted to send request over unconnected socket')
+ return
+ }
- const newId = requestIdCounter++;
- callbacks[newId] = callback;
+ const newId = requestIdCounter++
+ callbacks[newId] = callback
- request.id = newId;
- request.token = getAuthToken();
+ request.id = newId
+ request.token = getAuthToken()
- if (!request.isRootRoute) {
- request.path = "/v2" + request.path;
- }
+ if (!request.isRootRoute) {
+ request.path = '/v2' + request.path
+ }
- socket.emit("request", request);
+ socket.emit('request', request)
- if (process.env.NODE_ENV !== "production") {
- console.log("Sent socket request:", request);
- }
+ if (process.env.NODE_ENV !== 'production') {
+ console.log('Sent socket request:', request)
+ }
}
function onSocketResponse(json) {
- const response = JSON.parse(json);
+ const response = JSON.parse(json)
- if (process.env.NODE_ENV !== "production") {
- console.log("Received socket response:", response);
- }
+ if (process.env.NODE_ENV !== 'production') {
+ console.log('Received socket response:', response)
+ }
- callbacks[response.id](response);
- delete callbacks[response.id];
+ callbacks[response.id](response)
+ delete callbacks[response.id]
}