mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
remove invalid UOMs
This commit is contained in:
@@ -129,12 +129,10 @@ function formatValue(value: any, uom: number, digit: number) {
|
||||
case DeviceValueUOM.MINUTES:
|
||||
return value ? formatDuration(value) : '0 minutes';
|
||||
case DeviceValueUOM.NONE:
|
||||
case DeviceValueUOM.LIST:
|
||||
if (typeof value === 'number') {
|
||||
return new Intl.NumberFormat().format(value);
|
||||
}
|
||||
return value;
|
||||
case DeviceValueUOM.NUM:
|
||||
return new Intl.NumberFormat().format(value);
|
||||
case DeviceValueUOM.BOOLEAN:
|
||||
return value ? 'on' : 'off';
|
||||
case DeviceValueUOM.DEGREES:
|
||||
return (
|
||||
new Intl.NumberFormat(undefined, {
|
||||
|
||||
@@ -92,9 +92,6 @@ export enum DeviceValueUOM {
|
||||
KB,
|
||||
SECONDS,
|
||||
DBM,
|
||||
NUM,
|
||||
BOOLEAN,
|
||||
LIST,
|
||||
MV
|
||||
}
|
||||
|
||||
@@ -114,8 +111,5 @@ export const DeviceValueUOM_s = [
|
||||
'KB',
|
||||
'seconds',
|
||||
'dBm',
|
||||
'number',
|
||||
'on/off',
|
||||
'',
|
||||
'mV'
|
||||
];
|
||||
|
||||
@@ -51,7 +51,7 @@ class ValueForm extends React.Component<ValueFormProps> {
|
||||
>
|
||||
<DialogTitle id="user-form-dialog-title">Change Value</DialogTitle>
|
||||
<DialogContent dividers>
|
||||
{devicevalue.u === DeviceValueUOM.LIST && (
|
||||
{devicevalue.l && (
|
||||
<TextField
|
||||
id="outlined-select-value"
|
||||
select
|
||||
@@ -66,34 +66,19 @@ class ValueForm extends React.Component<ValueFormProps> {
|
||||
))}
|
||||
</TextField>
|
||||
)}
|
||||
{devicevalue.u !== DeviceValueUOM.BOOLEAN &&
|
||||
devicevalue.u !== DeviceValueUOM.LIST && (
|
||||
<OutlinedInput
|
||||
id="value"
|
||||
value={devicevalue.v}
|
||||
autoFocus
|
||||
fullWidth
|
||||
onChange={handleValueChange('v')}
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
{DeviceValueUOM_s[devicevalue.u]}
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{devicevalue.u === DeviceValueUOM.BOOLEAN && (
|
||||
<TextField
|
||||
id="selected-value"
|
||||
select
|
||||
{!devicevalue.l && (
|
||||
<OutlinedInput
|
||||
id="value"
|
||||
value={devicevalue.v}
|
||||
autoFocus
|
||||
fullWidth
|
||||
onChange={handleValueChange('v')}
|
||||
variant="outlined"
|
||||
>
|
||||
<MenuItem value="true">on</MenuItem>
|
||||
<MenuItem value="false">off</MenuItem>
|
||||
</TextField>
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
{DeviceValueUOM_s[devicevalue.u]}
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<FormHelperText>{devicevalue.n}</FormHelperText>
|
||||
<Box color="warning.main" p={0} pl={0} pr={0} mt={4} mb={0}>
|
||||
|
||||
Reference in New Issue
Block a user