diff --git a/html/growpi/package-lock.json b/html/growpi/package-lock.json index 8210a5b..c0cbd28 100644 --- a/html/growpi/package-lock.json +++ b/html/growpi/package-lock.json @@ -8,6 +8,7 @@ "name": "growpi", "version": "0.0.0", "dependencies": { + "date-format": "^4.0.14", "primevue": "^3.52.0", "vue": "^3.4.21" }, @@ -722,6 +723,14 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, + "node_modules/date-format": { + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", + "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", + "engines": { + "node": ">=4.0" + } + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", diff --git a/html/growpi/package.json b/html/growpi/package.json index afe6c05..16bfe65 100644 --- a/html/growpi/package.json +++ b/html/growpi/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "dependencies": { + "date-format": "^4.0.14", "primevue": "^3.52.0", "vue": "^3.4.21" }, diff --git a/html/growpi/src/App.vue b/html/growpi/src/App.vue index 8c85df4..0434722 100644 --- a/html/growpi/src/App.vue +++ b/html/growpi/src/App.vue @@ -3,6 +3,7 @@ import Button from 'primevue/button'; import Image from 'primevue/image'; import InputNumber from 'primevue/inputnumber'; import ToggleButton from 'primevue/togglebutton'; +import format from 'date-format' export default { data() { return { @@ -13,7 +14,8 @@ export default { water_primed: false, fan_state: false, pumpAmount: 150, - image_src: "/image" + image_src: "/image", + watering_history: [{ time: 1714976340, amount: 150, moisture_before_watering: 0.7490353 }] }; }, components: { ToggleButton, Button, InputNumber, Image }, @@ -25,6 +27,9 @@ export default { this.pump_state = to_bool(info.pump_state); this.temperature = info.temperature; this.soil_moisture = info.soil_moisture; + + let response = await fetch("/api/watering_history/10"); + this.watering_history = await response.json(); }, async updateImage() { this.image_src = "/image#" + new Date().getTime(); @@ -41,6 +46,9 @@ export default { async refreshImage() { await fetch("/api/refresh_image"); this.updateImage(); + }, + formatDate(timestamp) { + return format.asString('dd-MM-yyyy at hh:mm', new Date(timestamp * 1000)); } }, created() { @@ -125,6 +133,25 @@ function to_bool(state) { +
+ {{ formatDate(record.time) }} + | ++ {{ record.amount }} grams + | ++ {{ Math.round(record.moisture_before_watering * 100 * 100) / 100 }}% moisture + | +