From 9082cae4e6f76c6f4594385adff2f399fdfe43e1 Mon Sep 17 00:00:00 2001 From: VladislavOstapov Date: Thu, 25 Jan 2024 19:39:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=82=D0=B5=D0=BA=D1=83?= =?UTF-8?q?=D1=89=D0=B8=D1=85=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B8=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B0,?= =?UTF-8?q?=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=82=20=D0=B4=D0=B0=D1=82=D1=8B=20?= =?UTF-8?q?=D0=B8=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/index-main.js | 26 +++++++++++++++++++++----- templates/index.html | 14 +++++++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) 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'