| | |
| | | import React, { useRef, useEffect, useState } from 'react'; |
| | | import * as THREE from 'three'; |
| | | import { useTranslate } from 'react-admin'; |
| | | import { useTranslate, useDataProvider } from 'react-admin'; |
| | | import { |
| | | Box, |
| | | CircularProgress, |
| | |
| | | Stack, |
| | | useTheme, |
| | | } from '@mui/material'; |
| | | import { useNotification } from '../../Notification'; |
| | | import AgvThree from './AgvThree'; |
| | | import { getAgvInfo } from '../../http'; |
| | | import BoolValueIcon from '../BoolValueIcon'; |
| | |
| | | } |
| | | |
| | | const AgvMain = (props) => { |
| | | const { curAgvNo, curAgvInfo: info } = props; |
| | | const { curAgvNo, curAgvInfo: info, fetchAgvInfo } = props; |
| | | const theme = useTheme(); |
| | | const translate = useTranslate(); |
| | | const dataProvider = useDataProvider(); |
| | | const notify = useNotification(); |
| | | const containerRef = useRef(); |
| | | const [loading, setLoading] = useState(true); |
| | | |
| | |
| | | |
| | | const handleReset = () => { |
| | | alert(1) |
| | | } |
| | | |
| | | const updateStatus = (status) => { |
| | | dataProvider.update('agv', { |
| | | id: info.agvId, |
| | | data: { |
| | | status: status === 0 ? 1 : 0 |
| | | } |
| | | }).then(({ data }) => { |
| | | fetchAgvInfo(curAgvNo); |
| | | notify.success(translate('common.response.success')); |
| | | }).catch((error) => { |
| | | notify.success(translate('common.response.fail')); |
| | | console.error(`Error: ${error.message}`); |
| | | }); |
| | | } |
| | | |
| | | return ( |
| | |
| | | flexDirection: 'column', |
| | | justifyContent: 'space-between', |
| | | }}> |
| | | <Box> |
| | | <Grid container spacing={2} style={{ marginTop: '0px' }}> |
| | | <Box sx={{ |
| | | height: "70%", |
| | | overflowY: 'auto' |
| | | }}> |
| | | <Grid container spacing={1.5} style={{ marginTop: '0px' }}> |
| | | <Grid item xs={12}> |
| | | <KeyValuePair label={translate('table.field.agv.uuid')} value={info?.agvNo} /> |
| | | </Grid> |
| | |
| | | </Grid> |
| | | </Box> |
| | | |
| | | <Grid container spacing={2} style={{ marginTop: '0px' }}> |
| | | <Grid item xs={12}> |
| | | <Stack spacing={2} mt={2}> |
| | | <ConfirmButton |
| | | label="page.map.action.reset" |
| | | color="primary" |
| | | variant="contained" |
| | | onConfirm={() => { |
| | | handleReset(); |
| | | }} |
| | | /> |
| | | {info && ( |
| | | info.status === 1 |
| | | ? <Button variant="contained" color="error" fullWidth> |
| | | {translate('page.map.action.disable')} |
| | | </Button> |
| | | : <Button variant="contained" fullWidth> |
| | | {translate('page.map.action.enable')} |
| | | </Button> |
| | | )} |
| | | </Stack> |
| | | <Box sx={{ |
| | | height: "30%", |
| | | display: 'flex', |
| | | flexDirection: 'column', |
| | | justifyContent: 'flex-end' |
| | | }}> |
| | | <Grid container spacing={2} style={{ marginTop: '0px' }}> |
| | | <Grid item xs={12}> |
| | | <Stack spacing={2} mt={2}> |
| | | <ConfirmButton |
| | | label="page.map.action.reset" |
| | | color="primary" |
| | | variant="contained" |
| | | onConfirm={() => { |
| | | handleReset(); |
| | | }} |
| | | /> |
| | | <ConfirmButton |
| | | label="page.map.action.reset" |
| | | color="primary" |
| | | variant="contained" |
| | | onConfirm={() => { |
| | | handleReset(); |
| | | }} |
| | | /> |
| | | {info && ( |
| | | info.status === 1 |
| | | ? <Button variant="contained" color="error" fullWidth onClick={() => { |
| | | updateStatus(info.status); |
| | | }}> |
| | | {translate('page.map.action.disable')} |
| | | </Button> |
| | | : <Button variant="contained" fullWidth onClick={() => { |
| | | updateStatus(info.status); |
| | | }}> |
| | | {translate('page.map.action.enable')} |
| | | </Button> |
| | | )} |
| | | </Stack> |
| | | </Grid> |
| | | </Grid> |
| | | </Grid> |
| | | </Box> |
| | | </Paper> |
| | | </Box> |
| | | </Box> |