mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
show commands differently
This commit is contained in:
@@ -158,6 +158,8 @@ const DashboardData: FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isCmdOnly = (dv: DeviceValue) => dv.v === undefined && dv.c;
|
||||||
|
|
||||||
function formatValue(value: any, uom: number) {
|
function formatValue(value: any, uom: number) {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
return '';
|
return '';
|
||||||
@@ -218,7 +220,7 @@ const DashboardData: FC = () => {
|
|||||||
if (deviceValue) {
|
if (deviceValue) {
|
||||||
return (
|
return (
|
||||||
<Dialog open={deviceValue !== undefined} onClose={() => setDeviceValue(undefined)}>
|
<Dialog open={deviceValue !== undefined} onClose={() => setDeviceValue(undefined)}>
|
||||||
<DialogTitle>Change Value</DialogTitle>
|
<DialogTitle>{isCmdOnly(deviceValue) ? 'Run Command' : 'Change Value'}</DialogTitle>
|
||||||
<DialogContent dividers>
|
<DialogContent dividers>
|
||||||
{deviceValue.l && (
|
{deviceValue.l && (
|
||||||
<ValidatedTextField
|
<ValidatedTextField
|
||||||
@@ -506,7 +508,6 @@ const DashboardData: FC = () => {
|
|||||||
{hasMask(dv.n, DeviceEntityMask.DV_API_MQTT_EXCLUDE) && (
|
{hasMask(dv.n, DeviceEntityMask.DV_API_MQTT_EXCLUDE) && (
|
||||||
<CommentsDisabledOutlinedIcon color="primary" sx={{ fontSize: 12 }} />
|
<CommentsDisabledOutlinedIcon color="primary" sx={{ fontSize: 12 }} />
|
||||||
)}
|
)}
|
||||||
{dv.v === undefined && dv.c && <PlayArrowIcon color="primary" sx={{ fontSize: 14 }} />}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -519,21 +520,13 @@ const DashboardData: FC = () => {
|
|||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<StyledTableCell padding="checkbox" style={{ width: 18 }}></StyledTableCell>
|
<StyledTableCell padding="checkbox" style={{ width: 18 }}></StyledTableCell>
|
||||||
<StyledTableCell align="left">ENTITY NAME/COMMAND</StyledTableCell>
|
<StyledTableCell align="left">ENTITY NAME</StyledTableCell>
|
||||||
<StyledTableCell align="right">VALUE</StyledTableCell>
|
<StyledTableCell align="right">VALUE</StyledTableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{deviceData.data.map((dv, i) => (
|
{deviceData.data.map((dv, i) => (
|
||||||
<TableRow
|
<StyledTableRow key={i} onClick={() => sendCommand(dv)}>
|
||||||
key={i}
|
|
||||||
onClick={() => sendCommand(dv)}
|
|
||||||
// sx={
|
|
||||||
// hasMask(dv.n, DeviceEntityMask.DV_FAVORITE)
|
|
||||||
// ? { backgroundColor: '#334900' }
|
|
||||||
// : { backgroundColor: 'black' }
|
|
||||||
// }
|
|
||||||
>
|
|
||||||
<StyledTableCell padding="checkbox">
|
<StyledTableCell padding="checkbox">
|
||||||
{dv.c && me.admin && !hasMask(dv.n, DeviceEntityMask.DV_READONLY) && (
|
{dv.c && me.admin && !hasMask(dv.n, DeviceEntityMask.DV_READONLY) && (
|
||||||
<IconButton size="small">
|
<IconButton size="small">
|
||||||
@@ -544,8 +537,10 @@ const DashboardData: FC = () => {
|
|||||||
<StyledTableCell component="th" scope="row">
|
<StyledTableCell component="th" scope="row">
|
||||||
{renderNameCell(dv)}
|
{renderNameCell(dv)}
|
||||||
</StyledTableCell>
|
</StyledTableCell>
|
||||||
<StyledTableCell align="right">{formatValue(dv.v, dv.u)}</StyledTableCell>
|
<StyledTableCell align="right">
|
||||||
</TableRow>
|
{isCmdOnly(dv) ? <PlayArrowIcon color="primary" sx={{ fontSize: 14 }} /> : formatValue(dv.v, dv.u)}
|
||||||
|
</StyledTableCell>
|
||||||
|
</StyledTableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
Reference in New Issue
Block a user