Move room and calendar data to a specific folder (#52)

On met tout dans /data pour décorréler les sources du calendrier de la logique au maximum

Co-authored-by: Tom Hubrecht <tom.hubrecht@ens.fr>
Reviewed-on: https://git.rz.ens.wtf/Klub-RZ/metis/pulls/52
Co-authored-by: tomate <tom.hubrecht@ens.fr>
Co-committed-by: tomate <tom.hubrecht@ens.fr>
This commit is contained in:
tomate 2022-09-12 17:46:54 +02:00 committed by Ryan Lahfa
parent 26ccb5dcc9
commit e420cdd0b4
5 changed files with 193 additions and 209 deletions

131
data/calendars.json Normal file
View file

@ -0,0 +1,131 @@
{
"tree": {
"COF": {
"BdA": {},
"Évènements (COF)": {},
"Assemblées Générales (COF)": {}
},
"Clubs COF": {
"Club réseau": {},
"hackENS": {},
"Écriv'ENS": {},
"CinéClub": {},
"Ernestophone": {},
"DDR": {},
"BandarrêtdurgENS": {},
"Club Inutile ☔": {}
},
"BDS": {},
"La Nuit de l'ENS": {},
"Délégation Générale": {},
"K-Fêt": {},
"Rentrée académique": {
"Amphis de rentrée": {},
"Rentrée des départements": {},
"Conférences de recherche": {},
"Visites de bibliothèques": {},
"Réunions de rentrée des Masters": {},
"Activités pour les étudiants internationaux": {}
},
"Divers": {}
},
"sources": {
"eleves-ens": {
"LLWm8qK9iC5YGrrR": {
"name": "Délégation Générale",
"short_name": "DG"
},
"2KGkWzBJGorxzyTW": {
"name": "La Nuit de l'ENS",
"short_name": "La Nuit"
},
"w442JdS5AaQ6czrP": {
"name": "Écriv'ENS"
},
"fRtjDkjrZyn6fxd8": {
"name": "K-Fêt",
"color": "#c63b52",
"default_location": "K-Fêt"
},
"gsZtZK8c9EmREofn": {
"name": "Ernestophone"
},
"dTHrXnYgsEoSTjWB": {
"name": "Évènements (COF)",
"short_name": "COF"
},
"bCgRFByHLiCCNc55": {
"name": "Assemblées Générales (COF)",
"short_name": "AG COF"
},
"r4yJZDHjwNtH8wkR": {
"name": "BdA"
},
"ZtWm3MYSi388k2yk": {
"name": "DDR"
},
"T5WoHbs4FT5A945Z": {
"name": "CinéClub"
},
"6SHG6cg9d7S3qqwD": {
"name": "Club Inutile ☔",
"initial": false
},
"Ekjb4kDqMMqwJXZF": {
"name": "Rentrée des départements",
"short_name": "Dpt"
},
"8SKP62tQJP65K8EW": {
"name": "Conférences de recherche",
"short_name": "Conf"
},
"PnRXqeq4SsSC33FM": {
"name": "Visites de bibliothèques",
"short_name": "Bibli",
"initial": false
},
"NWPtiEiz62LTtjo2": {
"name": "Amphis de rentrée",
"short_name": "Prés. de rentrée"
},
"JiRt58aJXay9kfyk": {
"name": "Réunions de rentrée des Masters",
"short_name": "Masters"
},
"5Rb4bRjCDcsFjDdQ": {
"name": "Activités pour les étudiants internationaux",
"short_name": "Internationaux"
},
"62wKfQRrLNz2WXjt": {
"name": "Divers"
},
"TFjE83ASCMK9rfRi": {
"name": "BandarrêtdurgENS",
"short_name": "Banda"
},
"TyMrLaPPDzT7yAGC": {
"name": "BDS"
}
},
"klub-reseau": {
"5WrcagPPARQ3BD87": {
"name": "Club réseau",
"default_location": "Cave d'hackENS"
},
"TFEAKjAgNFQZpNjo": {
"name": "hackENS",
"default_location": "Cave d'hackENS"
}
},
"frama-agenda": {
"TFjE83ASCMK9rfRi": {
"name": "BandarrêtdurgENS",
"short_name": "Banda"
},
"T5WoHbs4FT5A945Z": {
"name": "CinéClub"
}
}
}
}

44
data/locations.json Normal file
View file

@ -0,0 +1,44 @@
{
"nameMap": {
"Amphi Jourdan": "Amphithéâtre Jourdan",
"R2-21 (Jourdan)": "R2-21",
"Salle Jean Ibanes (Jourdan, R1-07)": "Salle Jean Ibanes (R1-07)",
"Salle Madeleine Rebérioux (Jourdan, R2-02)": "Salle Madeleine Rebérioux (R2-02)",
"Salle Marcel Roncayolo (Jourdan, R2-05)": "Salle Marcel Roncayolo (R2-05)"
},
"rooms": {
"45 rue d'Ulm": [
"Amphithéâtre Galois",
"Bibliothèque Lettres",
"Salle Histoire",
"Salle Cavaillès",
"Salle Dussane",
"Salle des Actes",
"Salle des Résistants",
"Salle Cavaillès",
"Salle Cartan",
"Salle Noether",
"Salle Bourbaki",
"Cour aux Ernests",
"Cour du NIR",
"Cour Pasteur",
"Pôt",
"Petit pôt",
"Canopée",
"K-Fêt",
"Cave d'hackENS",
"Gymnase"
],
"24 rue Lhomond": ["Salle CONF IV"],
"29 rue d'Ulm": ["Bibliothèque des sciences expérimentales", "Salle Jaurès"],
"Jourdan": [
"Bibliothèque de Jourdan",
"Salle Marcel Roncayolo (R2-05)",
"Salle Madeleine Rebérioux (R2-02)",
"Amphithéâtre Jourdan",
"R2-21",
"Salle Jean Ibanes"
]
}
}

View file

@ -22,7 +22,7 @@
import bootstrap5Plugin from '@fullcalendar/bootstrap5';
import { Tooltip } from 'bootstrap';
import ENSLocations from './static-ens-locations.json';
import LOCATIONS from '../data/locations.json';
const event = writable(null);
@ -95,7 +95,7 @@
scrollTime: '08:00:00',
resourceGroupField: 'building',
resourceAreaWidth: '27%',
resources: Object.entries(ENSLocations).flatMap(([building, rooms]) =>
resources: Object.entries(LOCATIONS.rooms).flatMap(([building, rooms]) =>
rooms.map(room => ({
id: `${building}-${room}`,
building,

View file

@ -1,4 +1,5 @@
import STATIC_LOCATIONS from './static-ens-locations.json'
import CALENDARS from '../data/calendars.json'
import LOCATIONS from '../data/locations.json'
// https://stackoverflow.com/a/35970186
function invertColor(hex) {
@ -19,140 +20,19 @@ function invertColor(hex) {
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#FFFFFF'
}
const clouds = {
KLUB_RESEAU: 'klub-reseau',
ELEVES_ENS: 'eleves-ens',
FRAMA_AGENDA: 'frama-agenda'
const parseCalendars = () => {
let calendars = {};
for (const [cloud, cals] of Object.entries(CALENDARS.sources)) {
for (const [id, attrs] of Object.entries(cals)) {
calendars[id] = { cloud: cloud, ...attrs }
}
}
return calendars;
}
const calendars = {
'5WrcagPPARQ3BD87': {
cloud: clouds.KLUB_RESEAU,
name: 'Club réseau',
color: null,
default_location: "Cave d'hackENS"
},
TFEAKjAgNFQZpNjo: {
cloud: clouds.KLUB_RESEAU,
name: 'hackENS',
color: null,
default_location: "Cave d'hackENS"
},
LLWm8qK9iC5YGrrR: {
cloud: clouds.ELEVES_ENS,
name: 'Délégation Générale',
short_name: 'DG',
color: null
},
'2KGkWzBJGorxzyTW': {
cloud: clouds.ELEVES_ENS,
name: "La Nuit de l'ENS",
short_name: 'La Nuit',
color: null
},
w442JdS5AaQ6czrP: {
cloud: clouds.ELEVES_ENS,
name: "Écriv'ENS",
color: null
},
fRtjDkjrZyn6fxd8: {
cloud: clouds.ELEVES_ENS,
name: 'K-Fêt',
color: '#c63b52',
default_location: 'K-Fêt'
},
gsZtZK8c9EmREofn: {
cloud: clouds.ELEVES_ENS,
name: 'Ernestophone',
color: null
},
dTHrXnYgsEoSTjWB: {
cloud: clouds.ELEVES_ENS,
name: 'Évènements (COF)',
short_name: 'COF',
color: null
},
bCgRFByHLiCCNc55: {
cloud: clouds.ELEVES_ENS,
name: 'Assemblées Générales (COF)',
short_name: 'AG COF',
color: null
},
r4yJZDHjwNtH8wkR: {
cloud: clouds.ELEVES_ENS,
name: 'BdA',
color: null
},
ZtWm3MYSi388k2yk : {
cloud: clouds.ELEVES_ENS,
name: 'DDR',
color: null
},
T5WoHbs4FT5A945Z: {
cloud: clouds.FRAMA_AGENDA,
name: 'CinéClub',
color: null
},
'6SHG6cg9d7S3qqwD': {
cloud: clouds.ELEVES_ENS,
name: 'Club Inutile ☔',
color: null,
initial: false
},
Ekjb4kDqMMqwJXZF: {
cloud: clouds.ELEVES_ENS,
name: 'Rentrée des départements',
short_name: 'Dpt',
color: null
},
'8SKP62tQJP65K8EW': {
cloud: clouds.ELEVES_ENS,
name: 'Conférences de recherche',
short_name: 'Conf',
color: null
},
PnRXqeq4SsSC33FM: {
cloud: clouds.ELEVES_ENS,
name: 'Visites de bibliothèques',
short_name: 'Bibli',
initial: false,
color: null
},
NWPtiEiz62LTtjo2: {
cloud: clouds.ELEVES_ENS,
name: 'Amphis de rentrée',
short_name: 'Prés. de rentrée',
color: null
},
JiRt58aJXay9kfyk: {
cloud: clouds.ELEVES_ENS,
name: 'Réunions de rentrée des Masters',
short_name: 'Masters',
color: null
},
'5Rb4bRjCDcsFjDdQ': {
cloud: clouds.ELEVES_ENS,
name: 'Activités pour les étudiants internationaux',
short_name: 'Internationaux',
color: null
},
'62wKfQRrLNz2WXjt': {
cloud: clouds.ELEVES_ENS,
name: 'Divers',
color: null
},
TFjE83ASCMK9rfRi: {
cloud: clouds.FRAMA_AGENDA,
name: 'BandarrêtdurgENS',
short_name: 'Banda',
color: null
},
TyMrLaPPDzT7yAGC: {
cloud: clouds.ELEVES_ENS,
name: 'BDS',
color: null
}
}
const calendars = parseCalendars()
const calendarsByName = Object.fromEntries(
Object.entries(calendars).map(([id, { name }]) => [name, id])
@ -164,36 +44,7 @@ export const initialCalendars = Array.from(
.filter(cal => cal[1])
.map(cal => cal[0])
export const calendarTree = {
COF: {
BdA: {},
'Évènements (COF)': {},
'Assemblées Générales (COF)': {}
},
'Clubs COF': {
'Club réseau': {},
hackENS: {},
"Écriv'ENS": {},
CinéClub: {},
Ernestophone: {},
DDR: {},
'BandarrêtdurgENS': {},
'Club Inutile ☔': {}
},
BDS: {},
"La Nuit de l'ENS": {},
'Délégation Générale': {},
'K-Fêt': {},
'Rentrée académique': {
'Amphis de rentrée': {},
'Rentrée des départements': {},
'Conférences de recherche': {},
'Visites de bibliothèques': {},
'Réunions de rentrée des Masters': {},
'Activités pour les étudiants internationaux': {}
},
Divers: {}
}
export const calendarTree = CALENDARS.tree
const dfs = (p, t, l) => {
for (const [c, s] of Object.entries(t)) {
@ -266,17 +117,9 @@ class Calendar {
}
function findLocationId(location) {
const adhocMap = {
'Amphi Jourdan': 'Amphithéâtre Jourdan',
'R2-21 (Jourdan)': 'R2-21',
'Salle Jean Ibanes (Jourdan, R1-07)': 'Salle Jean Ibanes (R1-07)',
'Salle Madeleine Rebérioux (Jourdan, R2-02)': 'Salle Madeleine Rebérioux (R2-02)',
'Salle Marcel Roncayolo (Jourdan, R2-05)': 'Salle Marcel Roncayolo (R2-05)'
}
const correctedLocation = LOCATIONS.nameMap[location] || location
const correctedLocation = adhocMap[location] || location
const result = Object.entries(STATIC_LOCATIONS).find(([building, rooms]) =>
const result = Object.entries(LOCATIONS.rooms).find(([building, rooms]) =>
rooms.includes(correctedLocation)
)

View file

@ -1,34 +0,0 @@
{
"45 rue d'Ulm": [
"Amphithéâtre Galois",
"Bibliothèque Lettres",
"Salle Histoire",
"Salle Cavaillès",
"Salle Dussane",
"Salle des Actes",
"Salle des Résistants",
"Salle Cavaillès",
"Salle Cartan",
"Salle Noether",
"Salle Bourbaki",
"Cour aux Ernests",
"Cour du NIR",
"Cour Pasteur",
"Pôt",
"Petit pôt",
"Canopée",
"K-Fêt",
"Cave d'hackENS",
"Gymnase"
],
"24 rue Lhomond": ["Salle CONF IV"],
"29 rue d'Ulm": ["Bibliothèque des sciences expérimentales", "Salle Jaurès"],
"Jourdan": [
"Bibliothèque de Jourdan",
"Salle Marcel Roncayolo (R2-05)",
"Salle Madeleine Rebérioux (R2-02)",
"Amphithéâtre Jourdan",
"R2-21",
"Salle Jean Ibanes"
]
}