diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-05-11 16:34:25 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-05-12 22:50:49 +0200 |
| commit | 2dbb06f433964ccac13fd64ef512ed03142ed97b (patch) | |
| tree | ac6f9ec1d131de362ef1095be171442de4d9cdd9 /opendc-web/opendc-web-ui/src/api/routes/topologies.js | |
| parent | 873ddacf5abafe43fbc2b6c1033e473c3366dc62 (diff) | |
ui: Move communication to REST API
This change removes the socket.io websocket connection/client in favour
of the OpenDC REST API. The socket.io websocket implementation was
intended to be used for interactive and collaborative datacenter design
and exploration.
However, we do not support this functionality at the moment
(collaborative design and exploration) and having the entire API run
over this websocket connection is fragile and not standard practice.
To improve maintainability, we therefore remove the websocket
implementation in favour of the OpenDC REST API implementation using
the fetch API. If we want to implement collaboration in the future, we
will develop appropriate extensions in conjuction with the existing REST
API. For this, we should look for standard and existing implementation
of this functionality.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/api/routes/topologies.js')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/api/routes/topologies.js | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/opendc-web/opendc-web-ui/src/api/routes/topologies.js b/opendc-web/opendc-web-ui/src/api/routes/topologies.js index a8f0d6b1..076895ff 100644 --- a/opendc-web/opendc-web-ui/src/api/routes/topologies.js +++ b/opendc-web/opendc-web-ui/src/api/routes/topologies.js @@ -1,42 +1,17 @@ -import { deleteById, getById } from './util' -import { sendRequest } from '../index' +import { request } from '../index' export function addTopology(topology) { - return sendRequest({ - path: '/projects/{projectId}/topologies', - method: 'POST', - parameters: { - body: { - topology, - }, - path: { - projectId: topology.projectId, - }, - query: {}, - }, - }) + return request(`projects/${topology.projectId}/topologies`, 'POST', { topology }) } export function getTopology(topologyId) { - return getById('/topologies/{topologyId}', { topologyId }) + return request(`topologies/${topologyId}`) } export function updateTopology(topology) { - return sendRequest({ - path: '/topologies/{topologyId}', - method: 'PUT', - parameters: { - body: { - topology, - }, - path: { - topologyId: topology._id, - }, - query: {}, - }, - }) + return request(`topologies/${topology._id}`, 'PUT', { topology }) } export function deleteTopology(topologyId) { - return deleteById('/topologies/{topologyId}', { topologyId }) + return request(`topologies/${topologyId}`, 'DELETE') } |
