commit bdb39de0380d1862389701fea6684ab1e7c3f601 Author: bendtherules Date: Tue Jun 9 15:56:41 2026 +0530 Init file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..acad114 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +node_modules/ +/.pnp +.pnp.js +.DS_Store +npm-debug.log* +yarn-debug.log* +yarn-error.log* +package-lock.json +.env diff --git a/src/data.js b/src/data.js new file mode 100644 index 0000000..f8ae084 --- /dev/null +++ b/src/data.js @@ -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); + }); +} diff --git a/src/ui.js b/src/ui.js new file mode 100644 index 0000000..0c0af46 --- /dev/null +++ b/src/ui.js @@ -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); +}