load indicator frontend

This commit is contained in:
Gwendolyn 2024-12-29 21:49:08 +01:00
parent 17266dd997
commit 474af6c4fc

View file

@ -184,23 +184,22 @@ c3nav = {
}); });
}, },
_load_indicator_timer: null, _load_indicator_timer: null,
load_load_indicator_data: function () { load_load_indicator_data: async function () {
return;
c3nav._load_indicator_timer = null; c3nav._load_indicator_timer = null;
c3nav_api.get('map/load') try {
.then(data => { const data = await c3nav_api.get('map/load');
if (data) { if (data) {
c3nav._location_load_groups = data; c3nav._location_load_groups = data;
} }
c3nav.update_load_data();
} catch (err) {
console.error(err);
}
if (c3nav._load_indicator_timer === null) { if (c3nav._load_indicator_timer === null) {
c3nav._load_indicator_timer = window.setTimeout(c3nav.load_load_indicator_data, c3nav._load_indicator_interval); c3nav._load_indicator_timer = window.setTimeout(c3nav.load_load_indicator_data, c3nav._load_indicator_interval);
} }
c3nav.update_load_data();
})
.catch(err => {
console.error(err);
});
}, },
_sort_labels: function (a, b) { _sort_labels: function (a, b) {
let result = (a[0].effective_label_settings.min_zoom || -10) - (b[0].effective_label_settings.min_zoom || -10); let result = (a[0].effective_label_settings.min_zoom || -10) - (b[0].effective_label_settings.min_zoom || -10);
@ -292,7 +291,6 @@ c3nav = {
c3nav._update_loadinfo_labels(); c3nav._update_loadinfo_labels();
}, },
_update_loadinfo_labels: function () { _update_loadinfo_labels: function () {
return;
if (!c3nav._loadIndicatorLayer) return; if (!c3nav._loadIndicatorLayer) return;
c3nav._loadIndicatorLayer.clearLayers(); c3nav._loadIndicatorLayer.clearLayers();
if (!c3nav._loadIndicatorControl.enabled) return; if (!c3nav._loadIndicatorControl.enabled) return;
@ -1812,17 +1810,17 @@ c3nav = {
}, },
}).addTo(c3nav.map); }).addTo(c3nav.map);
// c3nav._loadIndicatorControl = new ToggleControl({ c3nav._loadIndicatorControl = new ToggleControl({
// storageId: 'load_indicator', storageId: 'load_indicator',
// enabledIcon: c3nav._map_material_icon('bar_chart'), enabledIcon: c3nav._map_material_icon('bar_chart'),
// disabledIcon: c3nav._map_material_icon('bar_chart_off'), disabledIcon: c3nav._map_material_icon('bar_chart_off'),
// onEnable: () => { onEnable: () => {
// c3nav._update_loadinfo_labels(); c3nav._update_loadinfo_labels();
// }, },
// onDisable: () => { onDisable: () => {
// c3nav._update_loadinfo_labels(); c3nav._update_loadinfo_labels();
// }, },
// }).addTo(c3nav.map); }).addTo(c3nav.map);
// setup grid control // setup grid control
if ($map.is('[data-grid]')) { if ($map.is('[data-grid]')) {