mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
feat: board profiles (#11)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { TextValidator, SelectValidator, ValidatorForm } from 'react-material-ui-form-validator';
|
||||
import { TextValidator, ValidatorForm } from 'react-material-ui-form-validator';
|
||||
|
||||
import { Checkbox, List, ListItem, ListItemText, ListItemAvatar, ListItemSecondaryAction } from '@material-ui/core';
|
||||
|
||||
@@ -9,7 +9,6 @@ import LockIcon from '@material-ui/icons/Lock';
|
||||
import LockOpenIcon from '@material-ui/icons/LockOpen';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import SaveIcon from '@material-ui/icons/Save';
|
||||
import MenuItem from '@material-ui/core/MenuItem';
|
||||
|
||||
import { RestFormProps, PasswordValidator, BlockFormControlLabel, FormActions, FormButton } from '../components';
|
||||
import { isIP, isHostname, optional } from '../validators';
|
||||
@@ -34,7 +33,6 @@ class NetworkSettingsForm extends React.Component<NetworkStatusFormProps> {
|
||||
ssid: selectedNetwork.ssid,
|
||||
password: "",
|
||||
hostname: props.data.hostname,
|
||||
ethernet_profile: 0,
|
||||
static_ip_config: false,
|
||||
}
|
||||
props.setData(networkSettings);
|
||||
@@ -119,17 +117,6 @@ class NetworkSettingsForm extends React.Component<NetworkStatusFormProps> {
|
||||
onChange={handleValueChange('hostname')}
|
||||
margin="normal"
|
||||
/>
|
||||
<SelectValidator name="ems_bus_id"
|
||||
label="Ethernet Profile"
|
||||
value={data.ethernet_profile}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('ethernet_profile')}
|
||||
margin="normal">
|
||||
<MenuItem value={0}>None (wifi only)</MenuItem>
|
||||
<MenuItem value={1}>Profile 1 (LAN8720)</MenuItem>
|
||||
<MenuItem value={2}>Profile 2 (TLK110)</MenuItem>
|
||||
</SelectValidator>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
|
||||
@@ -36,7 +36,6 @@ export interface NetworkSettings {
|
||||
ssid: string;
|
||||
password: string;
|
||||
hostname: string;
|
||||
ethernet_profile: number;
|
||||
static_ip_config: boolean;
|
||||
local_ip?: string;
|
||||
gateway_ip?: string;
|
||||
|
||||
@@ -2,40 +2,19 @@ import React, { Component, Fragment } from "react";
|
||||
import { withStyles, Theme, createStyles } from "@material-ui/core/styles";
|
||||
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableRow,
|
||||
TableContainer,
|
||||
withWidth,
|
||||
WithWidthProps,
|
||||
isWidthDown,
|
||||
Button,
|
||||
Tooltip,
|
||||
DialogTitle,
|
||||
DialogContent,
|
||||
DialogActions,
|
||||
Box,
|
||||
Dialog,
|
||||
Typography,
|
||||
Table, TableBody, TableCell, TableHead, TableRow, TableContainer, withWidth, WithWidthProps, isWidthDown,
|
||||
Button, Tooltip, DialogTitle, DialogContent, DialogActions, Box, Dialog, Typography
|
||||
} from "@material-ui/core";
|
||||
|
||||
import RefreshIcon from "@material-ui/icons/Refresh";
|
||||
import ListIcon from "@material-ui/icons/List";
|
||||
|
||||
import {
|
||||
redirectingAuthorizedFetch,
|
||||
withAuthenticatedContext,
|
||||
AuthenticatedContextProps,
|
||||
} from "../authentication";
|
||||
|
||||
import { redirectingAuthorizedFetch, withAuthenticatedContext, AuthenticatedContextProps } from "../authentication";
|
||||
import { RestFormProps, FormButton } from "../components";
|
||||
|
||||
import { EMSESPDevices, EMSESPDeviceData, Device } from "./EMSESPtypes";
|
||||
|
||||
import { ENDPOINT_ROOT } from "../api";
|
||||
|
||||
export const SCANDEVICES_ENDPOINT = ENDPOINT_ROOT + "scanDevices";
|
||||
export const DEVICE_DATA_ENDPOINT = ENDPOINT_ROOT + "deviceData";
|
||||
|
||||
@@ -73,22 +52,19 @@ type EMSESPDevicesFormProps = RestFormProps<EMSESPDevices> &
|
||||
|
||||
function formatTemp(t: string) {
|
||||
if (t == null) {
|
||||
return "(not available)";
|
||||
return "n/a";
|
||||
}
|
||||
return t + " °C";
|
||||
}
|
||||
|
||||
function formatUnit(u: string) {
|
||||
function formatUnit(u: string) {
|
||||
if (u == null) {
|
||||
return u;
|
||||
}
|
||||
return " " + u;
|
||||
}
|
||||
|
||||
class EMSESPDevicesForm extends Component<
|
||||
EMSESPDevicesFormProps,
|
||||
EMSESPDevicesFormState
|
||||
> {
|
||||
class EMSESPDevicesForm extends Component<EMSESPDevicesFormProps, EMSESPDevicesFormState> {
|
||||
state: EMSESPDevicesFormState = {
|
||||
confirmScanDevices: false,
|
||||
processing: false,
|
||||
@@ -106,7 +82,7 @@ class EMSESPDevicesForm extends Component<
|
||||
return (this.state.deviceData?.data || []).length === 0;
|
||||
};
|
||||
|
||||
createDeviceItems() {
|
||||
renderDeviceItems() {
|
||||
const { width, data } = this.props;
|
||||
return (
|
||||
<TableContainer>
|
||||
@@ -186,7 +162,7 @@ class EMSESPDevicesForm extends Component<
|
||||
);
|
||||
}
|
||||
|
||||
createSensorItems() {
|
||||
renderSensorItems() {
|
||||
const { data } = this.props;
|
||||
return (
|
||||
<TableContainer>
|
||||
@@ -365,11 +341,11 @@ class EMSESPDevicesForm extends Component<
|
||||
</TableContainer>
|
||||
)}
|
||||
{this.noDeviceData() && (
|
||||
<Box color="warning.main" p={0} mt={0} mb={0}>
|
||||
<Typography variant="body1">
|
||||
<i>No data available for this device</i>
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box color="warning.main" p={0} mt={0} mb={0}>
|
||||
<Typography variant="body1">
|
||||
<i>No data available for this device</i>
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
</Fragment >
|
||||
);
|
||||
@@ -379,9 +355,9 @@ class EMSESPDevicesForm extends Component<
|
||||
return (
|
||||
<Fragment>
|
||||
<br></br>
|
||||
{this.createDeviceItems()}
|
||||
{this.renderDeviceItems()}
|
||||
{this.renderDeviceData()}
|
||||
{this.createSensorItems()}
|
||||
{this.renderSensorItems()}
|
||||
<br></br>
|
||||
<Box display="flex" flexWrap="wrap">
|
||||
<Box flexGrow={1} padding={1}>
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import React, { Component } from 'react';
|
||||
import { ValidatorForm, TextValidator, SelectValidator } from 'react-material-ui-form-validator';
|
||||
|
||||
import { Checkbox, Typography, Box, Link } from '@material-ui/core';
|
||||
import SaveIcon from '@material-ui/icons/Save';
|
||||
import MenuItem from '@material-ui/core/MenuItem';
|
||||
// import { Container } from '@material-ui/core';
|
||||
|
||||
import { ENDPOINT_ROOT } from '../api';
|
||||
import { restController, RestControllerProps, RestFormLoader, RestFormProps, FormActions, FormButton, BlockFormControlLabel, SectionContent } from '../components';
|
||||
import EMSESPSettingsForm from './EMSESPSettingsForm';
|
||||
|
||||
import { isIP, optional } from '../validators';
|
||||
import { restController, RestControllerProps, RestFormLoader, SectionContent } from '../components';
|
||||
|
||||
import { EMSESPSettings } from './EMSESPtypes';
|
||||
|
||||
@@ -19,303 +15,24 @@ type EMSESPSettingsControllerProps = RestControllerProps<EMSESPSettings>;
|
||||
class EMSESPSettingsController extends Component<EMSESPSettingsControllerProps> {
|
||||
|
||||
componentDidMount() {
|
||||
ValidatorForm.addValidationRule('isOptionalIP', optional(isIP));
|
||||
this.props.loadData();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<SectionContent title='EMS-ESP Settings' titleGutter>
|
||||
// <Container maxWidth="md" disableGutters>
|
||||
<SectionContent title='' titleGutter>
|
||||
<RestFormLoader
|
||||
{...this.props}
|
||||
render={props => (
|
||||
<EMSESPSettingsControllerForm {...props} />
|
||||
render={formProps => (
|
||||
<EMSESPSettingsForm {...formProps} />
|
||||
)}
|
||||
/>
|
||||
</SectionContent>
|
||||
// </Container>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default restController(EMSESP_SETTINGS_ENDPOINT, EMSESPSettingsController);
|
||||
|
||||
type EMSESPSettingsControllerFormProps = RestFormProps<EMSESPSettings>;
|
||||
|
||||
function EMSESPSettingsControllerForm(props: EMSESPSettingsControllerFormProps) {
|
||||
const { data, saveData, handleValueChange } = props;
|
||||
return (
|
||||
<ValidatorForm onSubmit={saveData}>
|
||||
<Box bgcolor="info.main" p={2} mt={2} mb={2}>
|
||||
<Typography variant="body1">
|
||||
Change the default settings on this page. For help click <Link target="_blank" href="https://emsesp.github.io/docs/#/Configure-firmware?id=settings" color="primary">{'here'}</Link>.
|
||||
</Typography>
|
||||
</Box>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
EMS Bus
|
||||
</Typography>
|
||||
<SelectValidator name="tx_mode"
|
||||
label="Tx Mode"
|
||||
value={data.tx_mode}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('tx_mode')}
|
||||
margin="normal">
|
||||
<MenuItem value={0}>0 - Off</MenuItem>
|
||||
<MenuItem value={1}>1 - Default</MenuItem>
|
||||
<MenuItem value={2}>2 - EMS+</MenuItem>
|
||||
<MenuItem value={3}>3 - HT3</MenuItem>
|
||||
<MenuItem value={4}>4 - Hardware</MenuItem>
|
||||
</SelectValidator>
|
||||
<SelectValidator name="ems_bus_id"
|
||||
label="Bus ID"
|
||||
value={data.ems_bus_id}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('ems_bus_id')}
|
||||
margin="normal">
|
||||
<MenuItem value={0x0B}>Service Key (0x0B)</MenuItem>
|
||||
<MenuItem value={0x0D}>Modem (0x0D)</MenuItem>
|
||||
<MenuItem value={0x0A}>Terminal (0x0A)</MenuItem>
|
||||
<MenuItem value={0x0F}>Time Module (0x0F)</MenuItem>
|
||||
<MenuItem value={0x12}>Alarm Module (0x12)</MenuItem>
|
||||
</SelectValidator>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Rx GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="rx_gpio"
|
||||
label="Rx GPIO pin"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.rx_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('rx_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Tx GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="tx_gpio"
|
||||
label="Tx GPIO pin"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.tx_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('tx_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:120']}
|
||||
errorMessages={['Tx delay is required', "Must be a number", "Must be 0 or higher", "Max value is 120"]}
|
||||
name="tx_delay"
|
||||
label="Tx delayed start (seconds)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.tx_delay}
|
||||
type="number"
|
||||
onChange={handleValueChange('tx_delay')}
|
||||
margin="normal"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
External Button
|
||||
</Typography>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Button GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="pbutton_gpio"
|
||||
label="Button GPIO pin"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.pbutton_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('pbutton_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
Dallas Sensor
|
||||
</Typography>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Dallas GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="dallas_gpio"
|
||||
label="Dallas GPIO pin (0=none)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.dallas_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('dallas_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.dallas_parasite}
|
||||
onChange={handleValueChange('dallas_parasite')}
|
||||
value="dallas_parasite"
|
||||
/>
|
||||
}
|
||||
label="Dallas Parasite Mode"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
LED
|
||||
</Typography>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['LED GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="led_gpio"
|
||||
label="LED GPIO pin (0=none)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.led_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('led_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.hide_led}
|
||||
onChange={handleValueChange('hide_led')}
|
||||
value="hide_led"
|
||||
/>
|
||||
}
|
||||
label="Invert/Hide LED"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
Shower
|
||||
</Typography>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.shower_timer}
|
||||
onChange={handleValueChange('shower_timer')}
|
||||
value="shower_timer"
|
||||
/>
|
||||
}
|
||||
label="Shower Timer"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.shower_alert}
|
||||
onChange={handleValueChange('shower_alert')}
|
||||
value="shower_alert"
|
||||
/>
|
||||
}
|
||||
label="Shower Alert"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
API
|
||||
</Typography>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.api_enabled}
|
||||
onChange={handleValueChange('api_enabled')}
|
||||
value="api_enabled"
|
||||
/>
|
||||
}
|
||||
label="Allow WEB API to write commands"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
Syslog
|
||||
</Typography>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.syslog_enabled}
|
||||
onChange={handleValueChange('syslog_enabled')}
|
||||
value="syslog_enabled"
|
||||
/>
|
||||
}
|
||||
label="Enable Syslog"
|
||||
/>
|
||||
<TextValidator
|
||||
validators={['isOptionalIP']}
|
||||
errorMessages={["Not a valid IP address"]}
|
||||
name="syslog_host"
|
||||
label="Syslog IP"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.syslog_host}
|
||||
onChange={handleValueChange('syslog_host')}
|
||||
margin="normal"
|
||||
/>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:65535']}
|
||||
errorMessages={['Port is required', "Must be a number", "Must be greater than 0 ", "Max value is 65535"]}
|
||||
name="syslog_port"
|
||||
label="Syslog Port (default 514)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.syslog_port}
|
||||
type="number"
|
||||
onChange={handleValueChange('syslog_port')}
|
||||
margin="normal"
|
||||
/>
|
||||
<SelectValidator name="syslog_level"
|
||||
label="Syslog Log Level"
|
||||
value={data.syslog_level}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('syslog_level')}
|
||||
margin="normal">
|
||||
<MenuItem value={-1}>OFF</MenuItem>
|
||||
<MenuItem value={3}>ERR</MenuItem>
|
||||
<MenuItem value={5}>NOTICE</MenuItem>
|
||||
<MenuItem value={6}>INFO</MenuItem>
|
||||
<MenuItem value={7}>DEBUG</MenuItem>
|
||||
<MenuItem value={8}>ALL</MenuItem>
|
||||
</SelectValidator>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:65535']}
|
||||
errorMessages={['Syslog Mark is required', "Must be a number", "Must be 0 or higher", "Max value is 10"]}
|
||||
name="syslog_mark_interval"
|
||||
label="Syslog Mark Interval (seconds, 0=off)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.syslog_mark_interval}
|
||||
type="number"
|
||||
onChange={handleValueChange('syslog_mark_interval')}
|
||||
margin="normal"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.trace_raw}
|
||||
onChange={handleValueChange('trace_raw')}
|
||||
value="trace_raw"
|
||||
/>
|
||||
}
|
||||
label="Trace EMS telegrams in raw format"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
Analog Input
|
||||
</Typography>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.analog_enabled}
|
||||
onChange={handleValueChange('analog_enabled')}
|
||||
value="analog_enabled"
|
||||
/>
|
||||
}
|
||||
label="Enable ADC"
|
||||
/>
|
||||
<br></br>
|
||||
<FormActions>
|
||||
<FormButton startIcon={<SaveIcon />} variant="contained" color="primary" type="submit">
|
||||
Save
|
||||
</FormButton>
|
||||
</FormActions>
|
||||
</ValidatorForm>
|
||||
);
|
||||
}
|
||||
|
||||
371
interface/src/project/EMSESPSettingsForm.tsx
Normal file
371
interface/src/project/EMSESPSettingsForm.tsx
Normal file
@@ -0,0 +1,371 @@
|
||||
import React from 'react';
|
||||
import { ValidatorForm, TextValidator, SelectValidator } from 'react-material-ui-form-validator';
|
||||
|
||||
import { Checkbox, Typography, Box, Link, withWidth, WithWidthProps } from '@material-ui/core';
|
||||
import SaveIcon from '@material-ui/icons/Save';
|
||||
import MenuItem from '@material-ui/core/MenuItem';
|
||||
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
|
||||
|
||||
import { RestFormProps, FormActions, FormButton, BlockFormControlLabel } from '../components';
|
||||
|
||||
import { isIP, optional } from '../validators';
|
||||
|
||||
import { EMSESPSettings } from './EMSESPtypes';
|
||||
|
||||
type EMSESPSettingsFormProps = RestFormProps<EMSESPSettings> & WithWidthProps;
|
||||
|
||||
class EMSESPSettingsForm extends React.Component<EMSESPSettingsFormProps> {
|
||||
|
||||
componentDidMount() {
|
||||
ValidatorForm.addValidationRule('isOptionalIP', optional(isIP));
|
||||
}
|
||||
|
||||
/*
|
||||
handleSliderChange = (name: keyof LedSettings) => (event: React.ChangeEvent<{}>, value: number | number[]) => {
|
||||
const { setData } = this.props;
|
||||
setData({ ...this.props.data!, [name]: value });
|
||||
}
|
||||
*/
|
||||
|
||||
render() {
|
||||
const { data, saveData, handleValueChange } = this.props;
|
||||
return (
|
||||
<ValidatorForm onSubmit={saveData}>
|
||||
<Box bgcolor="info.main" p={2} mt={2} mb={2}>
|
||||
<Typography variant="body1">
|
||||
Modify any EMS-ESP settings on this page. For help go to the <Link target="_blank" href="https://emsesp.github.io/docs/#/Configure-firmware32?id=ems-esp-settings" color="primary">{'wiki'}</Link>.
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
EMS Bus
|
||||
</Typography>
|
||||
|
||||
<Grid container spacing={1} direction="row" justify="flex-start" alignItems="flex-start">
|
||||
|
||||
<Grid item xs={5}>
|
||||
<SelectValidator name="tx_mode"
|
||||
label="Tx Mode"
|
||||
value={data.tx_mode}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('tx_mode')}
|
||||
margin="normal">
|
||||
<MenuItem value={0}>Off</MenuItem>
|
||||
<MenuItem value={1}>EMS</MenuItem>
|
||||
<MenuItem value={2}>EMS+</MenuItem>
|
||||
<MenuItem value={3}>HT3</MenuItem>
|
||||
<MenuItem value={4}>Hardware</MenuItem>
|
||||
</SelectValidator>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<SelectValidator name="ems_bus_id"
|
||||
label="Bus ID"
|
||||
value={data.ems_bus_id}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('ems_bus_id')}
|
||||
margin="normal">
|
||||
<MenuItem value={0x0B}>Service Key (0x0B)</MenuItem>
|
||||
<MenuItem value={0x0D}>Modem (0x0D)</MenuItem>
|
||||
<MenuItem value={0x0A}>Terminal (0x0A)</MenuItem>
|
||||
<MenuItem value={0x0F}>Time Module (0x0F)</MenuItem>
|
||||
<MenuItem value={0x12}>Alarm Module (0x12)</MenuItem>
|
||||
</SelectValidator>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:120']}
|
||||
errorMessages={['Tx delay is required', "Must be a number", "Must be 0 or higher", "Max value is 120"]}
|
||||
name="tx_delay"
|
||||
label="Tx start delay (seconds)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.tx_delay}
|
||||
type="number"
|
||||
onChange={handleValueChange('tx_delay')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
Board Profile
|
||||
</Typography>
|
||||
|
||||
<Box color="warning.main" p={0} mt={0} mb={0}>
|
||||
<Typography variant="body2">
|
||||
<i>Choose from a pre-configured board layout to automatically set the GPIO pins</i>
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<SelectValidator name="board_profile"
|
||||
label="Board Profile"
|
||||
value={data.board_profile}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('board_profile')}
|
||||
margin="normal">
|
||||
<MenuItem value={1}>Gateway S32</MenuItem>
|
||||
<MenuItem value={2}>Gateway E32 (LAN8720)</MenuItem>
|
||||
<MenuItem value={3}>NodeMCU 32S</MenuItem>
|
||||
<MenuItem value={4}>Lolin D32</MenuItem>
|
||||
<MenuItem value={5}>Olimex ESP32 Gateway (LAN8720)</MenuItem>
|
||||
<MenuItem value={6}>Ethernet (TLK110)</MenuItem>
|
||||
<MenuItem value={0}>Custom...</MenuItem>
|
||||
</SelectValidator>
|
||||
|
||||
{ (data.board_profile === 0) &&
|
||||
|
||||
<Grid container spacing={1} direction="row" justify="flex-start" alignItems="flex-start">
|
||||
<Grid item xs={4}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Rx GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="rx_gpio"
|
||||
label="Rx GPIO"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.rx_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('rx_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Tx GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="tx_gpio"
|
||||
label="Tx GPIO"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.tx_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('tx_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Button GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="pbutton_gpio"
|
||||
label="Button GPIO"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.pbutton_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('pbutton_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Dallas GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="dallas_gpio"
|
||||
label="Dallas GPIO (0=none)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.dallas_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('dallas_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['LED GPIO is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="led_gpio"
|
||||
label="LED GPIO (0=none)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.led_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('led_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
}
|
||||
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
Options
|
||||
</Typography>
|
||||
|
||||
{ data.dallas_gpio !== 0 &&
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.dallas_parasite}
|
||||
onChange={handleValueChange('dallas_parasite')}
|
||||
value="dallas_parasite"
|
||||
/>
|
||||
}
|
||||
label="Enable Dallas parasite mode"
|
||||
/>
|
||||
}
|
||||
{ data.led_gpio !== 0 &&
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.hide_led}
|
||||
onChange={handleValueChange('hide_led')}
|
||||
value="hide_led"
|
||||
/>
|
||||
}
|
||||
label="Invert LED"
|
||||
/>
|
||||
}
|
||||
|
||||
<Grid container spacing={0} direction="row" justify="flex-start" alignItems="flex-start">
|
||||
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.shower_timer}
|
||||
onChange={handleValueChange('shower_timer')}
|
||||
value="shower_timer"
|
||||
/>
|
||||
}
|
||||
label="Shower Timer"
|
||||
/>
|
||||
{/* <BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.shower_alert}
|
||||
onChange={handleValueChange('shower_alert')}
|
||||
value="shower_alert"
|
||||
/>
|
||||
}
|
||||
label="Shower Alert"
|
||||
/> */}
|
||||
</Grid>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.api_enabled}
|
||||
onChange={handleValueChange('api_enabled')}
|
||||
value="api_enabled"
|
||||
/>
|
||||
}
|
||||
label="Enable API write commands"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.analog_enabled}
|
||||
onChange={handleValueChange('analog_enabled')}
|
||||
value="analog_enabled"
|
||||
/>
|
||||
}
|
||||
label="Enable ADC"
|
||||
/>
|
||||
<br></br>
|
||||
<Typography variant="h6" color="primary" >
|
||||
Syslog
|
||||
</Typography>
|
||||
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.syslog_enabled}
|
||||
onChange={handleValueChange('syslog_enabled')}
|
||||
value="syslog_enabled"
|
||||
/>
|
||||
}
|
||||
label="Enable Syslog"
|
||||
/>
|
||||
|
||||
{ data.syslog_enabled &&
|
||||
<Grid container spacing={1} direction="row" justify="flex-start" alignItems="flex-start">
|
||||
<Grid item xs={5}>
|
||||
<TextValidator
|
||||
validators={['isOptionalIP']}
|
||||
errorMessages={["Not a valid IP address"]}
|
||||
name="syslog_host"
|
||||
label="IP"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.syslog_host}
|
||||
onChange={handleValueChange('syslog_host')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:65535']}
|
||||
errorMessages={['Port is required', "Must be a number", "Must be greater than 0 ", "Max value is 65535"]}
|
||||
name="syslog_port"
|
||||
label="Port"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.syslog_port}
|
||||
type="number"
|
||||
onChange={handleValueChange('syslog_port')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={5}>
|
||||
<SelectValidator name="syslog_level"
|
||||
label="Log Level"
|
||||
value={data.syslog_level}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={handleValueChange('syslog_level')}
|
||||
margin="normal">
|
||||
<MenuItem value={-1}>OFF</MenuItem>
|
||||
<MenuItem value={3}>ERR</MenuItem>
|
||||
<MenuItem value={5}>NOTICE</MenuItem>
|
||||
<MenuItem value={6}>INFO</MenuItem>
|
||||
<MenuItem value={7}>DEBUG</MenuItem>
|
||||
<MenuItem value={8}>ALL</MenuItem>
|
||||
</SelectValidator>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:65535']}
|
||||
errorMessages={['Syslog Mark is required', "Must be a number", "Must be 0 or higher", "Max value is 10"]}
|
||||
name="syslog_mark_interval"
|
||||
label="Mark Interval seconds (0=off)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.syslog_mark_interval}
|
||||
type="number"
|
||||
onChange={handleValueChange('syslog_mark_interval')}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.trace_raw}
|
||||
onChange={handleValueChange('trace_raw')}
|
||||
value="trace_raw"
|
||||
/>
|
||||
}
|
||||
label="Output EMS telegrams in raw format"
|
||||
/>
|
||||
</Grid>
|
||||
}
|
||||
|
||||
<br></br>
|
||||
<FormActions>
|
||||
<FormButton startIcon={<SaveIcon />} variant="contained" color="primary" type="submit">
|
||||
Save
|
||||
</FormButton>
|
||||
</FormActions>
|
||||
</ValidatorForm >
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default withWidth()(EMSESPSettingsForm);
|
||||
@@ -20,6 +20,7 @@ export interface EMSESPSettings {
|
||||
analog_enabled: boolean;
|
||||
pbutton_gpio: number;
|
||||
trace_raw: boolean;
|
||||
board_profile: number;
|
||||
}
|
||||
|
||||
export enum busConnectionStatus {
|
||||
|
||||
Reference in New Issue
Block a user