| | |
| | | SelectColumnsButton, |
| | | EditButton, |
| | | FilterButton, |
| | | CreateButton, |
| | | useRefresh, |
| | | ExportButton, |
| | | BulkDeleteButton, |
| | | WrapperField, |
| | |
| | | Pagination, |
| | | ListToolbar, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { Box, Typography, LinearProgress, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import AgvCreate from "./AgvCreate"; |
| | | import AgvPanel from "./AgvPanel"; |
| | |
| | | import MyExportButton from '../components/MyExportButton'; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | | import MyField from "../components/MyField"; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE } from '@/config/setting'; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE, CUSTOM_PAGES_DATA_INTERVAL } from '@/config/setting'; |
| | | import * as Common from '@/utils/common'; |
| | | import { ImageList } from "./GridList"; |
| | | import { AgvListFilter } from "./AgvListFilter"; |
| | | |
| | | export const AgvGrid = () => { |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | |
| | | return ( |
| | | <> |
| | | <ListBase perPage={50} sort={{ field: "uuid", order: "asc" }}> |
| | | <ListBase perPage={50} sort={{ field: "create_time", order: "asc" }}> |
| | | <AgvGridLayout |
| | | setCreateDialog={setCreateDialog} |
| | | /> |
| | |
| | | } |
| | | |
| | | const AgvGridLayout = ({ setCreateDialog }) => { |
| | | const { data, isPending, filterValues } = useListContext(); |
| | | const { data, isPending, filterValues, refetch } = useListContext(); |
| | | const hasFilters = filterValues && Object.keys(filterValues).length > 0; |
| | | |
| | | if (isPending) return null; |
| | | React.useEffect(() => { |
| | | const intervalId = setInterval(() => { |
| | | refetch(); |
| | | }, CUSTOM_PAGES_DATA_INTERVAL); |
| | | |
| | | return () => clearInterval(intervalId); |
| | | }, [refetch]); |
| | | |
| | | if (isPending) return <LinearProgress />; |
| | | if (!data?.length && !hasFilters) return <EmptyData onClick={() => { setCreateDialog(true) }} />; |
| | | |
| | | return ( |
| | |
| | | <MyExportButton /> |
| | | </TopToolbar> |
| | | )} |
| | | perPage={25} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='agv' |