From 44477c79e6a9db35ee47f4da122c91d1aae4720b Mon Sep 17 00:00:00 2001 From: Kalyax Date: Wed, 9 Nov 2022 14:37:58 +0100 Subject: [PATCH] lights requests --- index.html | 28 +++++++++++++++++++++++++--- src/api_requests.js | 5 ----- src/main.js | 33 +++++++++++++++++++++++++++++---- src/style.css | 9 ++++++++- 4 files changed, 62 insertions(+), 13 deletions(-) delete mode 100644 src/api_requests.js diff --git a/index.html b/index.html index c4a5b05..0e2a985 100644 --- a/index.html +++ b/index.html @@ -6,11 +6,33 @@ Domotique - +
- DOMOTIQUE 3000 + DOMOTIQUE
-

t

+
+
+

Temperature

+

°C

+
+
+

Radiateur

+ + +
+ +
+

Volets roulants

+ + +
+ +
+

Eclairage

+ + +
+
diff --git a/src/api_requests.js b/src/api_requests.js deleted file mode 100644 index 6c41c8f..0000000 --- a/src/api_requests.js +++ /dev/null @@ -1,5 +0,0 @@ -import axios from "axios"; - -export default async function getTemp(){ - return await axios.get("/api/temp.php"); -} \ No newline at end of file diff --git a/src/main.js b/src/main.js index 4f5034d..bc839c6 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,31 @@ import './style.css'; -import getTemp from './api_requests.js'; -getTemp() -.then((data) => { - document.getElementById("test").innerHTML = data; +import axios from 'axios'; + +function buttonSwitch(state, button){ + button.innerText = state = 1 ? "Eteindre" : "Allumer"; +} + +async function getTemp(){ + return await axios.get("/api/temp.php"); +} + +async function getLightState(light){ + return await axios.get("/api/light_state.php?l="+light) +} + +async function setLightState(light){ + const pins = [7, 0, 2, 3, 12, 13, 14, 6]; + const req = await axios.post("/api/set_light.php", {light: pins[light]}) + console.log(req.data) +} + +window.setLightState = setLightState + +/*getLightState(0).then((data) => { + const button = document.getElementById("button-radiateur") + buttonSwitch(data.data, button) +})*/ + +getTemp().then((data) => { + document.getElementById("temp").innerHTML = data.data; }) \ No newline at end of file diff --git a/src/style.css b/src/style.css index bd6213e..cc2335e 100644 --- a/src/style.css +++ b/src/style.css @@ -1,3 +1,10 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; + +button{ + @apply bg-slate-400 text-red-400; +} +h1{ + @apply text-3xl bg-yellow-300 font-bold text-emerald-500; +} \ No newline at end of file