feat(web-app): consistant inter-component communication

- All data are managed from the TimeSeriesManager.
- All other props of componenets were deleted
This commit is contained in:
fastium
2025-05-20 09:46:36 +02:00
parent a83257eb49
commit 71f8883f16
4 changed files with 75 additions and 116 deletions

View File

@@ -57,16 +57,17 @@ export class TimeSeriesManager {
},
];
error = ref(false);
loading = ref("");
series = ref<Serie[]>([]);
constructor(client: HttpClient) {
this.client = client;
}
async getTimeSeriesData(
user: string,
room: string,
device: string
): Promise<Serie[]> {
return this.client
async getTimeSeriesData() {
this.client
.getValues(
this.selected_user.tag,
this.selected_room.tag,
@@ -112,20 +113,20 @@ export class TimeSeriesManager {
const temperatureSerie = new Serie(
TEMPERATURE,
temperatureRecordsProcessed,
user,
room,
device
this.selected_user.user,
this.selected_room.room,
this.selected_device.device
);
const humiditySerie = new Serie(
HUMIDITY,
humidityRecordProcessed,
user,
room,
device
this.selected_user.user,
this.selected_room.room,
this.selected_device.device
);
return [temperatureSerie, humiditySerie];
this.series.value = [temperatureSerie, humiditySerie];
})
.catch((error) => {
console.error("Error fetching time series data:", error);
@@ -133,10 +134,16 @@ export class TimeSeriesManager {
});
}
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;
});
async getNewValue() {
this.client
.newValue(
this.selected_user.user,
this.selected_room.room,
this.selected_device.device
)
.catch((error) => {
console.error("Error asking new values:", this.selected_device.device);
throw error;
});
}
}