| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { useTranslate } from "react-admin"; |
| | | import { useTranslate, useRefresh, useSidebarState } from "react-admin"; |
| | | import { |
| | | TextField, |
| | | Select, |
| | |
| | | |
| | | const Map = () => { |
| | | const notify = useNotification(); |
| | | const [sidebarOpen] = useSidebarState(); |
| | | const translate = useTranslate(); |
| | | const theme = useTheme(); |
| | | const themeMode = theme.palette.mode; |
| | |
| | | return storedValue !== null ? JSON.parse(storedValue) : null; |
| | | }); |
| | | |
| | | const handleResize = () => { |
| | | const width = contentRef.current.offsetWidth; |
| | | const height = contentRef.current.offsetHeight; |
| | | player.resize(width, height); |
| | | }; |
| | | |
| | | useEffect(() => { |
| | | Tool.patchRaLayout('0px'); |
| | | const initialize = async () => { |
| | |
| | | // websocket = new WebSocketClient('/ws/map/websocket'); |
| | | |
| | | await Http.fetchMapData(); |
| | | |
| | | setTimeout(() => { |
| | | player.adaptScreen(); |
| | | notify.info('Welcome to Rcs'); |
| | | }, 200) |
| | | |
| | | // websocket.connect(); |
| | | // websocket.onMessage = (data) => { |
| | | // Tool.updateMapStatusInRealTime(data, () => curFloorRef.current, setCurSPrite); |
| | |
| | | initialize(); |
| | | |
| | | // resize |
| | | const handleResize = () => { |
| | | const width = contentRef.current.offsetWidth; |
| | | const height = contentRef.current.offsetHeight; |
| | | |
| | | player.resize(width, height); |
| | | }; |
| | | handleResize(); |
| | | window.addEventListener('resize', handleResize); |
| | | |
| | | notify.info('Welcome to Rcs'); |
| | | |
| | | return () => { |
| | | if (websocket) { |
| | |
| | | Tool.patchRaLayout(''); |
| | | }; |
| | | }, []) |
| | | |
| | | useEffect(() => { |
| | | setTimeout(handleResize, 300) |
| | | }, [sidebarOpen]); |
| | | |
| | | useEffect(() => { |
| | | player.setTheme(themeMode); |
| | |
| | | restartFn(); |
| | | }); |
| | | }); |
| | | |
| | | mapContainer.children.forEach(child => { |
| | | Tool.beMovable(child); |
| | | }) |
| | | break |
| | | case MapMode.SETTINGS_MODE: |
| | | player.hideGridLines(); |
| | |
| | | return ( |
| | | <Box |
| | | sx={{ |
| | | width: '100%', |
| | | height: '100%', |
| | | display: 'flex', |
| | | flexDirection: 'column', |