diff options
author | Zach Russell <zachatrocity@gmail.com> | 2023-05-02 01:27:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 09:27:27 +0200 |
commit | 6d2d9baf35b1772409162e86f6d4b7f9374edb2e (patch) | |
tree | 4c843a75f992a360b5cf0ba4fd84afe681e087d3 /src/components | |
parent | 1707f5adaddb90a126be4b60284921facb6d37ff (diff) | |
download | homer-6d2d9baf35b1772409162e86f6d4b7f9374edb2e.tar.gz homer-6d2d9baf35b1772409162e86f6d4b7f9374edb2e.tar.zst homer-6d2d9baf35b1772409162e86f6d4b7f9374edb2e.zip |
Fixed OctoPrint ‘text’ display when idle. (#607)
* Added moonraker support and temperature when idle
* removed config change
* Delete package-lock.json
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/services/OctoPrint.vue | 20 |
1 files changed, 19 insertions, 1 deletions
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 @@ | |||
6 | <template v-if="item.subtitle && !state"> | 6 | <template v-if="item.subtitle && !state"> |
7 | {{ item.subtitle }} | 7 | {{ item.subtitle }} |
8 | </template> | 8 | </template> |
9 | <template v-if="!error && display == 'text'"> | 9 | <template v-if="!error && display == 'text' && statusClass == 'in-progress'"> |
10 | <i class="fa-solid fa-gear mr-1"></i> | 10 | <i class="fa-solid fa-gear mr-1"></i> |
11 | <b v-if="completion">{{ completion.toFixed() }}%</b> | 11 | <b v-if="completion">{{ completion.toFixed() }}%</b> |
12 | <span class="separator mx-1"> | </span> | 12 | <span class="separator mx-1"> | </span> |
@@ -15,6 +15,12 @@ | |||
15 | {{ toTime(printTime) }} | 15 | {{ toTime(printTime) }} |
16 | </span> | 16 | </span> |
17 | </template> | 17 | </template> |
18 | <template v-if="!error && display == 'text' && statusClass == 'ready'"> | ||
19 | <i class="fa-solid fa-temperature-half mr-1"></i> | ||
20 | <b v-if="printer.temperature.bed">{{ printer.temperature.bed.actual.toFixed() }} C</b> | ||
21 | <span class="separator mx-1"> | </span> | ||
22 | <b v-if="printer.temperature.tool0">{{ printer.temperature.tool0.actual.toFixed() }} C</b> | ||
23 | </template> | ||
18 | <template v-if="!error && display == 'bar'"> | 24 | <template v-if="!error && display == 'bar'"> |
19 | <progress | 25 | <progress |
20 | v-if="completion" | 26 | v-if="completion" |
@@ -55,6 +61,7 @@ export default { | |||
55 | printTimeLeft: null, | 61 | printTimeLeft: null, |
56 | completion: null, | 62 | completion: null, |
57 | state: null, | 63 | state: null, |
64 | printer: null, | ||
58 | error: null, | 65 | error: null, |
59 | }), | 66 | }), |
60 | computed: { | 67 | computed: { |
@@ -73,6 +80,7 @@ export default { | |||
73 | }, | 80 | }, |
74 | created() { | 81 | created() { |
75 | this.display = this.item.display == "bar" ? this.item.display : "text"; | 82 | this.display = this.item.display == "bar" ? this.item.display : "text"; |
83 | this.fetchPrinterStatus(); | ||
76 | this.fetchStatus(); | 84 | this.fetchStatus(); |
77 | }, | 85 | }, |
78 | methods: { | 86 | methods: { |
@@ -89,6 +97,16 @@ export default { | |||
89 | console.error(e); | 97 | console.error(e); |
90 | } | 98 | } |
91 | }, | 99 | }, |
100 | fetchPrinterStatus: async function () { | ||
101 | try { | ||
102 | const response = await this.fetch(`api/printer?apikey=${this.item.apikey}`); | ||
103 | this.printer = response; | ||
104 | this.error = response.error; | ||
105 | } catch (e) { | ||
106 | this.error = `Fail to fetch octoprint data (${e.message})`; | ||
107 | console.error(e); | ||
108 | } | ||
109 | }, | ||
92 | toTime: function (timastamp) { | 110 | toTime: function (timastamp) { |
93 | return new Date(timastamp * 1000).toTimeString().substring(0, 5); | 111 | return new Date(timastamp * 1000).toTimeString().substring(0, 5); |
94 | }, | 112 | }, |