feat(web-app): add temperature request

The POST request was added to ask a new temperature, but didn't get the
new one.
This commit is contained in:
fastium
2025-05-14 17:47:05 +02:00
parent 563193f4cf
commit 63429dafa2
3 changed files with 33 additions and 0 deletions

View File

@@ -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({

View File

@@ -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<AxiosResponse<any, any>> {
const response = await axios.post(
`${BASE}${this._url}/${RACLETTE}`,
{
command: "MEASURE_NEW",
},
{
headers: this.getAuthHeader(),
params: {
user: user,
room: room,
device: device,
},
}
);
return response;
}
}

View File

@@ -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;
});
}
}