feat(web-app): add get values and update dependencies
This commit is contained in:
47
web-app/src/TimeSeriesManager.ts
Normal file
47
web-app/src/TimeSeriesManager.ts
Normal 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
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user