From d3002ce41532cb7912b8775d10c4036e3368af61 Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 29 Mar 2022 18:32:47 +0200 Subject: [PATCH] show all mask icons --- interface/src/project/DashboardData.tsx | 65 ++++++++++++------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/interface/src/project/DashboardData.tsx b/interface/src/project/DashboardData.tsx index ba589b513..a67b05c9c 100644 --- a/interface/src/project/DashboardData.tsx +++ b/interface/src/project/DashboardData.tsx @@ -39,6 +39,8 @@ import SaveIcon from '@mui/icons-material/Save'; import RemoveIcon from '@mui/icons-material/RemoveCircleOutline'; import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder'; import PlayArrowIcon from '@mui/icons-material/PlayArrow'; +import EditOffOutlinedIcon from '@mui/icons-material/EditOffOutlined'; +import CommentsDisabledOutlinedIcon from '@mui/icons-material/CommentsDisabledOutlined'; import DeviceIcon from './DeviceIcon'; @@ -64,7 +66,8 @@ import { AnalogType, AnalogTypeNames, Sensor, - Analog + Analog, + DeviceEntityMask } from './types'; const StyledTableCell = styled(TableCell)(({ theme }) => ({ @@ -487,39 +490,25 @@ const DashboardData: FC = () => { return; } + const hasMask = (entityName: string, mask: number) => (parseInt(entityName.slice(0, 2), 16) & mask) === mask; + const sendCommand = (dv: DeviceValue) => { - if (dv.c && me.admin) { + if (dv.c && me.admin && !hasMask(dv.n, DeviceEntityMask.DV_READONLY)) { setDeviceValue(dv); } }; - const renderNameCell = (dv: DeviceValue) => { - var mask = Number(dv.n.slice(0, 2)); - var name = dv.n.slice(2); - if (dv.v === undefined && dv.c) { - return ( - - {name}  - - - ); - } - - if ((mask & 8) === 8) { - return ( - - {name}  - - - ); - } - - return ( - - {name} - - ); - }; + const renderNameCell = (dv: DeviceValue) => ( + <> + {dv.n.slice(2)}  + {hasMask(dv.n, DeviceEntityMask.DV_FAVORITE) && } + {hasMask(dv.n, DeviceEntityMask.DV_READONLY) && } + {hasMask(dv.n, DeviceEntityMask.DV_API_MQTT_EXCLUDE) && ( + + )} + {dv.v === undefined && dv.c && } + + ); return ( <> @@ -536,17 +525,27 @@ const DashboardData: FC = () => { {deviceData.data.map((dv, i) => ( - sendCommand(dv)}> + sendCommand(dv)} + // sx={ + // hasMask(dv.n, DeviceEntityMask.DV_FAVORITE) + // ? { backgroundColor: '#334900' } + // : { backgroundColor: 'black' } + // } + > - {dv.c && me.admin && ( + {dv.c && me.admin && !hasMask(dv.n, DeviceEntityMask.DV_READONLY) && ( )} - {renderNameCell(dv)} + + {renderNameCell(dv)} + {formatValue(dv.v, dv.u)} - + ))}