From 785c745248b2db40b9264c7eea89eee703fe3f2d Mon Sep 17 00:00:00 2001 From: Tristan Teufel Date: Thu, 28 Dec 2023 17:02:11 +0100 Subject: [PATCH] updates --- src/app/ChannelsForType.tsx | 13 ++- src/app/FloorControl.tsx | 1 - src/app/ThermostatControl.tsx | 151 ++++++++++++++------------- src/app/components/ChannelHeader.tsx | 3 + 4 files changed, 89 insertions(+), 79 deletions(-) diff --git a/src/app/ChannelsForType.tsx b/src/app/ChannelsForType.tsx index 90dadc8..f1dd30c 100644 --- a/src/app/ChannelsForType.tsx +++ b/src/app/ChannelsForType.tsx @@ -19,12 +19,11 @@ import { Icon } from '@iconify/react'; interface ExpandMoreProps { - expand: boolean; + expanded: boolean; } - -const ExpandMore = styled(Icon)(({ expand }: ExpandMoreProps) => ({ - transform: !expand ? 'rotate(0deg)' : 'rotate(180deg)', +const ExpandMore = styled(Icon)(({ expanded }) => ({ + transform: expanded ? 'rotate(180deg)' : 'rotate(0deg)', marginLeft: 'auto', transition: 'transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms', padding: '5px', @@ -76,7 +75,7 @@ export const ChannelsForType: React.FC = ({ const [hasTransitionExited, setHasTransitionExited] = useState< boolean - >(false); + >(true); const [expanded, setExpanded] = useState(false); const handleExpandClick = () => setExpanded(!expanded); @@ -85,7 +84,7 @@ export const ChannelsForType: React.FC = ({ handleExpandClick()} disableRipple={true} > @@ -101,7 +100,7 @@ export const ChannelsForType: React.FC = ({ > {t(channelType)} - + {hasTransitionExited ? : null} diff --git a/src/app/FloorControl.tsx b/src/app/FloorControl.tsx index f6c6862..53bcdc6 100644 --- a/src/app/FloorControl.tsx +++ b/src/app/FloorControl.tsx @@ -35,7 +35,6 @@ export const FloorControl = (props: FloorControlProps) => { return ( - diff --git a/src/app/ThermostatControl.tsx b/src/app/ThermostatControl.tsx index 264d407..cc0db95 100644 --- a/src/app/ThermostatControl.tsx +++ b/src/app/ThermostatControl.tsx @@ -1,11 +1,4 @@ -import { - Box, - Button, - CardContent, - CardHeader, - Slider, - Typography, -} from '@mui/material'; +import { Box, Button, CardContent, Slider, Typography } from '@mui/material'; import { HeatingClimateControlTransceiverChannel, @@ -13,7 +6,6 @@ import { } from '../hooks/useApi'; import { useEffect, useState } from 'react'; import { CircularProgressWithLabel } from './components/CircularProgressWithLabel'; -import { TypographyWithEllipsis } from './components/TypographyWithEllipsis'; import { StyledHeaderIcon, StyledIconButton } from './components/StyledIcons'; import { ChannelHeader } from './components/ChannelHeader'; @@ -85,6 +77,81 @@ export const ThermostatControl = ({ channel }: ControlProps) => { } }; + const getHumidity = () => { + return datapoints?.HUMIDITY ? ( + + + + {Number(datapoints?.HUMIDITY)}% + + + ) : null; + }; + + const getValveLevel = () => { + return (datapoints?.LEVEL ? ( + + + + + ) : null) + } + + const getActualTemperature = () => { + return ( + { + setPointMode(Number(pointMode ? '0' : '1')); + setValueMutation.mutateAsync({ + interface: interfaceName, + address, + valueKey: 'CONTROL_MODE', + type: 'double', + value: pointMode ? 0 : 1, + }); + }} + /> + + {datapoints?.ACTUAL_TEMPERATURE + ? Number(datapoints?.ACTUAL_TEMPERATURE).toLocaleString( + 'de-DE', + { + maximumFractionDigits: 2, + minimumFractionDigits: 2, + } + ) + : null} + °C + + ) + } + + + const getTargetTemperature = () => { + return ( + + + {pointTemp.toLocaleString('de-DE', { + maximumFractionDigits: 2, + minimumFractionDigits: 2, + })} + °C + + ) + } + return ( { }} > - {datapoints?.HUMIDITY ? ( - - - - {Number(datapoints?.HUMIDITY)}% - - - ) : null} + {getHumidity()} - {datapoints?.LEVEL ? ( - - - - - ) : null} + {getValveLevel()} { mt: '5px', }} > - - { - setPointMode(Number(pointMode ? '0' : '1')); - setValueMutation.mutateAsync({ - interface: interfaceName, - address, - valueKey: 'CONTROL_MODE', - type: 'double', - value: pointMode ? 0 : 1, - }); - }} - /> - - {datapoints?.ACTUAL_TEMPERATURE - ? Number(datapoints?.ACTUAL_TEMPERATURE).toLocaleString( - 'de-DE', - { - maximumFractionDigits: 2, - minimumFractionDigits: 2, - } - ) - : null} - °C - - + {getActualTemperature()} - - - - {pointTemp.toLocaleString('de-DE', { - maximumFractionDigits: 2, - minimumFractionDigits: 2, - })} - °C - - + {getTargetTemperature()} diff --git a/src/app/components/ChannelHeader.tsx b/src/app/components/ChannelHeader.tsx index ebbb98c..7b52ec1 100644 --- a/src/app/components/ChannelHeader.tsx +++ b/src/app/components/ChannelHeader.tsx @@ -19,6 +19,9 @@ export const ChannelHeader = ({ return (