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'">
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 == 'bar'">
21 class="progress is-primary"
24 :title="`${state} - ${completion.toFixed()}%, ${toTime(
31 <span v-if="error" :title="error">{{ error }}</span>
35 <i :class="['status', statusClass]" :title="state"></i>
41 import service from "@/mixins/service.js";
42 import Generic from "./Generic.vue";
61 statusClass: function () {
75 this.display = this.item.display == "bar" ? this.item.display : "text";
79 fetchStatus: async function () {
81 const response = await this.fetch(`api/job?apikey=${this.item.apikey}`);
82 this.printTime = response.progress.printTime;
83 this.printTimeLeft = response.progress.printTimeLeft;
84 this.completion = response.progress.completion;
85 this.state = response.state;
86 this.error = response.error;
88 this.error = `Fail to fetch octoprint data (${e.message})`;
92 toTime: function (timastamp) {
93 return new Date(timastamp * 1000).toTimeString().substring(0, 5);
99 <style scoped lang="scss">
100 .fa-triangle-exclamation::before {