mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
improve device value helper text
This commit is contained in:
@@ -83,6 +83,22 @@ const DashboarDevicesDialog = ({ open, onClose, onSave, selectedItem, validator
|
||||
}
|
||||
};
|
||||
|
||||
const showHelperText = (dv: DeviceValue) => {
|
||||
if (dv.h) {
|
||||
return dv.h;
|
||||
}
|
||||
if (dv.l) {
|
||||
return '[ ' + dv.l.join(' | ') + ' ]';
|
||||
}
|
||||
if (dv.u !== DeviceValueUOM.NONE) {
|
||||
if (dv.m && dv.x) {
|
||||
return '<number between ' + dv.m + ' and ' + dv.x + '>';
|
||||
}
|
||||
return '<number>';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={close}>
|
||||
<DialogTitle>{selectedItem.v === '' && selectedItem.c ? LL.RUN_COMMAND() : LL.CHANGE_VALUE()}</DialogTitle>
|
||||
@@ -90,7 +106,7 @@ const DashboarDevicesDialog = ({ open, onClose, onSave, selectedItem, validator
|
||||
<Box color="warning.main" p={0} pl={0} pr={0} mt={0} mb={2}>
|
||||
<Typography variant="body2">{editItem.id.slice(2)}</Typography>
|
||||
</Box>
|
||||
<Grid container spacing={1}>
|
||||
<Grid>
|
||||
<Grid item>
|
||||
{editItem.l && (
|
||||
<TextField
|
||||
@@ -125,7 +141,9 @@ const DashboarDevicesDialog = ({ open, onClose, onSave, selectedItem, validator
|
||||
/>
|
||||
)}
|
||||
</Grid>
|
||||
{editItem.h && <FormHelperText>{editItem.h}</FormHelperText>}
|
||||
<Grid item>
|
||||
<FormHelperText>format: {showHelperText(editItem)}</FormHelperText>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DialogContent>
|
||||
|
||||
|
||||
@@ -170,14 +170,10 @@ export const deviceValueItemValidation = (dv: DeviceValue) =>
|
||||
{
|
||||
validator(rule: InternalRuleItem, value: string, callback: (error?: string) => void) {
|
||||
if (dv.u !== DeviceValueUOM.NONE && isNaN(+value)) {
|
||||
// not a number
|
||||
dv.m && dv.x
|
||||
? callback('Value must be a number between ' + dv.m + ' and ' + dv.x)
|
||||
: callback('Value must be a number');
|
||||
callback('Not a valid number');
|
||||
}
|
||||
// is a number
|
||||
(dv.m && Number(value) < dv.m) || (dv.x && Number(value) > dv.x)
|
||||
? callback('Value must be between ' + dv.m + ' and ' + dv.x)
|
||||
? callback('Value out of range')
|
||||
: callback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,6 +492,13 @@ const emsesp_devicedata_1 = {
|
||||
id: '00hc1 mode',
|
||||
c: 'hc1/mode',
|
||||
l: ['off', 'on', 'auto']
|
||||
},
|
||||
{
|
||||
v: '00 mo 00:00 T1',
|
||||
u: 0,
|
||||
id: '00hc1 program switchtime',
|
||||
c: 'hc1/switchtime',
|
||||
h: '<nn> [ not_set | day hh:mm Tn ]'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -194,13 +194,13 @@ MAKE_NOTRANSLATION(6kW, "6 kW")
|
||||
MAKE_NOTRANSLATION(9kW, "9 kW")
|
||||
|
||||
// templates - this are not translated and will be saved under options_single
|
||||
MAKE_NOTRANSLATION(tpl_datetime, "Format: < NTP | dd.mm.yyyy-hh:mm:ss-day(0-6)-dst(0/1) >")
|
||||
MAKE_NOTRANSLATION(tpl_switchtime, "Format: <nn> [ not_set | day hh:mm on|off ]")
|
||||
MAKE_NOTRANSLATION(tpl_switchtime1, "Format: <nn> [ not_set | day hh:mm Tn ]")
|
||||
MAKE_NOTRANSLATION(tpl_holidays, "Format: < dd.mm.yyyy-dd.mm.yyyy >")
|
||||
MAKE_NOTRANSLATION(tpl_date, "Format: < dd.mm.yyyy >")
|
||||
MAKE_NOTRANSLATION(tpl_input, "Format: <inv>[<evu1><evu2><evu3><comp><aux><cool><heat><dhw><pv>]")
|
||||
MAKE_NOTRANSLATION(tpl_input4, "Format: <inv>[<comp><aux><cool><heat><dhw><pv>]")
|
||||
MAKE_NOTRANSLATION(tpl_datetime, "< NTP | dd.mm.yyyy-hh:mm:ss-day(0-6)-dst(0/1) >")
|
||||
MAKE_NOTRANSLATION(tpl_switchtime, "<nn> [ not_set | day hh:mm on|off ]")
|
||||
MAKE_NOTRANSLATION(tpl_switchtime1, "<nn> [ not_set | day hh:mm Tn ]")
|
||||
MAKE_NOTRANSLATION(tpl_holidays, "< dd.mm.yyyy-dd.mm.yyyy >")
|
||||
MAKE_NOTRANSLATION(tpl_date, "< dd.mm.yyyy >")
|
||||
MAKE_NOTRANSLATION(tpl_input, "<inv>[<evu1><evu2><evu3><comp><aux><cool><heat><dhw><pv>]")
|
||||
MAKE_NOTRANSLATION(tpl_input4, "<inv>[<comp><aux><cool><heat><dhw><pv>]")
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
MAKE_NOTRANSLATION(test_cmd, "run a test")
|
||||
|
||||
Reference in New Issue
Block a user