mirror of
https://gitlab.aliens-lyon.fr/encartes/web-interface.git
synced 2026-03-18 23:21:05 +01:00
debug de la gestion des connexions
This commit is contained in:
parent
2f0645708b
commit
7b010f2c4c
@ -42,8 +42,8 @@ function ChangeFloor({ currentFloor, callbackFloorChanged }) {
|
||||
fullWidth
|
||||
>
|
||||
<MenuItem value={1}>Monod - Premier étage</MenuItem>
|
||||
<MenuItem value={2}>Monod - Troisième étage</MenuItem>
|
||||
<MenuItem value={3}>Monod - Quatrième étage</MenuItem>
|
||||
<MenuItem value={6}>Monod - Troisième étage</MenuItem>
|
||||
<MenuItem value={7}>Monod - Quatrième étage</MenuItem>
|
||||
</Select>
|
||||
</div>
|
||||
</>
|
||||
|
||||
18
src/Map.js
18
src/Map.js
@ -140,10 +140,14 @@ function min_max(request)
|
||||
|
||||
function floorList(connectedFloors, callbackChangeFloor)
|
||||
{
|
||||
// Returns under html format a list of floors connected
|
||||
// listed in connectedFloors
|
||||
let htmlFloorList = [];
|
||||
for (const floor in connectedFloors)
|
||||
{
|
||||
htmlFloorList = [...htmlFloorList, <li onClick={() => {callbackChangeFloor(floor["id"]);}}> {floor["name"]} </li>];
|
||||
htmlFloorList = [...htmlFloorList, <li key={floor} onClick={() => {callbackChangeFloor(connectedFloors[floor]);}}>
|
||||
{connectedFloors[floor]}
|
||||
</li>];
|
||||
}
|
||||
return htmlFloorList;
|
||||
}
|
||||
@ -159,7 +163,7 @@ function newPolygon(element, positions, selectedRoom, callbackRoomSelected, call
|
||||
return <Polygon positions={positions} key={element["id"] + color} color={color} evenHandlers={{click: () => callbackRoomSelected(element["id"])}}>
|
||||
<Tooltip>{element["id"]}</Tooltip>
|
||||
<Stairs position={polygonCenter(positions)} size={logoSize(positions)} body={<Popup>
|
||||
{floorList(element["connexions"], callbackChangeFloor)}
|
||||
{floorList(element["connectedFloors"], callbackChangeFloor)}
|
||||
</Popup>
|
||||
}
|
||||
/>
|
||||
@ -171,7 +175,7 @@ function newPolygon(element, positions, selectedRoom, callbackRoomSelected, call
|
||||
return <Polygon positions={positions} key={element["id"] + color} color={color} evenHandlers={{click: () => callbackRoomSelected(element["id"])}}>
|
||||
<Tooltip>{element["id"]}</Tooltip>
|
||||
<Lift position={polygonCenter(positions)} size={logoSize(positions)} body={<Popup>
|
||||
{floorList(element["connexions"], callbackChangeFloor)}
|
||||
{floorList(element["connectedFloors"], callbackChangeFloor)}
|
||||
</Popup>
|
||||
}
|
||||
/>
|
||||
@ -205,7 +209,8 @@ function list_polygons(request, center, callbackRoomSelected, selectedRoom, call
|
||||
const element = request[ind];
|
||||
// element can be a room, a lift, a staircase or toilets
|
||||
const positions = (element["surface"]).map((pt) => {
|
||||
// This function rotates and recenters de the map (should not be necessary once the real data are gathered)
|
||||
// This function rotates and recenters de the map (should not be necessary once the real data are gathered and
|
||||
// only works for third floor)
|
||||
// It also changes the objects into lists of two coordinates to make it accepted by the "positions" attribute of
|
||||
// the "Polygon" react-leaflet component
|
||||
return [-(pt["y"] - center[1]) / 25, (pt["x"] - center[0]) / 25];
|
||||
@ -237,13 +242,16 @@ function Map({callbackRoomSelected, selectedRoom, floorID, callbackChangeFloor})
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [floor, setFloor] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
// We use the useEffect hook to fetch the data to build the Map
|
||||
useEffect(() =>
|
||||
{
|
||||
fetch("https://encartes.aliens-lyon.fr/api/map/get_floor/"+floorID)
|
||||
.then(response => response.json())
|
||||
.then(data => {setLoading(false); setFloor(data)})
|
||||
.catch((error) => {setError("API unreachable");});
|
||||
}, []);
|
||||
}, [floorID]);
|
||||
// We distinguish wether to print an error, a loading message
|
||||
// or the map if we got the answer
|
||||
if (error != null)
|
||||
{
|
||||
return <MapContainer center={[0, 0]} zoom={4} scrollWheelZoom={true} style={{ flexGrow: '1' }}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user