2019-09-20 15:46:05 -04:00
|
|
|
<template>
|
|
|
|
<div class="card">
|
2021-11-03 15:04:18 -04:00
|
|
|
<h3 class="card-header">{{ name || 'Unknown' }}</h3>
|
|
|
|
<img class="card-img webcam" :src="'/webcam/' + slug" />
|
2021-11-03 16:01:24 -04:00
|
|
|
<div class="card-body" v-if="status">
|
2019-09-20 15:46:05 -04:00
|
|
|
<div>{{ status.state.text }}</div>
|
|
|
|
<div>Job File Name: {{ status.job.file.name || 'None' }}</div>
|
2020-09-25 18:55:58 -04:00
|
|
|
<div v-if="status.progress.completion">
|
|
|
|
<div>
|
|
|
|
Job Completion:
|
|
|
|
{{ status.progress.completion.toFixed(2) }}%
|
|
|
|
<progress :value="status.progress.completion" max="100"></progress>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
Job Time: {{ formatDuration(status.progress.printTime) }} elapsed,
|
|
|
|
{{ formatDuration(status.progress.printTimeLeft) }} left
|
|
|
|
</div>
|
2019-09-20 15:46:05 -04:00
|
|
|
</div>
|
|
|
|
<div>User: {{ status.job.user || '-' }}</div>
|
|
|
|
</div>
|
2021-11-03 16:01:24 -04:00
|
|
|
<div class="card-footer">Last updated {{ lastUpdateString }}</div>
|
2019-09-20 15:46:05 -04:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-10-11 21:28:12 -04:00
|
|
|
<script setup lang="ts">
|
2021-11-03 16:01:24 -04:00
|
|
|
import { computed } from 'vue';
|
2020-09-25 18:55:58 -04:00
|
|
|
import prettyMilliseconds from 'pretty-ms';
|
2019-09-20 15:46:05 -04:00
|
|
|
|
2021-10-11 21:28:12 -04:00
|
|
|
import * as octoprint from '../types/octoprint';
|
2019-09-20 15:46:05 -04:00
|
|
|
|
2021-11-03 16:01:24 -04:00
|
|
|
const props = defineProps<{
|
2021-10-13 23:25:28 -04:00
|
|
|
slug: string;
|
|
|
|
name?: string;
|
2021-11-03 16:01:24 -04:00
|
|
|
lastUpdate: Date;
|
|
|
|
now: Date;
|
2021-10-11 21:28:12 -04:00
|
|
|
status: octoprint.CurrentOrHistoryPayload | null;
|
|
|
|
}>();
|
2020-09-25 18:55:58 -04:00
|
|
|
|
2021-10-11 21:28:12 -04:00
|
|
|
function formatDuration(seconds: number): string {
|
|
|
|
return prettyMilliseconds(seconds * 1000);
|
2019-09-20 15:46:05 -04:00
|
|
|
}
|
2021-11-03 16:01:24 -04:00
|
|
|
|
|
|
|
const lastUpdateString = computed(() => {
|
|
|
|
if (props.status !== null) {
|
|
|
|
const elapsed = props.now.getTime() - props.lastUpdate.getTime();
|
|
|
|
if (elapsed < 10_000) {
|
|
|
|
return 'seconds ago';
|
|
|
|
} else if (elapsed < 60_000) {
|
|
|
|
return 'less than a minute ago';
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
prettyMilliseconds(elapsed, { compact: true, verbose: true }) + ' ago'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-09-20 15:46:05 -04:00
|
|
|
</script>
|