mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
Web selectbox for enum commands (like bool)
This commit is contained in:
@@ -125,6 +125,7 @@ function formatValue(value: any, uom: number) {
|
||||
case DeviceValueUOM.MINUTES:
|
||||
return value ? formatDuration(value) : '0 minutes';
|
||||
case DeviceValueUOM.NONE:
|
||||
case DeviceValueUOM.LIST:
|
||||
return value;
|
||||
case DeviceValueUOM.NUM:
|
||||
return new Intl.NumberFormat().format(value);
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface DeviceValue {
|
||||
u: number;
|
||||
n: string;
|
||||
c: string;
|
||||
l: string[];
|
||||
}
|
||||
|
||||
export interface EMSESPDeviceData {
|
||||
@@ -88,7 +89,8 @@ export enum DeviceValueUOM {
|
||||
SECONDS,
|
||||
DBM,
|
||||
NUM,
|
||||
BOOLEAN
|
||||
BOOLEAN,
|
||||
LIST
|
||||
}
|
||||
|
||||
export const DeviceValueUOM_s = [
|
||||
@@ -108,5 +110,6 @@ export const DeviceValueUOM_s = [
|
||||
'seconds',
|
||||
'dBm',
|
||||
'number',
|
||||
'on/off'
|
||||
'on/off',
|
||||
''
|
||||
];
|
||||
|
||||
@@ -51,24 +51,40 @@ class ValueForm extends React.Component<ValueFormProps> {
|
||||
>
|
||||
<DialogTitle id="user-form-dialog-title">Change Value</DialogTitle>
|
||||
<DialogContent dividers>
|
||||
{devicevalue.u !== DeviceValueUOM.BOOLEAN && (
|
||||
<OutlinedInput
|
||||
id="outlined-adornment-value"
|
||||
{devicevalue.u === DeviceValueUOM.LIST && (
|
||||
<TextField
|
||||
id="outlined-select-value"
|
||||
select
|
||||
value={devicevalue.v}
|
||||
autoFocus
|
||||
fullWidth
|
||||
onChange={handleValueChange('v')}
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
{DeviceValueUOM_s[devicevalue.u]}
|
||||
</InputAdornment>
|
||||
}
|
||||
aria-describedby="outlined-value-helper-text"
|
||||
inputProps={{
|
||||
'aria-label': 'value'
|
||||
}}
|
||||
/>
|
||||
variant="outlined"
|
||||
>
|
||||
{devicevalue.l.map((val) => (
|
||||
<MenuItem value={val}>{val}</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
)}
|
||||
{devicevalue.u !== DeviceValueUOM.BOOLEAN &&
|
||||
devicevalue.u !== DeviceValueUOM.LIST && (
|
||||
<OutlinedInput
|
||||
id="outlined-adornment-value"
|
||||
value={devicevalue.v}
|
||||
autoFocus
|
||||
fullWidth
|
||||
onChange={handleValueChange('v')}
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
{DeviceValueUOM_s[devicevalue.u]}
|
||||
</InputAdornment>
|
||||
}
|
||||
aria-describedby="outlined-value-helper-text"
|
||||
inputProps={{
|
||||
'aria-label': 'value'
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{devicevalue.u === DeviceValueUOM.BOOLEAN && (
|
||||
<TextField
|
||||
id="outlined-select-value"
|
||||
|
||||
Reference in New Issue
Block a user