mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
show dallas-temperatures always with digit on web
This commit is contained in:
@@ -118,7 +118,7 @@ export const formatDuration = (duration_min: number) => {
|
|||||||
const pluralize = (count: number, noun: string, suffix = 's') =>
|
const pluralize = (count: number, noun: string, suffix = 's') =>
|
||||||
` ${count} ${noun}${count !== 1 ? suffix : ''} `;
|
` ${count} ${noun}${count !== 1 ? suffix : ''} `;
|
||||||
|
|
||||||
function formatValue(value: any, uom: number) {
|
function formatValue(value: any, uom: number, digit: number) {
|
||||||
switch (uom) {
|
switch (uom) {
|
||||||
case DeviceValueUOM.HOURS:
|
case DeviceValueUOM.HOURS:
|
||||||
return value ? formatDuration(value * 60) : '0 hours';
|
return value ? formatDuration(value * 60) : '0 hours';
|
||||||
@@ -131,6 +131,14 @@ function formatValue(value: any, uom: number) {
|
|||||||
return new Intl.NumberFormat().format(value);
|
return new Intl.NumberFormat().format(value);
|
||||||
case DeviceValueUOM.BOOLEAN:
|
case DeviceValueUOM.BOOLEAN:
|
||||||
return value ? 'on' : 'off';
|
return value ? 'on' : 'off';
|
||||||
|
case DeviceValueUOM.DEGREES:
|
||||||
|
return (
|
||||||
|
new Intl.NumberFormat(undefined, {
|
||||||
|
minimumFractionDigits: digit
|
||||||
|
}).format(value) +
|
||||||
|
' ' +
|
||||||
|
DeviceValueUOM_s[uom]
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
new Intl.NumberFormat().format(value) + ' ' + DeviceValueUOM_s[uom]
|
new Intl.NumberFormat().format(value) + ' ' + DeviceValueUOM_s[uom]
|
||||||
@@ -313,7 +321,7 @@ class EMSESPDevicesForm extends Component<
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="center">{sensorData.id}</TableCell>
|
<TableCell align="center">{sensorData.id}</TableCell>
|
||||||
<TableCell align="right">
|
<TableCell align="right">
|
||||||
{formatValue(sensorData.temp, DeviceValueUOM.DEGREES)}
|
{formatValue(sensorData.temp, DeviceValueUOM.DEGREES, 1)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
@@ -476,7 +484,7 @@ class EMSESPDevicesForm extends Component<
|
|||||||
{item.n}
|
{item.n}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell padding="none" align="right">
|
<TableCell padding="none" align="right">
|
||||||
{formatValue(item.v, item.u)}
|
{formatValue(item.v, item.u, 0)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user