From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- rushs/eplace/src/rooms/index.js | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 rushs/eplace/src/rooms/index.js (limited to 'rushs/eplace/src/rooms/index.js') diff --git a/rushs/eplace/src/rooms/index.js b/rushs/eplace/src/rooms/index.js new file mode 100644 index 0000000..dde88e6 --- /dev/null +++ b/rushs/eplace/src/rooms/index.js @@ -0,0 +1,50 @@ +// FIXME: This file should handle the rooms API +// Functions may include: + +import { subscribe } from "../utils/streams"; +import { authedAPIRequest } from "../utils/auth"; + +// - fetchRoomConfig (get the configuration of a room) +export async function fetchRoomConfig(slug) { + const config = { + method: "get", + }; + + return authedAPIRequest(`/rooms/${slug}/config`, config) + .then(async (res) => { + if (!res) { + return null; + } + + const response = await res.json(); + + document.getElementById("room-name").innerHTML = + response.metadata.name; + const description = document.getElementById("room-description"); + + if (response.metadata.description) { + description.innerHTML = response.metadata.description; + description.style.display = "inherit"; + } else { + description.style.display = "none"; + } + + return response; + }) + .catch((error) => { + console.log(error); + return null; + }); +} +// - joinRoom (join a room by its slug) +export function joinRoom(slug) { + if (!slug) { + slug = "epi-place"; + } + + subscribe(slug); +} +// - listRooms (list all the rooms available) +// - createRoom (create a room) +// - updateRoom (update a room's configuration) +// - deleteRoom (delete a room) -- cgit v1.2.3