summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/redux
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-04-04 17:00:31 +0200
committerGitHub <noreply@github.com>2022-04-04 17:00:31 +0200
commit38769373c7e89783d33849283586bfa0b62e8251 (patch)
tree4fda128ee6b30018c1aa14c584cc53ade80e67f7 /opendc-web/opendc-web-ui/src/redux
parent6021aa4278bebb34bf5603ead4b5daeabcdc4c19 (diff)
parent527ae2230f5c2dd22f496f45d5d8e3bd4acdb854 (diff)
merge: Migrate to Quarkus-based web API
This pull request changes the web API to a Quarkus-based version. Currently, the OpenDC web API is written in Python (using Flask). Although Python is a powerful language to develop web services, having another language next to Kotlin/Java and JavaScript introduces some challenges. For instance, the web API and UI lack integration with our Gradle-based build pipeline and require additional steps from the developer to start working with. Furthermore, deploying OpenDC requires having Python installed in addition to the JVM. By converting the web API into a Quarkus application, we can enjoy further integration with our Gradle-based build pipeline and simplify the development/deployment process of OpenDC, by requiring only the JVM and Node to work with OpenDC. ## Implementation Notes :hammer_and_pick: * Move build dependencies into version catalog * Design unified communication protocol * Add Quarkus API implementation * Add new web client implementation * Update runner to use new web client * Fix compatibility with React.js UI * Remove Python build steps from CI pipeline * Update Docker deployment for new web API * Remove obsolete database configuration ## External Dependencies :four_leaf_clover: * Quarkus ## Breaking API Changes :warning: * The new web API only supports SQL-based databases for storing user-data, as opposed to MongoDB currently. We intend to use H2 for development and Postgres for production.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/redux')
-rw-r--r--opendc-web/opendc-web-ui/src/redux/actions/topology/building.js8
-rw-r--r--opendc-web/opendc-web-ui/src/redux/actions/topology/index.js3
-rw-r--r--opendc-web/opendc-web-ui/src/redux/actions/topology/rack.js2
-rw-r--r--opendc-web/opendc-web-ui/src/redux/actions/topology/room.js6
-rw-r--r--opendc-web/opendc-web-ui/src/redux/reducers/topology/machine.js2
-rw-r--r--opendc-web/opendc-web-ui/src/redux/reducers/topology/rack.js4
-rw-r--r--opendc-web/opendc-web-ui/src/redux/reducers/topology/room.js4
-rw-r--r--opendc-web/opendc-web-ui/src/redux/reducers/topology/tile.js4
-rw-r--r--opendc-web/opendc-web-ui/src/redux/reducers/topology/topology.js4
-rw-r--r--opendc-web/opendc-web-ui/src/redux/sagas/topology.js9
10 files changed, 24 insertions, 22 deletions
diff --git a/opendc-web/opendc-web-ui/src/redux/actions/topology/building.js b/opendc-web/opendc-web-ui/src/redux/actions/topology/building.js
index 939c24a4..e430da2e 100644
--- a/opendc-web/opendc-web-ui/src/redux/actions/topology/building.js
+++ b/opendc-web/opendc-web-ui/src/redux/actions/topology/building.js
@@ -14,16 +14,16 @@ export const DELETE_TILE = 'DELETE_TILE'
export function startNewRoomConstruction() {
return (dispatch, getState) => {
const { topology } = getState()
- const topologyId = topology.root._id
+ const topologyId = topology.root.id
const room = {
- _id: uuid(),
+ id: uuid(),
name: 'Room',
topologyId,
tiles: [],
}
dispatch(addRoom(topologyId, room))
- dispatch(startNewRoomConstructionSucceeded(room._id))
+ dispatch(startNewRoomConstructionSucceeded(room.id))
}
}
@@ -97,7 +97,7 @@ export function addTile(roomId, positionX, positionY) {
return {
type: ADD_TILE,
tile: {
- _id: uuid(),
+ id: uuid(),
roomId,
positionX,
positionY,
diff --git a/opendc-web/opendc-web-ui/src/redux/actions/topology/index.js b/opendc-web/opendc-web-ui/src/redux/actions/topology/index.js
index 94a712c4..d48af37a 100644
--- a/opendc-web/opendc-web-ui/src/redux/actions/topology/index.js
+++ b/opendc-web/opendc-web-ui/src/redux/actions/topology/index.js
@@ -23,9 +23,10 @@
export const OPEN_TOPOLOGY = 'OPEN_TOPOLOGY'
export const STORE_TOPOLOGY = 'STORE_TOPOLOGY'
-export function openTopology(id) {
+export function openTopology(projectId, id) {
return {
type: OPEN_TOPOLOGY,
+ projectId,
id,
}
}
diff --git a/opendc-web/opendc-web-ui/src/redux/actions/topology/rack.js b/opendc-web/opendc-web-ui/src/redux/actions/topology/rack.js
index c319d966..308acaa6 100644
--- a/opendc-web/opendc-web-ui/src/redux/actions/topology/rack.js
+++ b/opendc-web/opendc-web-ui/src/redux/actions/topology/rack.js
@@ -24,7 +24,7 @@ export function addMachine(rackId, position) {
return {
type: ADD_MACHINE,
machine: {
- _id: uuid(),
+ id: uuid(),
rackId,
position,
cpus: [],
diff --git a/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js b/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
index bd447db5..fd2d8cdc 100644
--- a/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
+++ b/opendc-web/opendc-web-ui/src/redux/actions/topology/room.js
@@ -16,7 +16,7 @@ export function addRoom(topologyId, room) {
return {
type: ADD_ROOM,
room: {
- _id: uuid(),
+ id: uuid(),
topologyId,
...room,
},
@@ -54,9 +54,9 @@ export function addRackToTile(positionX, positionY) {
dispatch({
type: ADD_RACK_TO_TILE,
rack: {
- _id: uuid(),
+ id: uuid(),
name: 'Rack',
- tileId: tile._id,
+ tileId: tile.id,
capacity: DEFAULT_RACK_SLOT_CAPACITY,
powerCapacityW: DEFAULT_RACK_POWER_CAPACITY,
machines: [],
diff --git a/opendc-web/opendc-web-ui/src/redux/reducers/topology/machine.js b/opendc-web/opendc-web-ui/src/redux/reducers/topology/machine.js
index 47af53cf..1789257b 100644
--- a/opendc-web/opendc-web-ui/src/redux/reducers/topology/machine.js
+++ b/opendc-web/opendc-web-ui/src/redux/reducers/topology/machine.js
@@ -10,7 +10,7 @@ function machine(state = {}, action, { racks }) {
case ADD_MACHINE:
return produce(state, (draft) => {
const { machine } = action
- draft[machine._id] = machine
+ draft[machine.id] = machine
})
case DELETE_MACHINE:
return produce(state, (draft) => {
diff --git a/opendc-web/opendc-web-ui/src/redux/reducers/topology/rack.js b/opendc-web/opendc-web-ui/src/redux/reducers/topology/rack.js
index 155837cb..ca79348a 100644
--- a/opendc-web/opendc-web-ui/src/redux/reducers/topology/rack.js
+++ b/opendc-web/opendc-web-ui/src/redux/reducers/topology/rack.js
@@ -33,7 +33,7 @@ function rack(state = {}, action, { machines }) {
case ADD_RACK_TO_TILE:
return produce(state, (draft) => {
const { rack } = action
- draft[rack._id] = rack
+ draft[rack.id] = rack
})
case EDIT_RACK_NAME:
return produce(state, (draft) => {
@@ -48,7 +48,7 @@ function rack(state = {}, action, { machines }) {
case ADD_MACHINE:
return produce(state, (draft) => {
const { machine } = action
- draft[machine.rackId].machines.push(machine._id)
+ draft[machine.rackId].machines.push(machine.id)
})
case DELETE_MACHINE:
return produce(state, (draft) => {
diff --git a/opendc-web/opendc-web-ui/src/redux/reducers/topology/room.js b/opendc-web/opendc-web-ui/src/redux/reducers/topology/room.js
index d6cc51c1..c05c8bfa 100644
--- a/opendc-web/opendc-web-ui/src/redux/reducers/topology/room.js
+++ b/opendc-web/opendc-web-ui/src/redux/reducers/topology/room.js
@@ -32,7 +32,7 @@ function room(state = {}, action, { tiles }) {
case ADD_ROOM:
return produce(state, (draft) => {
const { room } = action
- draft[room._id] = room
+ draft[room.id] = room
})
case DELETE_ROOM:
return produce(state, (draft) => {
@@ -47,7 +47,7 @@ function room(state = {}, action, { tiles }) {
case ADD_TILE:
return produce(state, (draft) => {
const { tile } = action
- draft[tile.roomId].tiles.push(tile._id)
+ draft[tile.roomId].tiles.push(tile.id)
})
case DELETE_TILE:
return produce(state, (draft) => {
diff --git a/opendc-web/opendc-web-ui/src/redux/reducers/topology/tile.js b/opendc-web/opendc-web-ui/src/redux/reducers/topology/tile.js
index 6dbccb66..8e5ecd6e 100644
--- a/opendc-web/opendc-web-ui/src/redux/reducers/topology/tile.js
+++ b/opendc-web/opendc-web-ui/src/redux/reducers/topology/tile.js
@@ -33,7 +33,7 @@ function tile(state = {}, action, { racks }) {
case ADD_TILE:
return produce(state, (draft) => {
const { tile } = action
- draft[tile._id] = tile
+ draft[tile.id] = tile
})
case DELETE_TILE:
return produce(state, (draft) => {
@@ -43,7 +43,7 @@ function tile(state = {}, action, { racks }) {
case ADD_RACK_TO_TILE:
return produce(state, (draft) => {
const { rack } = action
- draft[rack.tileId].rack = rack._id
+ draft[rack.tileId].rack = rack.id
})
case DELETE_RACK:
return produce(state, (draft) => {
diff --git a/opendc-web/opendc-web-ui/src/redux/reducers/topology/topology.js b/opendc-web/opendc-web-ui/src/redux/reducers/topology/topology.js
index cd9b5efd..dff0a69e 100644
--- a/opendc-web/opendc-web-ui/src/redux/reducers/topology/topology.js
+++ b/opendc-web/opendc-web-ui/src/redux/reducers/topology/topology.js
@@ -21,7 +21,7 @@
*/
import produce from 'immer'
-import { STORE_TOPOLOGY } from "../../actions/topology";
+import { STORE_TOPOLOGY } from '../../actions/topology'
import { ADD_ROOM, DELETE_ROOM } from '../../actions/topology/room'
function topology(state = undefined, action) {
@@ -31,7 +31,7 @@ function topology(state = undefined, action) {
case ADD_ROOM:
return produce(state, (draft) => {
const { room } = action
- draft.rooms.push(room._id)
+ draft.rooms.push(room.id)
})
case DELETE_ROOM:
return produce(state, (draft) => {
diff --git a/opendc-web/opendc-web-ui/src/redux/sagas/topology.js b/opendc-web/opendc-web-ui/src/redux/sagas/topology.js
index 4c8ff5da..15147bcf 100644
--- a/opendc-web/opendc-web-ui/src/redux/sagas/topology.js
+++ b/opendc-web/opendc-web-ui/src/redux/sagas/topology.js
@@ -32,14 +32,15 @@ export function* updateServer() {
* Watch the topology on the server for changes.
*/
export function* watchServer() {
- let { id } = yield take(OPEN_TOPOLOGY)
+ let { projectId, id } = yield take(OPEN_TOPOLOGY)
while (true) {
- const channel = yield queryObserver(id)
+ const channel = yield queryObserver(projectId, id)
while (true) {
const [action, response] = yield race([take(OPEN_TOPOLOGY), take(channel)])
if (action) {
+ projectId = action.projectId
id = action.id
break
}
@@ -57,9 +58,9 @@ export function* watchServer() {
/**
* Observe changes for the topology with the specified identifier.
*/
-function* queryObserver(id) {
+function* queryObserver(projectId, id) {
const queryClient = yield getContext('queryClient')
- const observer = new QueryObserver(queryClient, { queryKey: ['topologies', id] })
+ const observer = new QueryObserver(queryClient, { queryKey: ['topologies', projectId, id] })
return eventChannel((emitter) => {
const unsubscribe = observer.subscribe((result) => {