mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
use numberValue() to prevent web errors with integers
This commit is contained in:
@@ -203,7 +203,7 @@ const CustomEntitiesDialog = ({
|
|||||||
margin="normal"
|
margin="normal"
|
||||||
sx={{ width: '11ch' }}
|
sx={{ width: '11ch' }}
|
||||||
type="number"
|
type="number"
|
||||||
value={editItem.offset}
|
value={numberValue(editItem.offset)}
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -288,21 +288,16 @@ const CustomEntitiesDialog = ({
|
|||||||
{editItem.value_type === DeviceValueType.STRING &&
|
{editItem.value_type === DeviceValueType.STRING &&
|
||||||
editItem.device_id !== '0' && (
|
editItem.device_id !== '0' && (
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextField
|
<ValidatedTextField
|
||||||
|
fieldErrors={fieldErrors}
|
||||||
name="factor"
|
name="factor"
|
||||||
label="Bytes"
|
label="Bytes"
|
||||||
value={editItem.factor}
|
value={numberValue(editItem.factor)}
|
||||||
|
sx={{ width: '11ch' }}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
margin="normal"
|
margin="normal"
|
||||||
type="number"
|
type="number"
|
||||||
slotProps={{
|
|
||||||
htmlInput: {
|
|
||||||
min: '1',
|
|
||||||
max: String(256 - editItem.offset),
|
|
||||||
step: '1'
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import Grid from '@mui/material/Grid2';
|
|||||||
|
|
||||||
import { dialogStyle } from 'CustomTheme';
|
import { dialogStyle } from 'CustomTheme';
|
||||||
import { useI18nContext } from 'i18n/i18n-react';
|
import { useI18nContext } from 'i18n/i18n-react';
|
||||||
import { updateValue } from 'utils';
|
import { numberValue, updateValue } from 'utils';
|
||||||
|
|
||||||
import EntityMaskToggle from './EntityMaskToggle';
|
import EntityMaskToggle from './EntityMaskToggle';
|
||||||
import { DeviceEntityMask } from './types';
|
import { DeviceEntityMask } from './types';
|
||||||
@@ -127,8 +127,8 @@ const CustomizationsDialog = ({
|
|||||||
<TextField
|
<TextField
|
||||||
name="mi"
|
name="mi"
|
||||||
label={LL.MIN()}
|
label={LL.MIN()}
|
||||||
value={editItem.mi}
|
value={numberValue(editItem.mi)}
|
||||||
sx={{ width: '8ch' }}
|
sx={{ width: '11ch' }}
|
||||||
type="number"
|
type="number"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
/>
|
/>
|
||||||
@@ -137,8 +137,8 @@ const CustomizationsDialog = ({
|
|||||||
<TextField
|
<TextField
|
||||||
name="ma"
|
name="ma"
|
||||||
label={LL.MAX()}
|
label={LL.MAX()}
|
||||||
value={editItem.ma}
|
value={numberValue(editItem.ma)}
|
||||||
sx={{ width: '8ch' }}
|
sx={{ width: '11ch' }}
|
||||||
type="number"
|
type="number"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ const SensorsAnalogDialog = ({
|
|||||||
fieldErrors={fieldErrors}
|
fieldErrors={fieldErrors}
|
||||||
name="g"
|
name="g"
|
||||||
label="GPIO"
|
label="GPIO"
|
||||||
sx={{ width: '15ch' }}
|
sx={{ width: '11ch' }}
|
||||||
value={numberValue(editItem.g)}
|
value={numberValue(editItem.g)}
|
||||||
type="number"
|
type="number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -157,7 +157,7 @@ const SensorsAnalogDialog = ({
|
|||||||
label={LL.OFFSET()}
|
label={LL.OFFSET()}
|
||||||
value={numberValue(editItem.o)}
|
value={numberValue(editItem.o)}
|
||||||
type="number"
|
type="number"
|
||||||
sx={{ width: '15ch' }}
|
sx={{ width: '11ch' }}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
@@ -178,7 +178,7 @@ const SensorsAnalogDialog = ({
|
|||||||
label={LL.STARTVALUE()}
|
label={LL.STARTVALUE()}
|
||||||
value={numberValue(editItem.o)}
|
value={numberValue(editItem.o)}
|
||||||
type="number"
|
type="number"
|
||||||
sx={{ width: '15ch' }}
|
sx={{ width: '11ch' }}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
@@ -193,7 +193,7 @@ const SensorsAnalogDialog = ({
|
|||||||
name="f"
|
name="f"
|
||||||
label={LL.FACTOR()}
|
label={LL.FACTOR()}
|
||||||
value={numberValue(editItem.f)}
|
value={numberValue(editItem.f)}
|
||||||
sx={{ width: '15ch' }}
|
sx={{ width: '11ch' }}
|
||||||
type="number"
|
type="number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
@@ -210,7 +210,7 @@ const SensorsAnalogDialog = ({
|
|||||||
name="o"
|
name="o"
|
||||||
label={LL.VALUE(0)}
|
label={LL.VALUE(0)}
|
||||||
value={numberValue(editItem.o)}
|
value={numberValue(editItem.o)}
|
||||||
fullWidth
|
sx={{ width: '11ch' }}
|
||||||
type="number"
|
type="number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
@@ -281,7 +281,7 @@ const SensorsAnalogDialog = ({
|
|||||||
value={numberValue(editItem.f)}
|
value={numberValue(editItem.f)}
|
||||||
type="number"
|
type="number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
sx={{ width: '15ch' }}
|
sx={{ width: '11ch' }}
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
input: {
|
input: {
|
||||||
@@ -299,7 +299,7 @@ const SensorsAnalogDialog = ({
|
|||||||
label={LL.DUTY_CYCLE()}
|
label={LL.DUTY_CYCLE()}
|
||||||
value={numberValue(editItem.o)}
|
value={numberValue(editItem.o)}
|
||||||
type="number"
|
type="number"
|
||||||
sx={{ width: '15ch' }}
|
sx={{ width: '11ch' }}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ const SensorsTemperatureDialog = ({
|
|||||||
name="o"
|
name="o"
|
||||||
label={LL.OFFSET()}
|
label={LL.OFFSET()}
|
||||||
value={numberValue(editItem.o)}
|
value={numberValue(editItem.o)}
|
||||||
sx={{ width: '12ch' }}
|
sx={{ width: '11ch' }}
|
||||||
type="number"
|
type="number"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={updateFormValue}
|
onChange={updateFormValue}
|
||||||
|
|||||||
Reference in New Issue
Block a user