From 59ba65acfc8df48ec781b46bd619dddea59f0081 Mon Sep 17 00:00:00 2001 From: feeling Date: Tue, 12 Jan 2021 14:45:26 +0100 Subject: [PATCH] a --- interface/src/project/FanCtlProject.tsx | 3 +- interface/src/project/FanCtlSettings.tsx | 71 ++++++++++++++++++++++++ interface/src/project/types.ts | 1 + 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 interface/src/project/FanCtlSettings.tsx diff --git a/interface/src/project/FanCtlProject.tsx b/interface/src/project/FanCtlProject.tsx index 2bc67c4..a156dad 100644 --- a/interface/src/project/FanCtlProject.tsx +++ b/interface/src/project/FanCtlProject.tsx @@ -7,6 +7,7 @@ import { PROJECT_PATH } from '../api'; import { MenuAppBar } from '../components'; import { AuthenticatedRoute } from '../authentication'; import FanCtlControl from './FanCtlControl'; +import FanCtlSettings from './FanCtlSettings'; class FanCtlProject extends Component { @@ -23,7 +24,7 @@ class FanCtlProject extends Component { - + diff --git a/interface/src/project/FanCtlSettings.tsx b/interface/src/project/FanCtlSettings.tsx new file mode 100644 index 0000000..f05b975 --- /dev/null +++ b/interface/src/project/FanCtlSettings.tsx @@ -0,0 +1,71 @@ +import React, { Component } from 'react'; +import { ValidatorForm } from 'react-material-ui-form-validator'; + +import { Typography, Box, Checkbox } from '@material-ui/core'; +import SaveIcon from '@material-ui/icons/Save'; + +import { ENDPOINT_ROOT } from '../api'; +import { restController, RestControllerProps, RestFormLoader, RestFormProps, FormActions, FormButton, SectionContent, BlockFormControlLabel } from '../components'; + +import { FanStatus } from './types'; + +export const FAN_STATUS_ENDPOINT = ENDPOINT_ROOT + "fanState"; + + + + + +type FanStatusRestControllerProps = RestControllerProps; + +class FanStatusRestController extends Component { + + componentDidMount() { + this.props.loadData(); + } + + render() { + return ( + + ( + + )} + /> + + ) + } + +} + +export default restController(FAN_STATUS_ENDPOINT, FanStatusRestController); + +type FanStatusRestControllerFormProps = RestFormProps; + +function FanStatusRestControllerForm(props: FanStatusRestControllerFormProps) { + const { data, saveData, handleValueChange } = props; + return ( + + + + The form below controls the LED via the RESTful service exposed by the ESP device. + + + + } + label="Fan State ?" + /> + + } variant="contained" color="primary" type="submit"> + Save + + + + ); +} diff --git a/interface/src/project/types.ts b/interface/src/project/types.ts index af78b40..e4ee43a 100644 --- a/interface/src/project/types.ts +++ b/interface/src/project/types.ts @@ -12,4 +12,5 @@ export interface FanStatus { fan_speed : number; temperature_thres_low : number; temperature_thres_high : number; + fan_status : boolean; } \ No newline at end of file