given files

This commit is contained in:
Gu://em_ 2026-05-15 11:08:23 +02:00
parent 9bf88844e9
commit a2c31f873d
48 changed files with 10458 additions and 0 deletions

6
src/utils/auth.js Normal file
View file

@ -0,0 +1,6 @@
// FIXME: This file should handle the authentication
// Functions may include:
// - getToken (exchanges the code for a token)
// - refreshToken (refreshes the token using the refresh_token)
// - authenticate (checks if the user is authenticated)
// - authedAPIRequest (makes an authenticated request to the API)

64
src/utils/notify.js Normal file
View file

@ -0,0 +1,64 @@
import $ from "jquery";
import alertHtml from "../components/notifications/index.html";
const iconMap = {
info: "fa-info-circle",
success: "fa-thumbs-up",
warning: "fa-exclamation-triangle",
error: "ffa fa-exclamation-circle",
};
/**
* Create an alert.
*
* Create an alert with the given title, message and type.
* The alert will display in the top right corner of the screen.
* This is a useful function to notify the user of any errors or warnings.
*
* @param {string} title
* @param {string} message
* @param {string} type success, warning, error
*
* @returns {void}
**/
export const createAlert = (title, message, type) => {
const alertContainer = $("#alert-container")?.[0];
$.ajax({
url: alertHtml,
success: (data) => {
const [alert] = $(data);
// Return if the alert cannot be created, usefull when a redirect is made
if (!alertContainer || !alert || !alert.classList) {
return;
}
// Add the type class to the alert
alert.classList.add(
`Alert${type.charAt(0).toUpperCase() + type.slice(1)}`,
);
// Replace values in innerHTML
alert.innerHTML = alert.innerHTML
.replace(/{{title}}/g, title)
.replace(/{{content}}/g, message)
.replace(/{{icon_classes}}/g, iconMap[type]);
// Get the close button
const closeBtn = alert.getElementsByClassName("AlertClose")?.[0];
closeBtn?.addEventListener("click", () => {
alert.remove();
});
// Append the alert to the container
alertContainer.append(alert);
// Remove the alert after 5 seconds
setTimeout(() => {
alert.remove();
}, 5000);
},
});
};

3
src/utils/rateLimits.js Normal file
View file

@ -0,0 +1,3 @@
// FIXME: This file should handle the rate limits
// Functions may include:
// - displayTimer (util function to display the timer for the rate limit)

4
src/utils/redirect.js Normal file
View file

@ -0,0 +1,4 @@
// FIXME: This file should handle the redirection to the AUTH URL
// Functions may include:
// - createLink (construct and return the URL to redirect the user to the login page)
// - redirectToLoginPage (redirect the user to the Forge ID login page)

9
src/utils/streams.js Normal file
View file

@ -0,0 +1,9 @@
// FIXME: This file should handle the sockets and the subscriptions
// Exports must include
// - initSocket (initialize the connection to the socket server)
// - socket (variable resulting of initSocket function)
// Functions may include:
// - subscribe (subscribe to a room's stream or chat)
// - unsubscribe (unsubscribe from a room's stream or chat)
// - sendMessage (send a message to a room's chat)