diff --git a/interface/src/project/SettingsCustomization.tsx b/interface/src/project/SettingsCustomization.tsx index e392cd03e..805210275 100644 --- a/interface/src/project/SettingsCustomization.tsx +++ b/interface/src/project/SettingsCustomization.tsx @@ -10,8 +10,8 @@ import { DialogContent, DialogTitle, ToggleButton, - IconButton, - ToggleButtonGroup + ToggleButtonGroup, + Tooltip } from '@mui/material'; import { Table } from '@table-library/react-table-library/table'; @@ -37,7 +37,7 @@ import * as EMSESP from './api'; import { extractErrorMessage } from '../utils'; -import { DeviceShort, Devices, DeviceEntity, DeviceEntityMask } from './types'; +import { DeviceShort, Devices, DeviceEntity } from './types'; const SettingsCustomization: FC = () => { const { enqueueSnackbar } = useSnackbar(); @@ -47,7 +47,7 @@ const SettingsCustomization: FC = () => { const [errorMessage, setErrorMessage] = useState(); const [selectedDevice, setSelectedDevice] = useState(0); const [confirmReset, setConfirmReset] = useState(false); - const [selectedFilters, setSelectedFilters] = useState(DeviceEntityMask.DV_FAVORITE); + const [selectedFilters, setSelectedFilters] = useState(15); // eslint-disable-next-line const [masks, setMasks] = useState(() => ['']); @@ -200,23 +200,7 @@ const SettingsCustomization: FC = () => { return ( <> - Select a device and customize each of its entities using the options: - - -  mark it as favorite to be listed at the top of the Dashboard - - - -  make it read-only, only if it has write operation available - - - -  excluded it from MQTT and API outputs - - - -  hide it from the Dashboard - + Select a device and customize each of its entities using the options. { return; } - const hasMask = (de: DeviceEntity) => { - return de.m & selectedFilters; - return (de.m & DeviceEntityMask.DV_FAVORITE) === DeviceEntityMask.DV_FAVORITE; - }; - - const setMask = (de: DeviceEntity, newMask: string[]) => { + const getMaskNumber = (newMask: string[]) => { var new_mask = 0; for (let entry of newMask) { new_mask |= Number(entry); } - de.m = new_mask; - setMasks(newMask); + return new_mask; }; - const getMask = (de: DeviceEntity) => { + const getMaskString = (m: number) => { var new_masks = []; - if ((de.m & 1) === 1 || de.id === '') { + if ((m & 1) === 1) { new_masks.push('1'); } - if ((de.m & 2) === 2) { + if ((m & 2) === 2) { new_masks.push('2'); } - if ((de.m & 4) === 4 && de.w) { + if ((m & 4) === 4) { new_masks.push('4'); } - if ((de.m & 8) === 8) { + if ((m & 8) === 8) { new_masks.push('8'); } - return new_masks; }; return ( <> - setSelectedDevice(8)}> - - - - { - // setMask(de, mask); - }} - > - - - - - - - - - - - - - + + Apply filter:  + { + setSelectedFilters(getMaskNumber(mask)); + }} + > + + + + + + + + + + + + + + + + + + + + + + hasMask(de)) }} + data={{ nodes: deviceEntities.filter((de) => de.m & selectedFilters || !selectedFilters) }} theme={entities_theme} sort={entity_sort} - layout={{ custom: true, horizontalScroll: true }} + layout={{ custom: true }} > {(tableList: any) => ( <> @@ -369,9 +353,10 @@ const SettingsCustomization: FC = () => { { - setMask(de, mask); + de.m = getMaskNumber(mask); + setMasks(['']); }} > @@ -438,18 +423,12 @@ const SettingsCustomization: FC = () => { const content = () => { return ( -
+ <> Device Entities {renderDeviceList()} -
- {renderDeviceData()} -
+ {renderDeviceData()} @@ -470,7 +449,7 @@ const SettingsCustomization: FC = () => { {renderResetDialog()} -
+ ); };