2 <Generic :item="item" :title="state">
4 <p class="title is-4">{{ item.name }}</p>
5 <p class="subtitle is-6">
6 <template v-if="item.subtitle && !state">
9 <template v-if="!error && display == 'text' && statusClass == 'in-progress'">
10 <i class="fa-solid fa-gear mr-1"></i>
11 <b v-if="completion">{{ completion.toFixed() }}%</b>
12 <span class="separator mx-1"> | </span>
13 <span v-if="printTime" :title="`${toTime(printTimeLeft)} left`">
14 <i class="fa-solid fa-stopwatch mr-1"></i>
15 {{ toTime(printTime) }}
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>
24 <template v-if="!error && display == 'bar'">
27 class="progress is-primary"
30 :title="`${state} - ${completion.toFixed()}%, ${toTime(
37 <span v-if="error" :title="error">{{ error }}</span>
41 <i :class="['status', statusClass]" :title="state"></i>
47 import service from "@/mixins/service.js";
48 import Generic from "./Generic.vue";
68 statusClass: function () {
82 this.display = this.item.display == "bar" ? this.item.display : "text";
83 this.fetchPrinterStatus();
87 fetchStatus: async function () {
89 const response = await this.fetch(`api/job?apikey=${this.item.apikey}`);
90 this.printTime = response.progress.printTime;
91 this.printTimeLeft = response.progress.printTimeLeft;
92 this.completion = response.progress.completion;
93 this.state = response.state;
94 this.error = response.error;
96 this.error = `Fail to fetch octoprint data (${e.message})`;
100 fetchPrinterStatus: async function () {
102 const response = await this.fetch(`api/printer?apikey=${this.item.apikey}`);
103 this.printer = response;
104 this.error = response.error;
106 this.error = `Fail to fetch octoprint data (${e.message})`;
110 toTime: function (timastamp) {
111 return new Date(timastamp * 1000).toTimeString().substring(0, 5);
117 <style scoped lang="scss">
118 .fa-triangle-exclamation::before {