From 63429dafa2ca3f94861e364aee140a42de24eb53 Mon Sep 17 00:00:00 2001 From: fastium Date: Wed, 14 May 2025 17:47:05 +0200 Subject: [PATCH] feat(web-app): add temperature request The POST request was added to ask a new temperature, but didn't get the new one. --- web-app/src/App.vue | 3 +++ web-app/src/Services/HttpClient.ts | 23 +++++++++++++++++++++++ web-app/src/TimeSeriesManager.ts | 7 +++++++ 3 files changed, 33 insertions(+) diff --git a/web-app/src/App.vue b/web-app/src/App.vue index 017b71a..d0fa3c0 100644 --- a/web-app/src/App.vue +++ b/web-app/src/App.vue @@ -41,6 +41,9 @@ import { URL, USERNAME, PASSWORD, USER, ROOM, DEVICE, APP_NAME } from "./const"; import { Serie } from "./Measures/Serie"; let httpClient = new HttpClient(URL, USERNAME, PASSWORD); + +// console.log(httpClient.newValue(URL, USERNAME, PASSWORD)); + let manager = new TimeSeriesManager(httpClient); export default defineComponent({ diff --git a/web-app/src/Services/HttpClient.ts b/web-app/src/Services/HttpClient.ts index 0636415..10fdde9 100644 --- a/web-app/src/Services/HttpClient.ts +++ b/web-app/src/Services/HttpClient.ts @@ -36,6 +36,7 @@ export class HttpClient { private getAuthHeader() { return { Authorization: `Basic ${btoa(`${this._username}:${this._password}`)}`, + "Content-Type": "application/json", }; } @@ -54,4 +55,26 @@ export class HttpClient { }); return response; } + + async newValue( + user: string, + room: string, + device: string + ): Promise> { + const response = await axios.post( + `${BASE}${this._url}/${RACLETTE}`, + { + command: "MEASURE_NEW", + }, + { + headers: this.getAuthHeader(), + params: { + user: user, + room: room, + device: device, + }, + } + ); + return response; + } } diff --git a/web-app/src/TimeSeriesManager.ts b/web-app/src/TimeSeriesManager.ts index 9183073..8b58cd2 100644 --- a/web-app/src/TimeSeriesManager.ts +++ b/web-app/src/TimeSeriesManager.ts @@ -77,4 +77,11 @@ export class TimeSeriesManager { throw error; // Re-throw to allow calling code to handle it }); } + + async getNewValue(user: string, room: string, device: string) { + this.client.newValue(user, room, device).catch((error) => { + console.error("Error asking new values:", error); + throw error; + }); + } }