Almost there
This commit is contained in:
1939
webapp/dist/main.js
vendored
1939
webapp/dist/main.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,4 +1,5 @@
|
|||||||
import Chart, {ChartPoint} from "chart.js";
|
//@ts-ignore
|
||||||
|
import Chart, {ChartPoint} from "chart.js/dist/Chart.bundle.min";
|
||||||
import {generateClimateChartConfig} from "./climateChartConfig";
|
import {generateClimateChartConfig} from "./climateChartConfig";
|
||||||
|
|
||||||
interface Snapshot {
|
interface Snapshot {
|
||||||
@@ -14,7 +15,6 @@ interface SnapshotRecords {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ClimateChart {
|
class ClimateChart {
|
||||||
private readonly urlEndpoint: string;
|
|
||||||
private chart: Chart | null;
|
private chart: Chart | null;
|
||||||
private latestSnapshot: Snapshot | null;
|
private latestSnapshot: Snapshot | null;
|
||||||
private onLoadedCallback: () => void = () => {};
|
private onLoadedCallback: () => void = () => {};
|
||||||
@@ -29,8 +29,6 @@ class ClimateChart {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(`invalid minutes passed to display in chart: ${minutesDisplayed}`);
|
throw new Error(`invalid minutes passed to display in chart: ${minutesDisplayed}`);
|
||||||
}
|
}
|
||||||
this.urlEndpoint = this.rootUrl + "data/";
|
|
||||||
this.urlEndpoint += "since/" + this.minutesDisplayed;
|
|
||||||
this.initChart().catch((e) => {this.onErrorCallback(e);});
|
this.initChart().catch((e) => {this.onErrorCallback(e);});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +46,7 @@ class ClimateChart {
|
|||||||
|
|
||||||
private async getInitialDataBlob(): Promise<SnapshotRecords> {
|
private async getInitialDataBlob(): Promise<SnapshotRecords> {
|
||||||
try {
|
try {
|
||||||
const data = await fetch(this.urlEndpoint);
|
const data = await fetch(this.rootUrl + "/data?since" + (new Date().getTime() - this.minutesDisplayed * 60 * 1000));
|
||||||
return await data.json();
|
return await data.json();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
@@ -27,11 +27,8 @@ const webpack = require('webpack');
|
|||||||
|
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: 'development',
|
mode: 'production',
|
||||||
entry: './src/main.ts',
|
entry: './src/main.ts',
|
||||||
plugins: [new webpack.ProgressPlugin()],
|
plugins: [new webpack.ProgressPlugin()],
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user