| | |
| | | const theme = useTheme(); |
| | | const themeMode = theme.palette.mode; |
| | | |
| | | let json = parseJson(data); |
| | | const [json, setJson] = useState(null); |
| | | |
| | | useEffect(() => { |
| | | if (data) { |
| | | setJson(parseJson(data)); |
| | | } |
| | | }, [data]); |
| | | |
| | | return ( |
| | | <Paper |
| | |
| | | import React from 'react'; |
| | | import React, { useEffect } from 'react'; |
| | | import { useTranslate } from "react-admin"; |
| | | import { useForm, Controller } from 'react-hook-form'; |
| | | import { |
| | |
| | | { value: 'STA_TO_STA', label: translate('page.map.insight.control.type.STA_TO_STA') }, |
| | | ]; |
| | | |
| | | useEffect(() => { |
| | | reset(); |
| | | }, [curAgvNo]); |
| | | |
| | | const onSubmit = (data) => { |
| | | if (curAgvNo) { |
| | | console.log(data); |
| | |
| | | |
| | | addObject(agvGroup); |
| | | |
| | | three.rePerspective(350, 450); |
| | | three?.rePerspective(350, 450); |
| | | |
| | | }).catch((error) => { |
| | | console.error(error); |
| | |
| | | } |
| | | |
| | | const AgvMain = (props) => { |
| | | const { data, curAgvNo, setCurAgvNo } = props; |
| | | const { curAgvNo, setCurAgvNo, setJsonData } = props; |
| | | const theme = useTheme(); |
| | | const translate = useTranslate(); |
| | | const containerRef = useRef(); |
| | |
| | | const [info, setInfo] = useState(null); |
| | | |
| | | useEffect(() => { |
| | | if (data) { |
| | | getAgvInfo(data.no, (response) => { |
| | | if (curAgvNo) { |
| | | getAgvInfo(curAgvNo, (response) => { |
| | | setInfo(response); |
| | | setCurAgvNo(data.no); |
| | | }); |
| | | } |
| | | }, [data]); |
| | | }, [curAgvNo]); |
| | | |
| | | useEffect(() => { |
| | | if (info) { |
| | | // console.log(info); |
| | | setJsonData(info); |
| | | endThree(); |
| | | setLoading(true); |
| | | setTimeout(() => { |
| | |
| | | |
| | | const [activeTab, setActiveTab] = useState(0); |
| | | const [curAgvNo, setCurAgvNo] = useState(null); |
| | | const [jsonData, setJsonData] = useState(null); |
| | | |
| | | const handleTabChange = (event, newValue) => { |
| | | setActiveTab(newValue); |
| | | }; |
| | | |
| | | useEffect(() => { |
| | | if (curAgvNo) { |
| | | setTitle(translate('page.map.devices.agv') + ' - ' + curAgvNo); |
| | | if (sprite) { |
| | | const agvNo = sprite.data.no; |
| | | if (agvNo) { |
| | | setCurAgvNo(agvNo); |
| | | setTitle(translate('page.map.devices.agv') + ' - ' + agvNo); |
| | | } |
| | | } |
| | | |
| | | return () => { |
| | | setTitle(null); |
| | | setJsonData(null); |
| | | } |
| | | }, [curAgvNo]) |
| | | }, [sprite]) |
| | | |
| | | return ( |
| | | <Box sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}> |
| | |
| | | <Box flex={1} pt={2}> |
| | | {activeTab === 0 && ( |
| | | <AgvMain |
| | | data={sprite?.data} |
| | | curAgvNo={curAgvNo} |
| | | setCurAgvNo={setCurAgvNo} |
| | | setJsonData={setJsonData} |
| | | /> |
| | | )} |
| | | {activeTab === 1 && ( |
| | | <AgvControl |
| | | data={sprite?.data} |
| | | curAgvNo={curAgvNo} |
| | | /> |
| | | )} |
| | | {activeTab === 2 && ( |
| | | <JsonShow |
| | | data={sprite?.data} |
| | | data={jsonData || sprite?.data} |
| | | height={550} |
| | | /> |
| | | )} |