feat(web-app): add get values and update dependencies

This commit is contained in:
fastium
2025-05-06 17:12:54 +02:00
parent d6e3a5c1e0
commit c8c719099e
7 changed files with 242 additions and 51 deletions

View File

@@ -0,0 +1,47 @@
import { Prop } from "vue";
import { Serie } from "./Measures/Serie";
import { HttpClient } from "./Services/HttpClient";
import { TEMPERATURE, HUMIDITY, TYPE, VALUE } from "./const";
export class TimeSeriesManager {
private client: HttpClient;
constructor(client: HttpClient) {
this.client = client;
}
async getTimeSeriesData(
user: string,
room: string,
device: string
): Promise<{ temperature: Serie; humidity: Serie }> {
return this.client
.getValues(user, room, device)
.then((response) => {
const serie_temperature = new Serie(
TEMPERATURE,
response.data.filter((x: any) => x[TYPE] === TEMPERATURE),
user,
room,
device
);
const serie_humidity = new Serie(
HUMIDITY,
response.data.filter((x: any) => x[TYPE] === HUMIDITY),
user,
room,
device
);
return {
temperature: serie_temperature,
humidity: serie_humidity,
};
})
.catch((error) => {
console.error("Error fetching time series data:", error);
throw error; // Re-throw to allow calling code to handle it
});
}
}