From 6d2d9baf35b1772409162e86f6d4b7f9374edb2e Mon Sep 17 00:00:00 2001
From: Zach Russell <zachatrocity@gmail.com>
Date: Tue, 2 May 2023 01:27:27 -0600
Subject: =?UTF-8?q?Fixed=20OctoPrint=20=E2=80=98text=E2=80=99=20display=20?=
 =?UTF-8?q?when=20idle.=20(#607)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Added moonraker support and temperature when idle

* removed config change

* Delete package-lock.json
---
 src/components/services/OctoPrint.vue | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

(limited to 'src/components/services/OctoPrint.vue')

diff --git a/src/components/services/OctoPrint.vue b/src/components/services/OctoPrint.vue
index c5da8d9..1428d9a 100644
--- a/src/components/services/OctoPrint.vue
+++ b/src/components/services/OctoPrint.vue
@@ -6,7 +6,7 @@
         <template v-if="item.subtitle && !state">
           {{ item.subtitle }}
         </template>
-        <template v-if="!error && display == 'text'">
+        <template v-if="!error && display == 'text' && statusClass == 'in-progress'">
           <i class="fa-solid fa-gear mr-1"></i>
           <b v-if="completion">{{ completion.toFixed() }}%</b>
           <span class="separator mx-1"> | </span>
@@ -15,6 +15,12 @@
             {{ toTime(printTime) }}
           </span>
         </template>
+        <template v-if="!error && display == 'text' && statusClass == 'ready'">
+          <i class="fa-solid fa-temperature-half mr-1"></i>
+          <b v-if="printer.temperature.bed">{{ printer.temperature.bed.actual.toFixed() }} C</b>
+          <span class="separator mx-1"> | </span>
+          <b v-if="printer.temperature.tool0">{{ printer.temperature.tool0.actual.toFixed() }} C</b>
+        </template>
         <template v-if="!error && display == 'bar'">
           <progress
             v-if="completion"
@@ -55,6 +61,7 @@ export default {
     printTimeLeft: null,
     completion: null,
     state: null,
+    printer: null,
     error: null,
   }),
   computed: {
@@ -73,6 +80,7 @@ export default {
   },
   created() {
     this.display = this.item.display == "bar" ? this.item.display : "text";
+    this.fetchPrinterStatus();
     this.fetchStatus();
   },
   methods: {
@@ -89,6 +97,16 @@ export default {
         console.error(e);
       }
     },
+    fetchPrinterStatus: async function () {
+      try {
+        const response = await this.fetch(`api/printer?apikey=${this.item.apikey}`);
+        this.printer = response;
+        this.error = response.error;
+      } catch (e) {
+        this.error = `Fail to fetch octoprint data (${e.message})`;
+        console.error(e);
+      }
+    },
     toTime: function (timastamp) {
       return new Date(timastamp * 1000).toTimeString().substring(0, 5);
     },
-- 
cgit v1.2.3

