diff --git a/src/Core.js b/src/Core.js index 5238e7f..009ceea 100644 --- a/src/Core.js +++ b/src/Core.js @@ -28,8 +28,8 @@ function Core() { - dispatch(setPlugin("sideMirrors"))} primary - label="Side Mirrors" /> + dispatch(setPlugin("petMode"))} primary + label="Pet Mode" /> {dummyButtons.map(i => )} diff --git a/src/plugins/PetMode.js b/src/plugins/PetMode.js new file mode 100644 index 0000000..2645001 --- /dev/null +++ b/src/plugins/PetMode.js @@ -0,0 +1,37 @@ +import React, { useState, useEffect } from "react"; +import PropTypes from "prop-types"; +import GenericPageWithIcon from "./GenericPageWithIcon"; +import { Sun } from "grommet-icons"; +import axios from "axios"; +import { CAR_API } from "../config"; + +function PetMode(props) { + const [ temp, setTemp ] = useState(null); + useEffect(() => { + axios.get(`${CAR_API}data/InsideTemperature`) + .then(resp => setTemp(resp.data.value)); + const id = setInterval( + () => axios.get(`${CAR_API}data/InsideTemperature`) + .then(resp => setTemp(resp.data.value)), + 1000 + ); + return () => clearInterval(id); + }, []); + if (temp === null) + return <>>; + return ( + 35 ? "un": ""}safe.`} + icon={ 35 ? "#E30000": "plain"} size="xlarge" />} + close={props.close} + />); +} + +PetMode.propTypes = { + close: PropTypes.func +}; + +PetMode.pluginName = "Temperature"; + +export default PetMode; diff --git a/src/plugins/index.js b/src/plugins/index.js index ca8bcac..3e332fd 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -2,10 +2,12 @@ import Warning from "./Warning"; import Manual from "./Manual"; import Temperature from "./Temperature"; import Accident from "./Accident"; +import PetMode from "./PetMode"; export default { warning: Warning, manual: Manual, temperature: Temperature, accident: Accident, + petMode: PetMode, }; diff --git a/src/sample.config.js b/src/sample.config.js index 12a0c13..b920a6d 100644 --- a/src/sample.config.js +++ b/src/sample.config.js @@ -1,5 +1,6 @@ const WS_BASE = "http://localhost:5050/"; const TG_API = "xxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxx"; const TG_USERID = 123456789; +const CAR_API = "http://localhost:5000/"; -export { WS_BASE, TG_API, TG_USERID }; +export { WS_BASE, TG_API, TG_USERID, CAR_API };