| | |
| | | import * as Http from './http'; |
| | | import WebSocketClient from './websocket' |
| | | import ConfirmButton from "../page/components/ConfirmButton"; |
| | | import { FitScreen, AltRoute } from '@mui/icons-material'; |
| | | import { FitScreen, AltRoute, RotateRight } from '@mui/icons-material'; |
| | | import MapSearch from "./header/MapSearch"; |
| | | import { startupOrShutdown } from "./http"; |
| | | import PulseSignal from "../page/components/PulseSignal"; |
| | | import FakeFab from "./header/FakeFab"; |
| | | |
| | | let player; |
| | | let websocket; |
| | |
| | | const [app, setApp] = useState(null); |
| | | const [mapContainer, setMapContainer] = useState(null); |
| | | |
| | | const [mode, setMode] = useState(null); |
| | | const [mode, setMode] = useState(MAP_MODE.OBSERVER_MODE); |
| | | const [dataFetched, setDataFetched] = useState(false); |
| | | const [insightVisible, setInsightVisible] = useState(false); |
| | | const [deviceVisible, setDeviceVisible] = useState(false); |
| | |
| | | const [batchSelectionVisible, setBatchSelectionVisible] = useState(false); |
| | | |
| | | const [curSprite, setCurSprite] = useState(null); |
| | | const prevCurSpriteRef = useRef(); |
| | | const [batchSprites, setBatchSprites] = useState([]); |
| | | |
| | | const [rcsStatus, setRcsStatus] = useState(null); |
| | |
| | | Http.setMapContainer(player.mapContainer); |
| | | websocket = new WebSocketClient('/ws/map/websocket'); |
| | | |
| | | await Http.fetchMapData(curZone, setRcsStatus); |
| | | await Http.fetchMapData(curZone, setRcsStatus, setCurSprite); |
| | | websocket.connect(); |
| | | websocket.onMessage = (wsMsg) => { |
| | | Tool.generateDynamicGraphic(curZone, JSON.parse(wsMsg), setCurSprite); |
| | | } |
| | | |
| | | player.rotateMap(localStorage.getItem('mapRotation')); |
| | | setTimeout(() => { |
| | | notify.info(translate('page.map.welcome')); |
| | | player.adaptScreen(); |
| | | setDataFetched(true); |
| | | setMode(MAP_MODE.OBSERVER_MODE); |
| | | }, 200) |
| | | } |
| | | initialize(); |
| | |
| | | if (!mapContainer) { |
| | | return; |
| | | } |
| | | prevCurSpriteRef.current = curSprite; |
| | | if (curSprite && prevCurSprite !== curSprite) { |
| | | Tool.removeSelectedEffect(); |
| | | } |
| | | Tool.removeSelectedEffect(); |
| | | if (curSprite) { |
| | | if (mode === MAP_MODE.OBSERVER_MODE) { |
| | | Tool.showSelectedEffect(curSprite); |
| | |
| | | setSettingsVisible(false); |
| | | } |
| | | }, [curSprite]); |
| | | const prevCurSprite = prevCurSpriteRef.current; |
| | | |
| | | // watch batchSprites |
| | | React.useEffect(() => { |
| | |
| | | <Box sx={{ mr: 2, display: 'flex', alignItems: 'center' }}> |
| | | <PulseSignal |
| | | negative |
| | | negativeColor = '#a4b0be' |
| | | negativeColor='#a4b0be' |
| | | flag={rcsStatus} |
| | | width={12} |
| | | /> |
| | |
| | | }} |
| | | > |
| | | {mode !== MAP_MODE.MOVABLE_MODE && ( |
| | | <Fab |
| | | variant="extended" |
| | | color={showRoutes ? 'primary' : 'default'} |
| | | size="small" |
| | | onClick={() => { |
| | | showRoutes ? Tool.hideRoutes(curZone, setShowRoutes) : Tool.showRoutes(curZone, setShowRoutes) |
| | | }} |
| | | > |
| | | <AltRoute /> |
| | | </Fab> |
| | | <> |
| | | <Fab |
| | | variant="extended" |
| | | color={showRoutes ? 'primary' : 'default'} |
| | | size="small" |
| | | onClick={() => { |
| | | showRoutes ? Tool.hideRoutes(curZone, setShowRoutes) : Tool.showRoutes(curZone, setShowRoutes) |
| | | }} |
| | | > |
| | | <AltRoute /> |
| | | </Fab> |
| | | <FakeFab |
| | | /> |
| | | </> |
| | | )} |
| | | <Fab |
| | | variant="extended" |
| | | color="primary" |
| | | size="small" |
| | | onClick={() => { |
| | | player.rotateMap(Math.PI / 2); |
| | | }} |
| | | > |
| | | <RotateRight /> |
| | | {/* {translate('page.map.action.adapt')} */} |
| | | </Fab> |
| | | <Fab |
| | | variant="extended" |
| | | color="primary" |
| | | size="small" |
| | | onClick={() => { |
| | | player.adaptScreen(); |
| | | }} |
| | | > |