diff --git a/src/App.js b/src/App.js
index a88b152..90e5dfb 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,9 +1,7 @@
-import * as React from 'react';
+import React from 'react';
import AppBar from '@mui/material/AppBar';
-import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
-import Chip from '@mui/material/Chip';
import CssBaseline from '@mui/material/CssBaseline';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
@@ -12,169 +10,20 @@ import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';
import Divider from '@mui/material/Divider';
import IconButton from '@mui/material/IconButton';
-import MenuItem from '@mui/material/MenuItem';
-import Select from '@mui/material/Select';
-import TextField from '@mui/material/TextField';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
-import EditIcon from '@mui/icons-material/Edit';
-import SearchIcon from '@mui/icons-material/Search';
import SettingsBrightnessIcon from '@mui/icons-material/SettingsBrightness';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import './App.css'
+import ChangeFloor from './ChangeFloor';
+import EditDialog from './EditDialog';
import Map from './Map.js';
-import Rooms from './Rooms.js';
-import API_URL from './config.js';
-
-function ChangeFloor({ currentFloor, callbackFloorChanged }) {
- const [sites, setSites] = React.useState([]);
- const handleFloorChanged = (event) => {
- callbackFloorChanged(event.target.value);
- };
-
- React.useEffect(() => {
- fetch(API_URL + "get_all_floors/")
- .then(response => response.json())
- .then(data => {
- setSites(data);
-
- // Display a floor
- callbackFloorChanged(data[0].buildings[0].floors[0].id)
- });
- }, [callbackFloorChanged]);
-
- if (currentFloor === undefined) return;
-
- var items = [];
-
- sites.forEach(site => {
- site.buildings.forEach(building => {
- building.floors.forEach(floor => {
- items.push(
-
- )
- })
- })
-
- });
-
- return <>
-
-
- Changer d'étage
-
-
-
- >
-}
-
-function RoomResearch({ callbackRoomSelected }) {
- const [currentRequest, setCurrentRequest] = React.useState("");
- const [rooms, setRooms] = React.useState([]);
-
- const startResearch = (event) => {
- fetch(API_URL + "find_place_by_name/" + currentRequest)
- .then(response => response.json())
- .then(data => {
- setRooms(data);
- });
- };
-
- return <>
-
-
- Rechercher une salle
-
- { setCurrentRequest(event.target.value) }}
- variant="outlined"
- fullWidth
- />
-
- } variant="contained" onClick={startResearch}>
- Rechercher
-
-
-
-
- >
-}
-
-function RoomInformation({ roomId, setIsEditDialogOpen }) {
- const [names, setNames] = React.useState([]);
- const [users, setUsers] = React.useState([]);
-
- React.useEffect(() => {
- if (roomId !== undefined) {
- fetch(API_URL + "get_place_info/" + roomId)
- .then(response => response.json())
- .then(data => {
- setNames(data.names);
- setUsers(data.users);
- });
- }
- }, [roomId]);
-
- if (roomId === undefined) {
- return;
- }
-
- return
-
- Salle sélectionnée
-
-
-
Noms
- {
- names.length === 0
- ?
Aucun nom défini
- : names.map(name => {
- return
-
-
-
- })
- }
-
-
Utilisateurs
-
- {
- users.length === 0
- ? Aucun utilisateur défini
- : users.map(name => {
- return
-
-
-
- })
- }
-
-
-
} onClick={() => { setIsEditDialogOpen(true) }}>
- Modifier
-
-
-}
+import RoomInformation from './RoomInformation';
+import RoomResearch from './RoomResearch';
function TopBar({ toggleTheme }) {
const [openAboutModal, setOpenAboutModal] = React.useState(false);
@@ -221,99 +70,6 @@ function TopBar({ toggleTheme }) {
>
}
-function EditDialog({ isOpen, setIsOpen, room }) {
- const [names, setNames] = React.useState([]);
- const [users, setUsers] = React.useState([]);
- const [newPlaceName, setNewPlaceName] = React.useState("");
- const [newUserName, setNewUserName] = React.useState("");
-
- // Used to refresh useEffect
- const [updatesCount, setupdatesCount] = React.useState(0);
-
- React.useEffect(() => {
- if (room !== undefined) {
- fetch(API_URL + "get_place_info/" + room)
- .then(response => response.json())
- .then(data => {
- setNames(data.names);
- setUsers(data.users);
- });
- }
- }, [room, updatesCount]);
-
- const refresh = () => {
- setupdatesCount(updatesCount + 1);
- };
-
- const addName = () => {
- fetch(API_URL + "add_place_name/" + room + "/" + encodeURI(newPlaceName))
- .then(response => refresh());
- };
-
- const removeName = (placeName) => {
- fetch(API_URL + "del_place_name/" + room + "/" + encodeURI(placeName))
- .then(response => refresh());
- }
-
- const addUser = () => {
- fetch(API_URL + "add_room_user_name/" + room + "/" + encodeURI(newUserName))
- .then(response => refresh());
- };
-
- const removeUser = (userName) => {
- fetch(API_URL + "del_room_user_name/" + room + "/" + encodeURI(userName))
- .then(response => refresh());
- }
-
- return
-}
-
function App({ toggleTheme }) {
const [currentFloor, setCurrentFloor] = React.useState(undefined);
const [selectedRoom, setSelectedRoom] = React.useState(undefined);
diff --git a/src/ChangeFloor.js b/src/ChangeFloor.js
new file mode 100644
index 0000000..724c2c1
--- /dev/null
+++ b/src/ChangeFloor.js
@@ -0,0 +1,58 @@
+import React from 'react';
+
+import MenuItem from '@mui/material/MenuItem';
+import Select from '@mui/material/Select';
+import Typography from '@mui/material/Typography';
+
+import API_URL from './config.js';
+
+export default function ChangeFloor({ currentFloor, callbackFloorChanged }) {
+ const [sites, setSites] = React.useState([]);
+ const handleFloorChanged = (event) => {
+ callbackFloorChanged(event.target.value);
+ };
+
+ React.useEffect(() => {
+ fetch(API_URL + "get_all_floors/")
+ .then(response => response.json())
+ .then(data => {
+ setSites(data);
+
+ // Display a floor
+ callbackFloorChanged(data[0].buildings[0].floors[0].id)
+ });
+ }, [callbackFloorChanged]);
+
+ if (currentFloor === undefined) return;
+
+ var items = [];
+
+ sites.forEach(site => {
+ site.buildings.forEach(building => {
+ building.floors.forEach(floor => {
+ items.push(
+
+ )
+ })
+ })
+
+ });
+
+ return <>
+
+
+ Changer d'étage
+
+
+
+ >
+ }
\ No newline at end of file
diff --git a/src/EditDialog.js b/src/EditDialog.js
new file mode 100644
index 0000000..2a68fbd
--- /dev/null
+++ b/src/EditDialog.js
@@ -0,0 +1,105 @@
+import React from 'react';
+
+import Button from '@mui/material/Button';
+import Chip from '@mui/material/Chip';
+import Dialog from '@mui/material/Dialog';
+import DialogActions from '@mui/material/DialogActions';
+import DialogContent from '@mui/material/DialogContent';
+import DialogTitle from '@mui/material/DialogTitle';
+import Divider from '@mui/material/Divider';
+import TextField from '@mui/material/TextField';
+
+import API_URL from './config.js';
+
+export default function EditDialog({ isOpen, setIsOpen, room }) {
+ const [names, setNames] = React.useState([]);
+ const [users, setUsers] = React.useState([]);
+ const [newPlaceName, setNewPlaceName] = React.useState("");
+ const [newUserName, setNewUserName] = React.useState("");
+
+ // Used to refresh useEffect
+ const [updatesCount, setupdatesCount] = React.useState(0);
+
+ React.useEffect(() => {
+ if (room !== undefined) {
+ fetch(API_URL + "get_place_info/" + room)
+ .then(response => response.json())
+ .then(data => {
+ setNames(data.names);
+ setUsers(data.users);
+ });
+ }
+ }, [room, updatesCount]);
+
+ const refresh = () => {
+ setupdatesCount(updatesCount + 1);
+ };
+
+ const addName = () => {
+ fetch(API_URL + "add_place_name/" + room + "/" + encodeURI(newPlaceName))
+ .then(response => refresh());
+ };
+
+ const removeName = (placeName) => {
+ fetch(API_URL + "del_place_name/" + room + "/" + encodeURI(placeName))
+ .then(response => refresh());
+ }
+
+ const addUser = () => {
+ fetch(API_URL + "add_room_user_name/" + room + "/" + encodeURI(newUserName))
+ .then(response => refresh());
+ };
+
+ const removeUser = (userName) => {
+ fetch(API_URL + "del_room_user_name/" + room + "/" + encodeURI(userName))
+ .then(response => refresh());
+ }
+
+ return
+ }
\ No newline at end of file
diff --git a/src/RoomInformation.js b/src/RoomInformation.js
new file mode 100644
index 0000000..a842f85
--- /dev/null
+++ b/src/RoomInformation.js
@@ -0,0 +1,64 @@
+import React from 'react';
+
+import Button from '@mui/material/Button';
+import Chip from '@mui/material/Chip';
+import Typography from '@mui/material/Typography';
+import EditIcon from '@mui/icons-material/Edit';
+
+import API_URL from './config.js';
+
+export default function RoomInformation({ roomId, setIsEditDialogOpen }) {
+ const [names, setNames] = React.useState([]);
+ const [users, setUsers] = React.useState([]);
+
+ React.useEffect(() => {
+ if (roomId !== undefined) {
+ fetch(API_URL + "get_place_info/" + roomId)
+ .then(response => response.json())
+ .then(data => {
+ setNames(data.names);
+ setUsers(data.users);
+ });
+ }
+ }, [roomId]);
+
+ if (roomId === undefined) {
+ return;
+ }
+
+ return
+
+ Salle sélectionnée
+
+
+
Noms
+ {
+ names.length === 0
+ ?
Aucun nom défini
+ : names.map(name => {
+ return
+
+
+
+ })
+ }
+
+
Utilisateurs
+
+ {
+ users.length === 0
+ ? Aucun utilisateur défini
+ : users.map(name => {
+ return
+
+
+
+ })
+ }
+
+
+
} onClick={() => { setIsEditDialogOpen(true) }}>
+ Modifier
+
+
+ }
\ No newline at end of file
diff --git a/src/RoomResearch.js b/src/RoomResearch.js
new file mode 100644
index 0000000..b77dfc6
--- /dev/null
+++ b/src/RoomResearch.js
@@ -0,0 +1,49 @@
+import React from 'react';
+
+import Box from '@mui/material/Box';
+import Button from '@mui/material/Button';
+import TextField from '@mui/material/TextField';
+import Typography from '@mui/material/Typography';
+import SearchIcon from '@mui/icons-material/Search';
+
+import Rooms from './Rooms.js';
+import API_URL from './config.js';
+
+export default function RoomResearch({ callbackRoomSelected }) {
+ const [currentRequest, setCurrentRequest] = React.useState("");
+ const [rooms, setRooms] = React.useState([]);
+
+ const startResearch = (event) => {
+ fetch(API_URL + "find_place_by_name/" + currentRequest)
+ .then(response => response.json())
+ .then(data => {
+ setRooms(data);
+ });
+ };
+
+ return <>
+
+
+ Rechercher une salle
+
+ { setCurrentRequest(event.target.value) }}
+ variant="outlined"
+ fullWidth
+ />
+
+ } variant="contained" onClick={startResearch}>
+ Rechercher
+
+
+
+
+ >
+ }
\ No newline at end of file