From 31fb88561061a18c27ec6f691782d9d470d0fdd0 Mon Sep 17 00:00:00 2001 From: Fabian Reinders Date: Sat, 7 May 2022 12:07:36 +0200 Subject: [PATCH 1/2] Front End: Change Weight Unit to Grams Change weight unit to grams as that's the unit returned by the API. --- public/js/app.js | 6 +++--- public/js/charts.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 969e333..a4d062b 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -186,7 +186,7 @@ async function updateCurrentData(data) { // Get values for current data displays and round them to 2 decimals let temperature = Number(latestRecord.temperature).toFixed(2); - let weight = Number(latestRecord.weight).toFixed(3); + let weight = Number(latestRecord.weight).toFixed(2); let humidity = Number(latestRecord.humidity).toFixed(2); let weightDelta = getWeightDeltaString(data); @@ -196,7 +196,7 @@ async function updateCurrentData(data) { document.querySelector('main').classList.remove('hide'); document.querySelector('#temperature').innerHTML = temperature + ' °C'; - document.querySelector('#weight').innerHTML = weight + ' kg'; + document.querySelector('#weight').innerHTML = weight + ' g'; document.querySelector('#weight-delta').innerHTML = weightDelta; document.querySelector('#humidity').innerHTML = humidity + ' %'; document.querySelector('#updated').innerHTML = measured; @@ -222,7 +222,7 @@ function getWeightDeltaString(data) { // Limit float to 2 decimal places weightDelta = weightDelta.toFixed(3); // Format HTML string with green color for weight growth and red color for weight decline - let weightDeltaString = weightDelta >= 0 ? `

+${weightDelta} kg

` : `

${weightDelta} kg

`; + let weightDeltaString = weightDelta >= 0 ? `

+${weightDelta} g

` : `

${weightDelta} g

`; return weightDeltaString; } diff --git a/public/js/charts.js b/public/js/charts.js index 6b90e59..d10a3e8 100644 --- a/public/js/charts.js +++ b/public/js/charts.js @@ -60,7 +60,7 @@ async function drawCharts(data) { */ async function drawCompareChart(data, separateWeight) { var compareData = [ - ['Tag', 'Temperatur (°C)', 'Gewicht (kg)', 'Luftfeuchtigkeit (%)'] + ['Tag', 'Temperatur (°C)', 'Gewicht (g)', 'Luftfeuchtigkeit (%)'] ]; for (row in data) { @@ -145,7 +145,7 @@ async function drawTempChart(data) { * @param {Array} data Array containing the data records that the graph should be generated from */ async function drawWeightChart(data) { - var weightData = [['Gemessen', 'Gewicht (kg)']]; + var weightData = [['Gemessen', 'Gewicht (g)']]; for (row in data) { var measured = new Date(data[row].measured); From ccc0f08f6b321b81f0e77c6369f7731b385a7359 Mon Sep 17 00:00:00 2001 From: AuxiliumCDNG Date: Sat, 7 May 2022 21:02:42 +0200 Subject: [PATCH 2/2] Chore: Change unit for telegram warning notifications --- api/insert_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/insert_data.py b/api/insert_data.py index aef43ef..30c4153 100644 --- a/api/insert_data.py +++ b/api/insert_data.py @@ -23,7 +23,7 @@ def insert_data(): if current["weight"] - float(r_data["w"]) > 0.5: notifications.Feed().push_notification("warning", "Gewichtsabfall!", - "Das Gewicht ist bei der aktuellen Messung um %skg abgefallen!" + "Das Gewicht ist bei der aktuellen Messung um %sg abgefallen!" % str(round(float(r_data["w"]) - current["weight"], 2))) except Exception as e: print("Error while performing data checks!\n"