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