mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
add search
This commit is contained in:
@@ -19,6 +19,7 @@ import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|||||||
import KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';
|
import KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';
|
||||||
import KeyboardArrowUpOutlinedIcon from '@mui/icons-material/KeyboardArrowUpOutlined';
|
import KeyboardArrowUpOutlinedIcon from '@mui/icons-material/KeyboardArrowUpOutlined';
|
||||||
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
|
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
|
||||||
|
import SearchIcon from '@mui/icons-material/Search';
|
||||||
import StarIcon from '@mui/icons-material/Star';
|
import StarIcon from '@mui/icons-material/Star';
|
||||||
import StarBorderOutlinedIcon from '@mui/icons-material/StarBorderOutlined';
|
import StarBorderOutlinedIcon from '@mui/icons-material/StarBorderOutlined';
|
||||||
import UnfoldMoreOutlinedIcon from '@mui/icons-material/UnfoldMoreOutlined';
|
import UnfoldMoreOutlinedIcon from '@mui/icons-material/UnfoldMoreOutlined';
|
||||||
@@ -32,9 +33,12 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
Grid2 as Grid,
|
Grid2 as Grid,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
InputAdornment,
|
||||||
List,
|
List,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
|
TextField,
|
||||||
|
ToggleButton,
|
||||||
Typography
|
Typography
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
@@ -81,6 +85,7 @@ const Devices = () => {
|
|||||||
const [deviceValueDialogOpen, setDeviceValueDialogOpen] = useState(false);
|
const [deviceValueDialogOpen, setDeviceValueDialogOpen] = useState(false);
|
||||||
const [showDeviceInfo, setShowDeviceInfo] = useState(false);
|
const [showDeviceInfo, setShowDeviceInfo] = useState(false);
|
||||||
const [selectedDevice, setSelectedDevice] = useState<number>();
|
const [selectedDevice, setSelectedDevice] = useState<number>();
|
||||||
|
const [search, setSearch] = useState('');
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@@ -591,8 +596,12 @@ const Devices = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const shown_data = onlyFav
|
const shown_data = onlyFav
|
||||||
? deviceData.nodes.filter((dv) => hasMask(dv.id, DeviceEntityMask.DV_FAVORITE))
|
? deviceData.nodes.filter(
|
||||||
: deviceData.nodes;
|
(dv) =>
|
||||||
|
hasMask(dv.id, DeviceEntityMask.DV_FAVORITE) &&
|
||||||
|
dv.id.slice(2).includes(search)
|
||||||
|
)
|
||||||
|
: deviceData.nodes.filter((dv) => dv.id.slice(2).includes(search));
|
||||||
|
|
||||||
const deviceIndex = coreData.devices.findIndex(
|
const deviceIndex = coreData.devices.findIndex(
|
||||||
(d) => d.id === device_select.state.id
|
(d) => d.id === device_select.state.id
|
||||||
@@ -615,47 +624,11 @@ const Devices = () => {
|
|||||||
border: '1px solid #177ac9'
|
border: '1px solid #177ac9'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box sx={{ border: '1px solid #177ac9' }}>
|
<Box sx={{ p: 1 }}>
|
||||||
<Typography noWrap variant="subtitle1" color="warning.main" sx={{ ml: 1 }}>
|
|
||||||
{coreData.devices[deviceIndex].n} (
|
|
||||||
{coreData.devices[deviceIndex].tn})
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<Grid container justifyContent="space-between">
|
<Grid container justifyContent="space-between">
|
||||||
<Typography sx={{ ml: 1 }} variant="subtitle2" color="grey">
|
<Typography noWrap variant="subtitle1" color="warning.main">
|
||||||
{LL.SHOWING() +
|
{coreData.devices[deviceIndex].n} (
|
||||||
' ' +
|
{coreData.devices[deviceIndex].tn})
|
||||||
shown_data.length +
|
|
||||||
'/' +
|
|
||||||
coreData.devices[deviceIndex].e +
|
|
||||||
' ' +
|
|
||||||
LL.ENTITIES(shown_data.length)}
|
|
||||||
<ButtonTooltip title={LL.DEVICE_DETAILS()}>
|
|
||||||
<IconButton onClick={() => setShowDeviceInfo(true)}>
|
|
||||||
<InfoOutlinedIcon color="primary" sx={{ fontSize: 18 }} />
|
|
||||||
</IconButton>
|
|
||||||
</ButtonTooltip>
|
|
||||||
{me.admin && (
|
|
||||||
<ButtonTooltip title={LL.CUSTOMIZATIONS()}>
|
|
||||||
<IconButton onClick={customize}>
|
|
||||||
<ConstructionIcon color="primary" sx={{ fontSize: 18 }} />
|
|
||||||
</IconButton>
|
|
||||||
</ButtonTooltip>
|
|
||||||
)}
|
|
||||||
<ButtonTooltip title={LL.EXPORT()}>
|
|
||||||
<IconButton onClick={handleDownloadCsv}>
|
|
||||||
<DownloadIcon color="primary" sx={{ fontSize: 18 }} />
|
|
||||||
</IconButton>
|
|
||||||
</ButtonTooltip>
|
|
||||||
<ButtonTooltip title={LL.FAVORITES()}>
|
|
||||||
<IconButton onClick={() => setOnlyFav(!onlyFav)}>
|
|
||||||
{onlyFav ? (
|
|
||||||
<StarIcon color="primary" sx={{ fontSize: 18 }} />
|
|
||||||
) : (
|
|
||||||
<StarBorderOutlinedIcon color="primary" sx={{ fontSize: 18 }} />
|
|
||||||
)}
|
|
||||||
</IconButton>
|
|
||||||
</ButtonTooltip>
|
|
||||||
</Typography>
|
</Typography>
|
||||||
<Grid justifyContent="flex-end">
|
<Grid justifyContent="flex-end">
|
||||||
<ButtonTooltip title={LL.CLOSE()}>
|
<ButtonTooltip title={LL.CLOSE()}>
|
||||||
@@ -665,6 +638,70 @@ const Devices = () => {
|
|||||||
</ButtonTooltip>
|
</ButtonTooltip>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
sx={{ width: '22ch' }}
|
||||||
|
placeholder={LL.SEARCH()}
|
||||||
|
onChange={(event) => {
|
||||||
|
setSearch(event.target.value);
|
||||||
|
}}
|
||||||
|
slotProps={{
|
||||||
|
input: {
|
||||||
|
startAdornment: (
|
||||||
|
<InputAdornment position="start">
|
||||||
|
<SearchIcon color="primary" sx={{ fontSize: 16 }} />
|
||||||
|
</InputAdornment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ButtonTooltip title={LL.DEVICE_DETAILS()}>
|
||||||
|
<IconButton onClick={() => setShowDeviceInfo(true)}>
|
||||||
|
<InfoOutlinedIcon color="primary" sx={{ fontSize: 18 }} />
|
||||||
|
</IconButton>
|
||||||
|
</ButtonTooltip>
|
||||||
|
{me.admin && (
|
||||||
|
<ButtonTooltip title={LL.CUSTOMIZATIONS()}>
|
||||||
|
<IconButton onClick={customize}>
|
||||||
|
<ConstructionIcon color="primary" sx={{ fontSize: 18 }} />
|
||||||
|
</IconButton>
|
||||||
|
</ButtonTooltip>
|
||||||
|
)}
|
||||||
|
<ButtonTooltip title={LL.EXPORT()}>
|
||||||
|
<IconButton onClick={handleDownloadCsv}>
|
||||||
|
<DownloadIcon color="primary" sx={{ fontSize: 18 }} />
|
||||||
|
</IconButton>
|
||||||
|
</ButtonTooltip>
|
||||||
|
|
||||||
|
<ButtonTooltip title={LL.FAVORITES()}>
|
||||||
|
<ToggleButton
|
||||||
|
value="1"
|
||||||
|
size="small"
|
||||||
|
selected={onlyFav}
|
||||||
|
onChange={() => {
|
||||||
|
setOnlyFav(!onlyFav);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{onlyFav ? (
|
||||||
|
<StarIcon color="primary" sx={{ fontSize: 18 }} />
|
||||||
|
) : (
|
||||||
|
<StarBorderOutlinedIcon color="primary" sx={{ fontSize: 18 }} />
|
||||||
|
)}{' '}
|
||||||
|
</ToggleButton>
|
||||||
|
</ButtonTooltip>
|
||||||
|
|
||||||
|
<span style={{ color: 'grey', fontSize: '12px' }}>
|
||||||
|
|
||||||
|
{LL.SHOWING() +
|
||||||
|
' ' +
|
||||||
|
shown_data.length +
|
||||||
|
'/' +
|
||||||
|
coreData.devices[deviceIndex].e +
|
||||||
|
' ' +
|
||||||
|
LL.ENTITIES(shown_data.length)}
|
||||||
|
</span>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
|
|||||||
Reference in New Issue
Block a user