Skip to content

Commit

Permalink
stripped table rows
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Nov 21, 2021
1 parent 53de2ca commit bb38458
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- Removed settings for MQTT subscribe format [#173](https://github.com/emsesp/EMS-ESP32/issues/173)
- Improve Nefit Moduline 200 functionality [#183](https://github.com/emsesp/EMS-ESP32/issues/183)
- `status` in the MQTT heartbeat renamed to `bus_status`
- Layout changes in the WebUI, showing stripped table rows in Dashboard

## **BREAKING CHANGES**

Expand Down
94 changes: 52 additions & 42 deletions interface/src/project/EMSESPDataForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,32 @@ export const DEVICE_DATA_ENDPOINT = ENDPOINT_ROOT + 'deviceData';
export const WRITE_VALUE_ENDPOINT = ENDPOINT_ROOT + 'writeValue';
export const WRITE_SENSOR_ENDPOINT = ENDPOINT_ROOT + 'writeSensor';

const StyledTableCell = withStyles((theme: Theme) =>
const StyledTableRow = withStyles((theme: Theme) =>
createStyles({
head: {
backgroundColor: theme.palette.common.black,
color: theme.palette.common.white
root: {
'&:nth-child(even)': {
backgroundColor: '#4e4e4e'
},
'&:hover': {
backgroundColor: theme.palette.info.light
}
},
body: {
fontSize: 14

selected: {
backgroundColor: theme.palette.common.white
}
})
)(TableRow);

const StyledTableRowHeader = withStyles((theme: Theme) =>
createStyles({
head: {
backgroundColor: theme.palette.common.black
}
})
)(TableCell);
)(TableRow);

const CustomTooltip = withStyles((theme: Theme) => ({
const StyledTooltip = withStyles((theme: Theme) => ({
tooltip: {
backgroundColor: theme.palette.secondary.main,
color: 'white',
Expand Down Expand Up @@ -304,7 +317,7 @@ class EMSESPDataForm extends Component<
return (this.state.deviceData?.data || []).length === 0;
};

renderDeviceItems() {
renderDevices() {
const { width, data } = this.props;
return (
<TableContainer>
Expand All @@ -325,7 +338,7 @@ class EMSESPDataForm extends Component<
onClick={() => this.handleRowClick(device.i)}
>
<TableCell>
<CustomTooltip
<StyledTooltip
title={
'DeviceID:0x' +
('00' + device.d.toString(16).toUpperCase()).slice(-2) +
Expand All @@ -343,7 +356,7 @@ class EMSESPDataForm extends Component<
>
{device.t}
</Button>
</CustomTooltip>
</StyledTooltip>
</TableCell>
<TableCell align="right">
{device.b + ' ' + device.n}{' '}
Expand Down Expand Up @@ -371,7 +384,7 @@ class EMSESPDataForm extends Component<
);
}

renderSensorItems() {
renderSensorData() {
const { data } = this.props;
const me = this.props.authenticatedContext.me;
return (
Expand All @@ -383,26 +396,22 @@ class EMSESPDataForm extends Component<
{!this.noSensors() && (
<Table size="small" padding="normal">
<TableHead>
<TableRow>
<StyledTableCell
padding="checkbox"
style={{ width: 18 }}
></StyledTableCell>
<StyledTableCell>Sensor #</StyledTableCell>
<StyledTableCell align="left">ID / Name</StyledTableCell>
<StyledTableCell align="right">Temperature</StyledTableCell>
</TableRow>
<StyledTableRowHeader>
<TableCell padding="checkbox" style={{ width: 18 }}></TableCell>
<TableCell>Dallas Sensor #</TableCell>
<TableCell align="left">ID / Name</TableCell>
<TableCell align="right">Temperature</TableCell>
</StyledTableRowHeader>
</TableHead>
<TableBody>
{data.sensors.map((sensorData) => (
<TableRow
<StyledTableRow
key={sensorData.n}
hover
onClick={() => this.sendSensor(sensorData)}
>
<TableCell padding="checkbox" style={{ width: 18 }}>
<TableCell padding="checkbox">
{me.admin && (
<CustomTooltip title="edit" placement="left-end">
<StyledTooltip title="edit" placement="left-end">
<IconButton
edge="start"
size="small"
Expand All @@ -411,7 +420,7 @@ class EMSESPDataForm extends Component<
>
<EditIcon color="primary" fontSize="small" />
</IconButton>
</CustomTooltip>
</StyledTooltip>
)}
</TableCell>
<TableCell component="th" scope="row">
Expand All @@ -421,7 +430,7 @@ class EMSESPDataForm extends Component<
<TableCell align="right">
{formatValue(sensorData.t, DeviceValueUOM.DEGREES)}
</TableCell>
</TableRow>
</StyledTableRow>
))}
</TableBody>
</Table>
Expand All @@ -437,20 +446,23 @@ class EMSESPDataForm extends Component<
);
}

renderAnalog() {
renderAnalogData() {
const { data } = this.props;
return (
<TableContainer>
<p></p>
{data.analog > 0 && (
<Table size="small" padding="normal">
<TableHead>
<TableRow>
<StyledTableCell>Sensortype</StyledTableCell>
<StyledTableCell align="right">Value</StyledTableCell>
</TableRow>
<StyledTableRowHeader>
<TableCell padding="normal" style={{ width: 18 }}></TableCell>
<TableCell>Sensor Type</TableCell>
<TableCell align="right">Value</TableCell>
</StyledTableRowHeader>
</TableHead>
<TableBody>
<TableRow>
<TableCell padding="normal">&nbsp;&nbsp;</TableCell>
<TableCell component="th" scope="row">
Analog Input
</TableCell>
Expand Down Expand Up @@ -575,7 +587,7 @@ class EMSESPDataForm extends Component<
<p></p>
<Box bgcolor="info.main" p={1} mt={1} mb={1}>
<Typography variant="body1" color="initial">
{deviceData.name}
{deviceData.type}&nbsp;Data
</Typography>
</Box>
{!this.noDeviceData() && (
Expand All @@ -584,17 +596,15 @@ class EMSESPDataForm extends Component<
size="small"
padding={isWidthDown('xs', width!) ? 'none' : 'normal'}
>
<TableHead></TableHead>
<TableBody>
{deviceData.data.map((item, i) => (
<TableRow
hover
<StyledTableRow
key={i}
onClick={() => this.sendCommand(item)}
>
<TableCell padding="checkbox" style={{ width: 18 }}>
{item.c && this.props.authenticatedContext.me.admin && (
<CustomTooltip
<StyledTooltip
title="change value"
placement="left-end"
>
Expand All @@ -606,7 +616,7 @@ class EMSESPDataForm extends Component<
>
<EditIcon color="primary" fontSize="small" />
</IconButton>
</CustomTooltip>
</StyledTooltip>
)}
</TableCell>
<TableCell padding="none" component="th" scope="row">
Expand All @@ -615,7 +625,7 @@ class EMSESPDataForm extends Component<
<TableCell padding="none" align="right">
{formatValue(item.v, item.u)}
</TableCell>
</TableRow>
</StyledTableRow>
))}
</TableBody>
</Table>
Expand All @@ -637,10 +647,10 @@ class EMSESPDataForm extends Component<
return (
<Fragment>
<br></br>
{this.renderDeviceItems()}
{this.renderDevices()}
{this.renderDeviceData()}
{this.renderSensorItems()}
{this.renderAnalog()}
{this.renderSensorData()}
{this.renderAnalogData()}
<br></br>
<Box display="flex" flexWrap="wrap">
<Box flexGrow={1} padding={1}>
Expand Down
2 changes: 1 addition & 1 deletion interface/src/project/EMSESPtypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface DeviceValue {
}

export interface EMSESPDeviceData {
name: string;
type: string;
data: DeviceValue[];
}

Expand Down
7 changes: 4 additions & 3 deletions mock-api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ const emsesp_data = {
{ n: 1, i: '28-233D-9497-0C03', t: 25.7, o: 1.2 },
{ n: 2, i: '28-243D-7437-1E3A', t: 26.1, o: 0 },
],
analog: 12,
}

const emsesp_status = {
Expand All @@ -364,7 +365,7 @@ const emsesp_status = {
}

const emsesp_devicedata_1 = {
name: 'Thermostat: RC20/Moduline 300',
type: 'Thermostat',
data: [
{
v: '(0)',
Expand Down Expand Up @@ -400,7 +401,7 @@ const emsesp_devicedata_1 = {
}

const emsesp_devicedata_2 = {
name: 'Boiler: Nefit GBx72/Trendline/Cerapur/Greenstar Si/27i',
type: 'Boiler',
data: [
{ v: 'off', u: 0, n: 'heating active' },
{ v: 'off', u: 0, n: 'warm water active' },
Expand Down Expand Up @@ -525,7 +526,7 @@ const emsesp_devicedata_2 = {
}

const emsesp_devicedata_3 = {
name: 'Controller: BC1',
type: 'Controller',
data: [],
}

Expand Down
2 changes: 1 addition & 1 deletion src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ const std::string EMSdevice::get_value_uom(const char * key) {
// except additional data is stored in the JSON document needed for the Web UI like the UOM and command
// v = value, u=uom, n=name, c=cmd
void EMSdevice::generate_values_json_web(JsonObject & output) {
output["name"] = to_string_short();
output["type"] = device_type_name();
JsonArray data = output.createNestedArray("data");

for (const auto & dv : devicevalues_) {
Expand Down

0 comments on commit bb38458

Please sign in to comment.