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,48 @@
import { TEMPERATURE, HUMIDITY, TYPE, VALUE } from "../const";
export class Serie {
private _type: string;
private _data: { time: number; value: number }[];
private _user: string;
private _room: string;
private _device: string;
constructor(
type: string,
data: { time: number; value: number }[],
user: string,
room: string,
device: string
) {
this._type = type;
this._data = data;
this._user = user;
this._room = room;
this._device = device;
}
public getLabel(): string {
return `${this._user} - ${this._room} - ${this._device}`;
}
public getSerie(): any {
if (this._type === TEMPERATURE) {
return {
label: this.getLabel(),
data: this._data,
borderColor: "rgba(255, 99, 132, 1)",
backgroundColor: "rgba(255, 99, 132, 0.2)",
borderWidth: 1,
};
} else if (this._type === HUMIDITY) {
return {
label: this.getLabel(),
data: this._data,
borderColor: "rgba(54, 162, 235, 1)",
backgroundColor: "rgba(54, 162, 235, 0.2)",
borderWidth: 1,
};
}
}
}