Reorder & optimise loading of UI elements

This commit is contained in:
Starbeamrainbowlabs 2019-06-30 18:40:26 +01:00
parent c91a895f9d
commit 98ebc02ec7
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 12 additions and 10 deletions

View File

@ -41,6 +41,9 @@ class MapManager {
this.map.attributionControl.addAttribution("Data: <a href='https://connectedhumber.org/'>Connected Humber</a>");
this.map.attributionControl.addAttribution("<a href='https://github.com/ConnectedHumber/Air-Quality-Web/'>Air Quality Web</a> by <a href='https://starbeamrainbowlabs.com/'>Starbeamrainbowlabs</a>");
// Setup the UI
this.ui = new UI(Config, this);
this.ui.setup().then(() => console.log("[map] UI setup complete."));
// Load the device information
this.device_data = new DeviceData();
@ -49,11 +52,13 @@ class MapManager {
// Add the device markers
console.info("[map] Loading device markers....");
this.setup_device_markers()
.then(() => console.info("[map] Device markers loaded successfully."))
.then(this.setup_overlay.bind(this))
.then(this.setup_layer_control.bind(this))
.then(() => document.querySelector("main").classList.remove("working-visual"));
Promise.all([
this.setup_device_markers.bind(this)()
.then(() => console.info("[map] Device markers loaded successfully.")),
this.setup_overlay.bind(this)()
.then(this.setup_layer_control.bind(this))
]).then(() => document.querySelector("main").classList.remove("working-visual"));
// Add the heatmap
// console.info("[map] Loading heatmap....");
@ -62,9 +67,6 @@ class MapManager {
// // ...and the time dimension
// .then(this.setup_time_dimension.bind(this))
// .then(() => console.info("[map] Time dimension initialised."));
this.ui = new UI(Config, this);
this.ui.setup().then(() => console.log("[map] UI setup complete."));
}
async setup_overlay() {

View File

@ -43,6 +43,8 @@ class UI {
}
async setup() {
await show_changelog(true);
this.reading_types = JSON.parse(
await GetFromUrl(`${this.config.api_root}?action=list-reading-types`)
);
@ -75,8 +77,6 @@ class UI {
]);
this.ui_panel.setIndex("Reading Type", this.reading_types.findIndex((type) => type.short_descr == "PM25"));
await show_changelog(true);
await this.tour.run_once();
}
}