feat(web-app): add unknown case for type of measure

This commit is contained in:
fastium
2025-05-20 09:58:15 +02:00
parent 71f8883f16
commit 803f93041b
2 changed files with 19 additions and 6 deletions

View File

@@ -22,8 +22,14 @@ export class Serie {
this._device = device; this._device = device;
} }
public getLabel(): string { public getLabel(): String {
return `${this._type} - ${this._user} - ${this._room} - ${this._device}`; if (this._type === TEMPERATURE) {
return "Temperature [°C]";
} else if (this._type === HUMIDITY) {
return "Humidity [%]";
} else {
return "Unknown";
}
} }
public getSerie(): any { public getSerie(): any {
@@ -47,6 +53,16 @@ export class Serie {
backgroundColor: "rgba(54, 162, 235, 0.2)", backgroundColor: "rgba(54, 162, 235, 0.2)",
borderWidth: 1, borderWidth: 1,
}; };
} else {
return {
label: "Unknown",
data: this._data.map((v: any) => {
return { x: v.time, y: v.value };
}),
borderColor: "rgba(255, 206, 86, 1)",
backgroundColor: "rgba(255, 206, 86, 0.2)",
borderWidth: 1,
};
} }
} }
} }

View File

@@ -48,10 +48,7 @@ export default defineComponent({
}, },
setup(props) { setup(props) {
const chartData = computed(() => { const chartData = computed(() => {
if ( if ((props.manager as TimeSeriesManager).series.value as Serie[]) {
props.manager ||
((props.manager as TimeSeriesManager).series.value as Serie[])
) {
let series_prepared = (props.manager.series.value as Serie[]).map( let series_prepared = (props.manager.series.value as Serie[]).map(
(s: Serie) => { (s: Serie) => {
return s.getSerie(); return s.getSerie();