Init file

This commit is contained in:
2026-06-09 15:56:41 +05:30
commit bdb39de038
3 changed files with 29 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
async function fetchTemperature(zoneId) {
const res = await fetch(`/api/v1/zones/${zoneId}/primary/temperature`);
return res.json();
}
// Don't change this function signature
export async function attachChart(chartInstance, zoneId) {
await fetchTemperature(zoneId).then(temp => {
chartInstance.update(temp);
});
}
+9
View File
@@ -0,0 +1,9 @@
// This file can not be modified.
// Each zone has one corresponding chart.
// UI code calls attachChart for each zone and corresponding chart.
import { attachChart } from './data.js';
const zones = ['zone-a', 'zone-b', 'zone-c', /* ... */];
for (const zoneId of zones) {
const chart = createChartForZone(zoneId);
attachChart(chart, zoneId);
}