Moved the webapp to a webpack with some typescript, updated server wtih new endpoints

This commit is contained in:
Daniel Ledda
2020-11-14 01:06:29 +01:00
parent 6dba158ff0
commit 4e57a8eb47
21 changed files with 11118 additions and 20964 deletions

27
webapp/src/main.ts Normal file
View File

@@ -0,0 +1,27 @@
import ClimateChart from "./ClimateChart";
const ROOT_URL: string = "climate/";
const CHART_DOM_ID: string = "myChart";
function createClimateChart() {
const pathname = window.location.pathname;
let minutesDisplayed = 60;
const argsStart = pathname.search(/\?minute-span=/);
if (argsStart !== -1) {
const parsedMins = Number(pathname[12]);
if (!isNaN(parsedMins) && parsedMins > 0) {
minutesDisplayed = parsedMins;
}
}
return new ClimateChart(ROOT_URL, CHART_DOM_ID, minutesDisplayed);
}
const overlay = document.createElement('div');
overlay.innerText = 'Loading data...';
overlay.className = 'overlay';
document.getRootNode().appendChild(overlay);
const climateChart = createClimateChart();
climateChart.onLoaded(() => {
overlay.classList.add('hidden');
})