mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
add is_system to analog and temperature sensors, highlight in Sensors page, remove from Dashboard, change button icon to be consistent when updating
This commit is contained in:
@@ -96,6 +96,7 @@ const common_theme = {
|
||||
}
|
||||
&:hover .td {
|
||||
background-color: #177ac9;
|
||||
color: white;
|
||||
}
|
||||
`,
|
||||
Cell: `
|
||||
@@ -297,7 +298,12 @@ const Sensors = () => {
|
||||
|
||||
const onTemperatureDialogSave = useCallback(
|
||||
async (ts: TemperatureSensor) => {
|
||||
await sendTemperatureSensor({ id: ts.id, name: ts.n, offset: ts.o })
|
||||
await sendTemperatureSensor({
|
||||
id: ts.id,
|
||||
name: ts.n,
|
||||
offset: ts.o,
|
||||
is_system: ts.s
|
||||
})
|
||||
.then(() => {
|
||||
toast.success(LL.UPDATED_OF(LL.SENSOR(1)));
|
||||
})
|
||||
@@ -342,7 +348,8 @@ const Sensors = () => {
|
||||
t: 0,
|
||||
f: 1,
|
||||
d: false,
|
||||
o_n: ''
|
||||
o_n: '',
|
||||
s: false
|
||||
});
|
||||
setAnalogDialogOpen(true);
|
||||
}, []);
|
||||
@@ -357,7 +364,8 @@ const Sensors = () => {
|
||||
factor: as.f,
|
||||
uom: as.u,
|
||||
type: as.t,
|
||||
deleted: as.d
|
||||
deleted: as.d,
|
||||
is_system: as.s
|
||||
})
|
||||
.then(() => {
|
||||
toast.success(LL.UPDATED_OF(LL.ANALOG_SENSOR(2)));
|
||||
@@ -431,20 +439,25 @@ const Sensors = () => {
|
||||
</HeaderRow>
|
||||
</Header>
|
||||
<Body>
|
||||
{tableList.map((a: AnalogSensor) => (
|
||||
<Row key={a.id} item={a} onClick={() => updateAnalogSensor(a)}>
|
||||
<Cell stiff>{a.g}</Cell>
|
||||
<Cell>{a.n}</Cell>
|
||||
<Cell stiff>{AnalogTypeNames[a.t]} </Cell>
|
||||
{(a.t === AnalogType.DIGITAL_OUT &&
|
||||
a.g !== GPIO_25 &&
|
||||
a.g !== GPIO_26) ||
|
||||
a.t === AnalogType.DIGITAL_IN ||
|
||||
a.t === AnalogType.PULSE ? (
|
||||
<Cell stiff>{a.v ? LL.ON() : LL.OFF()}</Cell>
|
||||
{tableList.map((as: AnalogSensor) => (
|
||||
<Row
|
||||
style={{ color: as.s ? 'grey' : 'inherit' }}
|
||||
key={as.id}
|
||||
item={as}
|
||||
onClick={() => updateAnalogSensor(as)}
|
||||
>
|
||||
<Cell stiff>{as.g}</Cell>
|
||||
<Cell>{as.n}</Cell>
|
||||
<Cell stiff>{AnalogTypeNames[as.t]} </Cell>
|
||||
{(as.t === AnalogType.DIGITAL_OUT &&
|
||||
as.g !== GPIO_25 &&
|
||||
as.g !== GPIO_26) ||
|
||||
as.t === AnalogType.DIGITAL_IN ||
|
||||
as.t === AnalogType.PULSE ? (
|
||||
<Cell stiff>{as.v ? LL.ON() : LL.OFF()}</Cell>
|
||||
) : (
|
||||
<Cell stiff>
|
||||
{a.t !== AnalogType.NOTUSED ? formatValue(a.v, a.u) : ''}
|
||||
{as.t !== AnalogType.NOTUSED ? formatValue(as.v, as.u) : ''}
|
||||
</Cell>
|
||||
)}
|
||||
</Row>
|
||||
@@ -506,6 +519,7 @@ const Sensors = () => {
|
||||
<Body>
|
||||
{tableList.map((ts: TemperatureSensor) => (
|
||||
<Row
|
||||
style={{ color: ts.s ? 'grey' : 'inherit' }}
|
||||
key={ts.id}
|
||||
item={ts}
|
||||
onClick={() => updateTemperatureSensor(ts)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
import DoneIcon from '@mui/icons-material/Done';
|
||||
import RemoveIcon from '@mui/icons-material/RemoveCircleOutline';
|
||||
import WarningIcon from '@mui/icons-material/Warning';
|
||||
import {
|
||||
@@ -441,6 +442,18 @@ const SensorsAnalogDialog = ({
|
||||
</>
|
||||
)}
|
||||
</Grid>
|
||||
{editItem.s && (
|
||||
<Grid>
|
||||
<Typography mt={1} color="warning.main" variant="body2">
|
||||
<WarningIcon
|
||||
fontSize="small"
|
||||
sx={{ mr: 1, verticalAlign: 'middle' }}
|
||||
color="warning"
|
||||
/>
|
||||
{LL.SYSTEM(0)} {LL.SENSOR(0)}
|
||||
</Typography>
|
||||
</Grid>
|
||||
)}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
{!creating && (
|
||||
@@ -465,7 +478,7 @@ const SensorsAnalogDialog = ({
|
||||
{LL.CANCEL()}
|
||||
</Button>
|
||||
<Button
|
||||
startIcon={<WarningIcon color="warning" />}
|
||||
startIcon={<DoneIcon />}
|
||||
variant="outlined"
|
||||
onClick={save}
|
||||
color="primary"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
import DoneIcon from '@mui/icons-material/Done';
|
||||
import WarningIcon from '@mui/icons-material/Warning';
|
||||
import {
|
||||
Box,
|
||||
@@ -139,6 +140,18 @@ const SensorsTemperatureDialog = ({
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
{editItem.s && (
|
||||
<Grid>
|
||||
<Typography mt={1} color="warning.main" variant="body2">
|
||||
<WarningIcon
|
||||
fontSize="small"
|
||||
sx={{ mr: 1, verticalAlign: 'middle' }}
|
||||
color="warning"
|
||||
/>
|
||||
{LL.SYSTEM(0)} {LL.SENSOR(0)}
|
||||
</Typography>
|
||||
</Grid>
|
||||
)}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
@@ -150,7 +163,7 @@ const SensorsTemperatureDialog = ({
|
||||
{LL.CANCEL()}
|
||||
</Button>
|
||||
<Button
|
||||
startIcon={<WarningIcon color="warning" />}
|
||||
startIcon={<DoneIcon />}
|
||||
variant="outlined"
|
||||
onClick={save}
|
||||
color="primary"
|
||||
|
||||
@@ -82,6 +82,7 @@ export interface TemperatureSensor {
|
||||
t?: number; // temp, optional
|
||||
o: number; // offset
|
||||
u: number; // uom
|
||||
s: boolean; // system sensor flag
|
||||
o_n?: string;
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ export interface AnalogSensor {
|
||||
f: number;
|
||||
t: number;
|
||||
d: boolean; // deleted flag
|
||||
s: boolean; // system customization flag
|
||||
s: boolean; // system sensor flag
|
||||
o_n?: string;
|
||||
}
|
||||
|
||||
@@ -103,6 +104,7 @@ export interface WriteTemperatureSensor {
|
||||
id: string;
|
||||
name: string;
|
||||
offset: number;
|
||||
is_system: boolean;
|
||||
}
|
||||
|
||||
export interface SensorData {
|
||||
@@ -318,6 +320,7 @@ export interface WriteAnalogSensor {
|
||||
uom: number;
|
||||
type: number;
|
||||
deleted: boolean;
|
||||
is_system: boolean;
|
||||
}
|
||||
|
||||
export enum DeviceEntityMask {
|
||||
|
||||
Reference in New Issue
Block a user