| | |
| | | import React from "react"; |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { useTranslate } from "react-admin"; |
| | | import { Fab } from '@mui/material'; |
| | | import { |
| | | Fab, |
| | | Box, |
| | | Backdrop, |
| | | useTheme, |
| | | } from '@mui/material'; |
| | | import CropFreeIcon from '@mui/icons-material/CropFree'; |
| | | import CircularProgress from '@mui/material/CircularProgress'; |
| | | import * as Tool from '../tool'; |
| | | |
| | | const AreaFab = ({ active = false, onToggle }) => { |
| | | const AreaFab = (props) => { |
| | | const { curZone, showAreas, setShowAreas, notify } = props; |
| | | const translate = useTranslate(); |
| | | const theme = useTheme(); // theme.palette.primary.main |
| | | |
| | | const [loading, setLoading] = React.useState(false); |
| | | |
| | | const handleClick = () => { |
| | | if (showAreas) { |
| | | setShowAreas(false); |
| | | // Tool.hideRoutes(curZone, setShowAreas); |
| | | } else { |
| | | setShowAreas(true); |
| | | // Tool.showRoutes(curZone, setShowAreas, setLoading); |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <Fab |
| | | variant="extended" |
| | | color={active ? 'primary' : 'default'} |
| | | size="small" |
| | | onClick={onToggle} |
| | | > |
| | | <CropFreeIcon /> |
| | | {translate('page.map.devices.area')} |
| | | </Fab> |
| | | ); |
| | | }; |
| | | <> |
| | | <Fab |
| | | variant="extended" |
| | | color={showAreas ? 'primary' : 'default'} |
| | | size="small" |
| | | disabled={loading} |
| | | onClick={handleClick} |
| | | sx={{ |
| | | minWidth: 100 |
| | | }} |
| | | > |
| | | <CropFreeIcon /> |
| | | {translate('page.map.action.area')} |
| | | {loading && ( |
| | | <> |
| | | <svg width={0} height={0}> |
| | | <defs> |
| | | <linearGradient id="my_gradient" x1="0%" y1="0%" x2="0%" y2="100%"> |
| | | <stop offset="0%" stopColor="#e01cd5" /> |
| | | <stop offset="100%" stopColor="#1CB5E0" /> |
| | | </linearGradient> |
| | | </defs> |
| | | </svg> |
| | | <CircularProgress size={18} thickness={8} sx={{ 'svg circle': { stroke: 'url(#my_gradient)' } }} /> |
| | | </> |
| | | )} |
| | | </Fab> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | export default AreaFab; |
| | | export default AreaFab; |