new params

This commit is contained in:
2021-01-12 18:31:19 +01:00
parent 2cfd2afaee
commit 1598d4934a
5 changed files with 130 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { ValidatorForm } from 'react-material-ui-form-validator';
import { ValidatorForm, TextValidator } from 'react-material-ui-form-validator';
import { Typography, Box, Checkbox } from '@material-ui/core';
import SaveIcon from '@material-ui/icons/Save';
@@ -25,7 +25,7 @@ class FanStatusRestController extends Component<FanStatusRestControllerProps> {
render() {
return (
<SectionContent title='REST Controller' titleGutter>
<SectionContent title='Fan Control Settings' titleGutter>
<RestFormLoader
{...this.props}
render={props => (
@@ -48,9 +48,10 @@ function FanStatusRestControllerForm(props: FanStatusRestControllerFormProps) {
<ValidatorForm onSubmit={saveData}>
<Box bgcolor="primary.main" color="primary.contrastText" p={2} mt={2} mb={2}>
<Typography variant="body1">
The form below controls the LED via the RESTful service exposed by the ESP device.
The form below allow you to define the fan behaviour depending of the temperature.
</Typography>
</Box>
<BlockFormControlLabel
control={
<Checkbox
@@ -59,8 +60,60 @@ function FanStatusRestControllerForm(props: FanStatusRestControllerFormProps) {
color="primary"
/>
}
label="Fan State ?"
label="Enable Fan"
/>
<TextValidator
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:100']}
errorMessages={['Low Temperature required', "Must be a number", "Must be 0 or higher", "Max value is 100"]}
name="temperature_thres_low"
label="Low Temperature Threshold"
fullWidth
variant="outlined"
value={data.temperature_thres_low}
type="number"
onChange={handleValueChange('temperature_thres_low')}
margin="normal"
/>
<TextValidator
validators={['required', 'isNumber', 'minNumber:30', 'maxNumber:200']}
errorMessages={['High Temperature required', "Must be a number", "Must be 0 or higher", "Max value is 100"]}
name="temperature_thres_high"
label="High Temperature Threshold"
fullWidth
variant="outlined"
value={data.temperature_thres_high}
type="number"
onChange={handleValueChange('temperature_thres_high')}
margin="normal"
/>
<TextValidator
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
errorMessages={['Fan GPIO pin is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
name="fan_gpio"
label="Fan GPIO pin"
fullWidth
variant="outlined"
value={data.fan_gpio}
type="number"
onChange={handleValueChange('fan_gpio')}
margin="normal"
/>
<TextValidator
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:100']}
errorMessages={['Fan MAX is required', "Must be a number", "Must be 0 or higher", "Max value is 1024"]}
name="fan_max_speed"
label="Fan Max Speed"
fullWidth
variant="outlined"
value={data.fan_max_speed}
type="number"
onChange={handleValueChange('fan_max_speed')}
margin="normal"
/>
<FormActions>
<FormButton startIcon={<SaveIcon />} variant="contained" color="primary" type="submit">
Save

View File

@@ -13,4 +13,6 @@ export interface FanStatus {
temperature_thres_low : number;
temperature_thres_high : number;
fan_status : boolean;
fan_gpio : number;
fan_max_speed : number;
}