2
0
mirror of https://github.com/ad1217/PrinterStatus synced 2024-11-22 07:23:48 -05:00
PrinterStatus/src/PrinterCard.vue

63 lines
1.6 KiB
Vue
Raw Normal View History

<template>
<div class="card">
<div class="card-header">{{ name || 'Unknown' }}</div>
<img v-if="name" class="webcam" :src="'/webcam/' + name" />
<div v-if="status">
<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>
</div>
<div>User: {{ status.job.user || '-' }}</div>
</div>
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
2020-09-25 18:55:58 -04:00
import prettyMilliseconds from 'pretty-ms';
import * as octoprint from './octoprint';
@Component
export default class PrinterCard extends Vue {
@Prop(String) readonly name!: string;
@Prop(Object) readonly status?: octoprint.CurrentOrHistoryPayload;
2020-09-25 18:55:58 -04:00
formatDuration(seconds: number): string {
return prettyMilliseconds(seconds * 1000);
}
}
</script>
<style lang="scss">
.card {
display: inline-block;
margin: 1em;
padding: 1em;
border-radius: 3px;
box-shadow: rgba(0, 0, 0, 0.2) 0px 3px 1px -2px,
rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px;
.card-header {
font-weight: bold;
font-size: 1.5em;
text-align: center;
padding-bottom: 0.25em;
}
.webcam {
width: 480px;
max-width: 100%;
}
}
</style>