diff --git a/static/js/index-main.js b/static/js/index-main.js index d5cbd38..e736826 100644 --- a/static/js/index-main.js +++ b/static/js/index-main.js @@ -76,13 +76,26 @@ async function makeRequest(url) { } async function loadChartData() { - let chartTime = localStorage.getItem("settings-chart-time") - - return (await makeRequest('/fetch/tank-chart?days=' + chartTime))['tank_chart'] + try { + const chartTime = localStorage.getItem("settings-chart-time") + const res = await makeRequest('/fetch/tank-chart?days=' + chartTime) + document.getElementById('chart-update-error').hidden = true + return res['tank_chart'] + } catch (e) { + document.getElementById('chart-update-error').hidden = false + return undefined + } } async function loadLastUpdates() { - return (await makeRequest('/fetch/stats'))['stats'] + try { + const res = await makeRequest('/fetch/stats') + document.getElementById('stats-update-error').hidden = true + return res['stats'] + } catch (e) { + document.getElementById('stats-update-error').hidden = false + return undefined + } } /** @@ -352,7 +365,10 @@ const updateFunctions = { } async function updateStatus() { - let dataset = await loadLastUpdates() + const dataset = await loadLastUpdates() + if (dataset === undefined) { + return + } for (let id in updateFunctions) { let element = document.getElementById(id) diff --git a/templates/index.html b/templates/index.html index 900971a..7ab79e8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -36,10 +36,21 @@ #canvas-wrapper { max-width: 1000px; } + + .error-message { + border: 2px var(--text-bad) solid; + border-radius: 8px; + margin: 0.5em 0; + padding: 0.5em; + color: var(--text-bad); + text-align: center; + } {% endblock %} {% block content %} + +
{% if perms.logs_service.view_pump_stats %} @@ -134,7 +145,8 @@ x: { type: 'time', time: { - unit: 'day' + unit: 'day', + tooltipFormat: DATETIME_FORMAT, }, scaleLabel: { labelString: 'Timestamp'