feat: gcode-files & jobqueue on dashboard (#726)

This commit is contained in:
Stefan Dej authored and GitHub committed 2022-05-11 18:32:42 +02:00
1 parent 2cf1a13129
commit 64eed0b6bd
23 files changed
+1745 -762

No files matched your search

+9 -6
View File
@@ -13,12 +13,7 @@
<panel
card-class="editor-dialog"
:icon="isWriteable ? mdiFileDocumentEditOutline : mdiFileDocumentOutline"
:title="
(filepath ? filepath.slice(1) + '/' : '') +
filename +
' ' +
(isWriteable ? changedOutput : '(' + $t('Editor.FileReadOnly') + ')')
">
:title="title">
<template #buttons>
<v-btn
v-if="restartServiceName === 'klipper'"
@@ -255,6 +250,14 @@ export default class TheEditor extends Mixins(BaseMixin) {
return this.$store.state.gui.editor.escToClose ?? false
}
get title() {
const title = `${this.filepath}/${this.filename}`
if (!this.isWriteable) return `${title} (${this.$t('Editor.FileReadOnly')})`
return `${title} ${this.changedOutput}`
}
cancelDownload() {
this.$store.dispatch('editor/cancelLoad')
}
@@ -0,0 +1,80 @@
<template>
<v-dialog v-model="bool" :max-width="dialogWidth">
<v-card>
<v-img v-if="file.big_thumbnail" contain :src="file.big_thumbnail"></v-img>
<v-card-title class="headline">{{ $t('Dialogs.StartPrint.Headline') }}</v-card-title>
<v-card-text class="pb-0">
{{ $t('Dialogs.StartPrint.DoYouWantToStartFilename', { filename: file.filename }) }}
</v-card-text>
<template v-if="moonrakerComponents.includes('timelapse')">
<v-divider class="mt-3 mb-2"></v-divider>
<v-card-text class="pb-0">
<settings-row :title="$t('Dialogs.StartPrint.Timelapse')">
<v-switch v-model="timelapseEnabled" hide-details class="mt-0"></v-switch>
</settings-row>
</v-card-text>
<v-divider class="mt-2 mb-0"></v-divider>
</template>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="" text @click="closeDialog">{{ $t('Dialogs.StartPrint.Cancel') }}</v-btn>
<v-btn
color="primary"
text
:disabled="printerIsPrinting || !klipperReadyForGui"
@click="startPrint(file.filename)">
{{ $t('Dialogs.StartPrint.Print') }}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { FileStateGcodefile } from '@/store/files/types'
import SettingsRow from '@/components/settings/SettingsRow.vue'
@Component({
components: {
SettingsRow,
},
})
export default class StartPrintDialog extends Mixins(BaseMixin) {
@Prop({ required: true, default: false })
declare readonly bool: boolean
@Prop({ required: true, default: '' })
declare readonly currentPath: string
@Prop({ required: true })
declare file: FileStateGcodefile
get timelapseEnabled() {
return this.$store.state.server.timelapse?.settings?.enabled ?? false
}
set timelapseEnabled(newVal) {
this.$socket.emit(
'machine.timelapse.post_settings',
{ enabled: newVal },
{ action: 'server/timelapse/initSettings' }
)
}
get dialogWidth() {
return this.file.big_thumbnail_width ?? 400
}
startPrint(filename = '') {
filename = (this.currentPath + '/' + filename).substring(1)
this.closeDialog()
this.$socket.emit('printer.print.start', { filename: filename }, { action: 'switchToDashboard' })
}
closeDialog() {
this.$emit('closeDialog')
}
}
</script>
+84 -144
View File
@@ -1,4 +1,5 @@
<style>
/*noinspection CssUnusedSymbol*/
.files-table .v-data-table-header__icon {
margin-left: 7px;
}
@@ -7,23 +8,28 @@
cursor: pointer;
}
/*noinspection CssUnusedSymbol*/
.file-list--select-td {
width: 20px;
}
/*noinspection CssUnusedSymbol*/
.files-table th.text-start {
padding-right: 0 !important;
}
/*noinspection CssUnusedSymbol*/
.v-chip.minimum-chip {
padding: 0;
min-width: 24px;
}
/*noinspection CssUnusedSymbol*/
.v-chip.minimum-chip .v-chip__content {
margin: 0 auto;
}
/*noinspection CssUnusedSymbol*/
.file-list__count_printed {
position: relative;
top: 1px;
@@ -32,7 +38,10 @@
<template>
<div>
<panel :title="$t('Files.GCodeFiles')" :icon="mdiFileDocumentMultipleOutline" card-class="gcode-files-panel">
<panel
:title="$t('Files.GCodeFiles').toString()"
:icon="mdiFileDocumentMultipleOutline"
card-class="gcode-files-panel">
<v-card-text>
<v-row>
<v-col class="col-12 d-flex align-center">
@@ -126,13 +135,13 @@
</v-list-item>
<v-divider></v-divider>
<draggable
v-model="configableHeaders"
v-model="configurableHeaders"
handle=".handle"
class="v-list-item-group"
ghost-class="ghost"
group="gcodeFilesColumnOrder">
<v-list-item
v-for="header of configableHeaders"
v-for="header of configurableHeaders"
:key="header.value"
class="minHeight36"
link>
@@ -308,22 +317,20 @@
</td>
<td class=" ">{{ item.filename }}</td>
<td class="text-right text-no-wrap">
<v-tooltip v-if="getJobStatus(item)" top>
<v-tooltip v-if="item.last_status" top>
<template #activator="{ on, attrs }">
<span v-bind="attrs" v-on="on">
<span
v-if="item.count_printed > 1"
:class="`file-list__count_printed ${getStatusTextColor(
getJobStatus(item)
)}`">
v-if="item.count_printed > 0"
:class="`file-list__count_printed ${getStatusTextColor(item.last_status)}`">
{{ item.count_printed }}
</span>
<v-icon small :color="getStatusColor(getJobStatus(item))">
{{ getStatusIcon(getJobStatus(item)) }}
<v-icon small :color="getStatusColor(item.last_status)">
{{ getStatusIcon(item.last_status) }}
</v-icon>
</span>
</template>
<span>{{ getJobStatus(item).replace(/_/g, ' ') }}</span>
<span>{{ item.last_status.replace(/_/g, ' ') }}</span>
</v-tooltip>
</td>
<td
@@ -340,38 +347,11 @@
</template>
</v-data-table>
</panel>
<v-dialog v-model="dialogPrintFile.show" :max-width="dialogPrintFile.item.big_thumbnail_width">
<v-card>
<v-img
v-if="dialogPrintFile.item.big_thumbnail"
contain
:src="dialogPrintFile.item.big_thumbnail"></v-img>
<v-card-title class="headline">{{ $t('Files.StartJob') }}</v-card-title>
<v-card-text class="pb-0">
{{ $t('Files.DoYouWantToStartFilename', { filename: dialogPrintFile.item.filename }) }}
</v-card-text>
<template v-if="moonrakerComponents.includes('timelapse')">
<v-divider class="mt-3 mb-2"></v-divider>
<v-card-text class="pb-0">
<settings-row title="Timelapse">
<v-switch v-model="timelapseEnabled" hide-details class="mt-0"></v-switch>
</settings-row>
</v-card-text>
<v-divider class="mt-2 mb-0"></v-divider>
</template>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="" text @click="dialogPrintFile.show = false">{{ $t('Files.Cancel') }}</v-btn>
<v-btn
color="primary"
text
:disabled="printerIsPrinting || !klipperReadyForGui"
@click="startPrint(dialogPrintFile.item.filename)">
{{ $t('Files.StartPrint') }}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<start-print-dialog
:bool="dialogPrintFile.show"
:file="dialogPrintFile.item"
:current-path="currentPath"
@closeDialog="closeStartPrint"></start-print-dialog>
<v-menu v-model="contextMenu.shown" :position-x="contextMenu.x" :position-y="contextMenu.y" absolute offset-y>
<v-list>
<v-list-item
@@ -555,55 +535,40 @@
import { Component, Mixins, Watch } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { validGcodeExtensions } from '@/store/variables'
import { formatFilesize, formatDate, sortFiles, formatPrintTime } from '@/plugins/helpers'
import { formatDate, formatFilesize, formatPrintTime, sortFiles } from '@/plugins/helpers'
import { FileStateFile, FileStateGcodefile } from '@/store/files/types'
import Panel from '@/components/ui/Panel.vue'
import SettingsRow from '@/components/settings/SettingsRow.vue'
import draggable from 'vuedraggable'
import {
mdiFileDocumentMultipleOutline,
mdiFile,
mdiMagnify,
mdiUpload,
mdiFolderPlus,
mdiRefresh,
mdiCog,
mdiFolderUpload,
mdiFolder,
mdiPlay,
mdiPlaylistPlus,
mdiFire,
mdiVideo3d,
mdiCloudDownload,
mdiRenameBox,
mdiPencil,
mdiDelete,
mdiCloseThick,
mdiClose,
mdiArrowUpDown,
mdiCheckboxBlankOutline,
mdiCheckboxMarked,
mdiArrowUpDown,
mdiCloseThick,
mdiCloudDownload,
mdiCog,
mdiDelete,
mdiFile,
mdiFileDocumentMultipleOutline,
mdiFire,
mdiFolder,
mdiFolderPlus,
mdiFolderUpload,
mdiMagnify,
mdiPencil,
mdiPlay,
mdiPlaylistPlus,
mdiRefresh,
mdiRenameBox,
mdiUpload,
mdiVideo3d,
} from '@mdi/js'
import StartPrintDialog from '@/components/dialogs/StartPrintDialog.vue'
interface draggingFile {
item: FileStateGcodefile
}
interface uploadSnackbar {
status: boolean
filename: string
percent: number
speed: number
total: number
number: number
max: number
cancelTokenSource: any
lastProgress: {
time: number
loaded: number
}
}
interface dialogPrintFile {
show: boolean
item: FileStateGcodefile
@@ -626,11 +591,11 @@ interface tableColumnSetting {
}
@Component({
components: { Panel, SettingsRow, draggable },
components: { StartPrintDialog, Panel, SettingsRow, draggable },
})
export default class GcodefilesPanel extends Mixins(BaseMixin) {
mdiFileDocumentMultipleOutline = mdiFileDocumentMultipleOutline
mdiFile = mdiFile
mdiFileDocumentMultipleOutline = mdiFileDocumentMultipleOutline
mdiMagnify = mdiMagnify
mdiUpload = mdiUpload
mdiFolderPlus = mdiFolderPlus
@@ -641,7 +606,6 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
mdiPlay = mdiPlay
mdiPlaylistPlus = mdiPlaylistPlus
mdiFire = mdiFire
mdiClose = mdiClose
mdiVideo3d = mdiVideo3d
mdiCloudDownload = mdiCloudDownload
mdiRenameBox = mdiRenameBox
@@ -665,24 +629,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
inputFieldRenameDirectory: HTMLInputElement
}
private TimelapseModeOptions = [
{
text: 'layermacro',
value: 'layermacro',
},
{
text: 'hyperlapse',
value: 'hyperlapse',
},
]
private search = ''
private selected = []
private hideHeaderColums = []
private dropzone = {
visibility: 'hidden',
opacity: 0,
}
private draggingFile: draggingFile = {
item: {
isDirectory: false,
@@ -701,20 +648,6 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
last_total_duration: null,
},
}
private uploadSnackbar: uploadSnackbar = {
status: false,
filename: '',
percent: 0,
speed: 0,
total: 0,
number: 0,
max: 0,
cancelTokenSource: {},
lastProgress: {
time: 0,
loaded: 0,
},
}
private dialogCreateDirectory = {
show: false,
name: '',
@@ -852,7 +785,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
]
}
get configableHeaders() {
get configurableHeaders() {
const headers: tableColumnSetting[] = [
{
text: this.$t('Files.Filesize').toString(),
@@ -923,6 +856,20 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
class: 'text-no-wrap',
outputType: 'time',
},
{
text: this.$t('Files.LastStartTime').toString(),
value: 'last_start_time',
visible: true,
class: 'text-no-wrap',
outputType: 'date',
},
{
text: this.$t('Files.LastEndTime').toString(),
value: 'last_end_time',
visible: true,
class: 'text-no-wrap',
outputType: 'date',
},
{
text: this.$t('Files.LastPrintDuration').toString(),
value: 'last_print_duration',
@@ -930,6 +877,20 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
class: 'text-no-wrap',
outputType: 'time',
},
{
text: this.$t('Files.LastTotalDuration').toString(),
value: 'last_total_duration',
visible: true,
class: 'text-no-wrap',
outputType: 'time',
},
{
text: this.$t('Files.LastFilamentUsed').toString(),
value: 'last_filament_used',
visible: true,
class: 'text-no-wrap',
outputType: 'length',
},
{
text: this.$t('Files.Slicer').toString(),
value: 'slicer',
@@ -954,7 +915,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
return headers.sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0))
}
set configableHeaders(newVal) {
set configurableHeaders(newVal) {
const orderArray: string[] = []
newVal.forEach((row: tableColumnSetting) => orderArray.push(row.value))
@@ -962,11 +923,11 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
}
get headers() {
return [...this.fixedHeaders, ...this.configableHeaders]
return [...this.fixedHeaders, ...this.configurableHeaders]
}
get tableColumns() {
return this.configableHeaders.filter((column) => column.visible)
return this.configurableHeaders.filter((column) => column.visible)
}
get directory() {
@@ -1045,31 +1006,15 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
this.$store.dispatch('gui/saveSetting', { name: 'view.gcodefiles.countPerPage', value: newVal })
}
get timelapseEnabled() {
return this.$store.state.server.timelapse?.settings?.enabled ?? false
}
set timelapseEnabled(newVal) {
this.$socket.emit(
'machine.timelapse.post_settings',
{ enabled: newVal },
{ action: 'server/timelapse/initSettings' }
)
}
getJobStatus(item: FileStateGcodefile) {
return this.$store.getters['server/history/getPrintStatus'](item.job_id)
}
getStatusIcon(status: string) {
getStatusIcon(status: string | null) {
return this.$store.getters['server/history/getPrintStatusIcon'](status)
}
getStatusTextColor(status: string) {
getStatusTextColor(status: string | null) {
return this.$store.getters['server/history/getPrintStatusTextColor'](status)
}
getStatusColor(status: string) {
getStatusColor(status: string | null) {
return this.$store.getters['server/history/getPrintStatusIconColor'](status)
}
@@ -1206,7 +1151,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
this.currentPath = this.currentPath.substr(0, this.currentPath.lastIndexOf('/'))
}
addToQueue(item: FileStateGcodefile) {
addToQueue(item: FileStateGcodefile | FileStateFile) {
let path = this.currentPath.slice(7)
if (path != '') path += '/'
const filename = path + item.filename
@@ -1218,7 +1163,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
this.$store.dispatch('gui/setGcodefilesMetadata', { name: name, value: value })
}
showContextMenu(e: any, item: FileStateFile) {
showContextMenu(e: any, item: FileStateGcodefile | FileStateFile) {
if (!this.contextMenu.shown) {
e?.preventDefault()
this.contextMenu.shown = true
@@ -1337,13 +1282,8 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
)
}
startPrint(filename = '') {
closeStartPrint() {
this.dialogPrintFile.show = false
this.$socket.emit(
'printer.print.start',
{ filename: this.currentPath + '/' + filename },
{ action: 'switchToDashboard' }
)
}
dragFile(e: Event, item: FileStateGcodefile) {
+2 -47
View File
@@ -121,7 +121,6 @@ import { ServerHistoryStateJob } from '@/store/server/history/types'
import { formatFilesize, formatPrintTime } from '@/plugins/helpers'
import Panel from '@/components/ui/Panel.vue'
import { ServerJobQueueStateJob } from '@/store/server/jobQueue/types'
import { thumbnailBigMin, thumbnailSmallMax, thumbnailSmallMin } from '@/store/variables'
import { mdiPlay, mdiPause, mdiFile, mdiDelete, mdiTrayFull } from '@mdi/js'
@Component({
components: { Panel },
@@ -215,55 +214,11 @@ export default class JobqueuePanel extends Mixins(BaseMixin) {
}
getSmallThumbnail(item: ServerJobQueueStateJob) {
if (item?.metadata?.thumbnails?.length) {
const thumbnail = item?.metadata?.thumbnails.find(
(thumb: any) =>
thumb.width >= thumbnailSmallMin &&
thumb.width <= thumbnailSmallMax &&
thumb.height >= thumbnailSmallMin &&
thumb.height <= thumbnailSmallMax
)
const path =
item.filename.lastIndexOf('/') !== -1
? 'gcodes/' + item.filename.slice(0, item.filename.lastIndexOf('/'))
: 'gcodes'
if (thumbnail && 'relative_path' in thumbnail)
return (
this.apiUrl +
'/server/files/' +
path +
'/' +
encodeURI(thumbnail.relative_path) +
'?timestamp=' +
item.metadata?.modified.getTime()
)
}
return ''
return this.$store.getters['server/jobQueue/getSmallThumbnail'](item)
}
getBigThumbnail(item: ServerJobQueueStateJob) {
if (item?.metadata?.thumbnails?.length) {
const thumbnail = item?.metadata?.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
const path =
item.filename.lastIndexOf('/') !== -1
? 'gcodes/' + item.filename.slice(0, item.filename.lastIndexOf('/'))
: 'gcodes'
if (thumbnail && 'relative_path' in thumbnail)
return (
this.apiUrl +
'/server/files/' +
path +
'/' +
encodeURI(thumbnail.relative_path) +
'?timestamp=' +
item.metadata?.modified.getTime()
)
}
return ''
return this.$store.getters['server/jobQueue/getBigThumbnail'](item)
}
getDescription(item: ServerJobQueueStateJob) {
@@ -59,7 +59,7 @@
import Component from 'vue-class-component'
import { Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import StatusPanelExcludeObjectDialog from '@/components/panels/StatusPanelExcludeObjectDialog.vue'
import StatusPanelExcludeObjectDialog from '@/components/panels/Status/ExcludeObjectDialog.vue'
import { mdiPrinter3dNozzle, mdiSelectionRemove } from '@mdi/js'
@Component({
components: { StatusPanelExcludeObjectDialog },
@@ -41,8 +41,8 @@
import Component from 'vue-class-component'
import { Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import StatusPanelExcludeObjectDialogMap from '@/components/panels/StatusPanelExcludeObjectDialogMap.vue'
import StatusPanelExcludeObjectDialogList from '@/components/panels/StatusPanelExcludeObjectDialogList.vue'
import StatusPanelExcludeObjectDialogMap from '@/components/panels/Status/ExcludeObjectDialogMap.vue'
import StatusPanelExcludeObjectDialogList from '@/components/panels/Status/ExcludeObjectDialogList.vue'
import Panel from '@/components/ui/Panel.vue'
import { mdiCloseThick, mdiSelectionRemove } from '@mdi/js'
@Component({
+473
View File
@@ -0,0 +1,473 @@
<style lang="scss" scoped></style>
<template>
<v-card ref="filesGcodeCard" flat>
<v-data-table
:items="gcodeFiles"
hide-default-footer
class="dashboard-gcodes-table"
sort-by="time_added"
mobile-breakpoint="0"
@current-items="setFirst">
<template #no-data>
<div class="text-center">{{ $t('Panels.StatusPanel.EmptyGcodes') }}</div>
</template>
<template #item="{ item }">
<tr
:key="item.filename"
v-longpress:600="(e) => showContextMenu(e, item)"
class="cursor-pointer"
@contextmenu="showContextMenu($event, item)"
@click="showDialog(item)">
<td class="pr-0 text-center" style="width: 32px">
<template v-if="item.small_thumbnail && item.big_thumbnail">
<v-tooltip top content-class="tooltip__content-opacity1">
<template #activator="{ on, attrs }">
<vue-load-image class="d-flex">
<img
slot="image"
:src="item.small_thumbnail"
width="32"
height="32"
v-bind="attrs"
v-on="on" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
<span><img :src="item.big_thumbnail" width="250" /></span>
</v-tooltip>
</template>
<template v-else-if="item.small_thumbnail">
<vue-load-image>
<img slot="image" :src="item.small_thumbnail" width="32" height="32" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
<template v-else>
<v-icon>{{ mdiFile }}</v-icon>
</template>
</td>
<td class="pr-2">
<div class="d-block text-truncate" :style="styleContentTdWidth">{{ item.filename }}</div>
<div v-if="existMetadata(item)">
<small>{{ getDescription(item) }}</small>
</div>
</td>
<td>
<v-tooltip v-if="item.last_status" top>
<template #activator="{ on, attrs }">
<span v-bind="attrs" v-on="on">
<v-icon small :color="getStatusColor(item.last_status)">
{{ getStatusIcon(item.last_status) }}
</v-icon>
</span>
</template>
<span>{{ item.last_status.replace(/_/g, ' ') }}</span>
</v-tooltip>
</td>
</tr>
</template>
</v-data-table>
<start-print-dialog
:bool="showDialogBool"
:file="dialogFile"
:current-path="currentPath"
@closeDialog="closeDialog"></start-print-dialog>
<v-menu v-model="contextMenu.shown" :position-x="contextMenu.x" :position-y="contextMenu.y" absolute offset-y>
<v-list>
<v-list-item :disabled="printerIsPrinting || !klipperReadyForGui" @click="showDialog(contextMenu.item)">
<v-icon class="mr-1">{{ mdiPlay }}</v-icon>
{{ $t('Files.PrintStart') }}
</v-list-item>
<v-list-item v-if="moonrakerComponents.includes('job_queue')" @click="addToQueue(contextMenu.item)">
<v-icon class="mr-1">{{ mdiPlaylistPlus }}</v-icon>
{{ $t('Files.AddToQueue') }}
</v-list-item>
<v-list-item
v-if="
'first_layer_extr_temp' in contextMenu.item &&
contextMenu.item.first_layer_extr_temp > 0 &&
'first_layer_bed_temp' in contextMenu.item &&
contextMenu.item.first_layer_bed_temp > 0
"
:disabled="['error', 'printing', 'paused'].includes(printer_state)"
@click="preheat(contextMenu.item)">
<v-icon class="mr-1">{{ mdiFire }}</v-icon>
{{ $t('Files.Preheat') }}
</v-list-item>
<v-list-item @click="view3D(contextMenu.item)">
<v-icon class="mr-1">{{ mdiVideo3d }}</v-icon>
{{ $t('Files.View3D') }}
</v-list-item>
<v-list-item @click="downloadFile(contextMenu.item)">
<v-icon class="mr-1">{{ mdiCloudDownload }}</v-icon>
{{ $t('Files.Download') }}
</v-list-item>
<v-list-item @click="editFile(contextMenu.item)">
<v-icon class="mr-1">{{ mdiPencil }}</v-icon>
{{ $t('Files.EditFile') }}
</v-list-item>
<v-list-item @click="renameFile(contextMenu.item)">
<v-icon class="mr-1">{{ mdiRenameBox }}</v-icon>
{{ $t('Files.Rename') }}
</v-list-item>
<v-list-item class="red--text" @click="removeFile(contextMenu.item)">
<v-icon class="mr-1" color="error">{{ mdiDelete }}</v-icon>
{{ $t('Files.Delete') }}
</v-list-item>
</v-list>
</v-menu>
<v-dialog v-model="dialogRenameFile.show" :max-width="400">
<panel
:title="$t('Files.RenameFile')"
card-class="dashboard-files-rename-file-dialog"
:margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="dialogRenameFile.show = false">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>
<v-text-field
ref="inputFieldRenameFile"
v-model="dialogRenameFile.newName"
:label="$t('Files.Name')"
required
@keyup.enter="renameFileAction"></v-text-field>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="" text @click="dialogRenameFile.show = false">{{ $t('Files.Cancel') }}</v-btn>
<v-btn color="primary" text @click="renameFileAction">{{ $t('Files.Rename') }}</v-btn>
</v-card-actions>
</panel>
</v-dialog>
</v-card>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { FileStateFile, FileStateGcodefile } from '@/store/files/types'
import StartPrintDialog from '@/components/dialogs/StartPrintDialog.vue'
import {
mdiFile,
mdiPlay,
mdiPlaylistPlus,
mdiFire,
mdiVideo3d,
mdiCloudDownload,
mdiPencil,
mdiRenameBox,
mdiDelete,
mdiCloseThick,
} from '@mdi/js'
interface dialogRenameObject {
show: boolean
newName: string
item: FileStateGcodefile
}
@Component({
components: {
StartPrintDialog,
},
})
export default class StatusPanelGcodefiles extends Mixins(BaseMixin) {
mdiFile = mdiFile
mdiPlay = mdiPlay
mdiPlaylistPlus = mdiPlaylistPlus
mdiFire = mdiFire
mdiVideo3d = mdiVideo3d
mdiCloudDownload = mdiCloudDownload
mdiPencil = mdiPencil
mdiRenameBox = mdiRenameBox
mdiDelete = mdiDelete
mdiCloseThick = mdiCloseThick
private showDialogBool = false
private dialogFile: FileStateGcodefile = {
isDirectory: false,
filename: '',
modified: new Date(),
permissions: '',
small_thumbnail: null,
big_thumbnail: null,
big_thumbnail_width: null,
count_printed: 0,
last_end_time: null,
last_filament_used: null,
last_print_duration: null,
last_status: null,
last_start_time: null,
last_total_duration: null,
}
private currentPath = ''
private contentTdWidth = 100
declare $refs: {
filesGcodeCard: any
inputFieldRenameFile: HTMLInputElement
}
private contextMenu = {
shown: false,
touchTimer: undefined,
x: 0,
y: 0,
item: {
filename: '',
permissions: '',
modified: new Date(),
},
}
private dialogRenameFile: dialogRenameObject = {
show: false,
newName: '',
item: {
isDirectory: false,
filename: '',
permissions: '',
modified: new Date(),
small_thumbnail: null,
big_thumbnail: null,
big_thumbnail_width: null,
count_printed: 0,
last_filament_used: null,
last_start_time: null,
last_end_time: null,
last_print_duration: null,
last_status: null,
last_total_duration: null,
},
}
get gcodeFiles() {
let gcodes = this.$store.getters['files/getAllGcodes'] ?? []
gcodes = gcodes
.slice()
.sort((a: FileStateGcodefile, b: FileStateGcodefile) => {
return b.modified.getTime() - a.modified.getTime()
})
.slice(0, 5)
const requestItems = gcodes.filter(
(file: FileStateGcodefile) => !file.metadataRequested && !file.metadataPulled
)
requestItems.forEach((file: FileStateGcodefile) => {
this.$store.dispatch('files/requestMetadata', {
filename: 'gcodes/' + file.filename,
})
})
return gcodes
}
get styleContentTdWidth() {
return `width: ${this.contentTdWidth}px;`
}
showContextMenu(e: any, item: FileStateFile) {
if (!this.contextMenu.shown) {
e?.preventDefault()
this.contextMenu.shown = true
this.contextMenu.x = e?.clientX || e?.pageX || window.screenX / 2
this.contextMenu.y = e?.clientY || e?.pageY || window.screenY / 2
this.contextMenu.item = item
this.$nextTick(() => {
this.contextMenu.shown = true
})
}
}
getDescription(item: FileStateGcodefile) {
let output = ''
output += this.$t('Panels.StatusPanel.Filament') + ': '
if (item.filament_total || item.filament_weight_total) {
if (item.filament_total) output += item.filament_total.toFixed() + ' mm'
if (item.filament_total && item.filament_weight_total) output += ' / '
if (item.filament_weight_total) output += item.filament_weight_total.toFixed(2) + ' g'
} else output += '--'
output += ', ' + this.$t('Panels.StatusPanel.PrintTime') + ': '
if (item.estimated_time) output += this.formatPrintTime(item.estimated_time)
else output += '--'
return output
}
existMetadata(item: FileStateGcodefile) {
return item?.metadataPulled
}
setFirst(currItems: any) {
// first check that actually exists values
if (currItems.length) {
// toggle all to false
currItems.forEach((x: any) => (x.isFirst = false))
// just set first to true
currItems[0].isFirst = true
}
}
formatPrintTime(totalSeconds: number) {
if (totalSeconds) {
let output = ''
const days = Math.floor(totalSeconds / (3600 * 24))
if (days) {
totalSeconds %= 3600 * 24
output += days + 'd'
}
const hours = Math.floor(totalSeconds / 3600)
totalSeconds %= 3600
if (hours) output += ' ' + hours + 'h'
const minutes = Math.floor(totalSeconds / 60)
if (minutes) output += ' ' + minutes + 'm'
const seconds = totalSeconds % 60
if (seconds) output += ' ' + seconds.toFixed(0) + 's'
return output
}
return '--'
}
getJobStatus(item: FileStateGcodefile) {
return item.last_status
}
getStatusIcon(status: string) {
return this.$store.getters['server/history/getPrintStatusIcon'](status)
}
getStatusColor(status: string) {
return this.$store.getters['server/history/getPrintStatusIconColor'](status)
}
showDialog(file: FileStateGcodefile) {
this.currentPath =
file.filename.lastIndexOf('/') >= 0 ? '/' + file.filename.slice(0, file.filename.lastIndexOf('/')) : ''
this.dialogFile = { ...file }
if (file.filename.lastIndexOf('/') >= 0) {
this.dialogFile.filename = file.filename.slice(file.filename.lastIndexOf('/') + 1)
}
this.showDialogBool = true
}
closeDialog() {
this.showDialogBool = false
}
addToQueue(item: FileStateGcodefile) {
this.$store.dispatch('server/jobQueue/addToQueue', [item.filename])
}
preheat(item: FileStateGcodefile) {
if (
'first_layer_extr_temp' in item &&
'first_layer_bed_temp' in item &&
!['error', 'printing', 'paused'].includes(this.printer_state)
) {
if (item.first_layer_extr_temp && item.first_layer_extr_temp > 0) {
const gcode = 'M104 S' + item.first_layer_extr_temp
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode })
}
if (item.first_layer_bed_temp && item.first_layer_bed_temp > 0) {
const gcode = 'M140 S' + item.first_layer_bed_temp
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode })
}
}
}
view3D(item: FileStateGcodefile) {
this.$router.push({ path: '/viewer', query: { filename: 'gcodes/' + item.filename } })
}
downloadFile(item: FileStateGcodefile) {
const href = this.apiUrl + '/server/files/gcodes/' + encodeURI(item.filename)
window.open(href)
}
editFile(item: FileStateGcodefile) {
const pos = item.filename.lastIndexOf('/')
const path = pos > 0 ? item.filename.slice(0, pos + 1) : ''
const filename = pos > 0 ? item.filename.slice(pos + 1) : item.filename
this.$store.dispatch('editor/openFile', {
root: 'gcodes',
path,
filename,
size: item.size,
permissions: item.permissions,
})
}
renameFile(item: FileStateGcodefile) {
this.dialogRenameFile.item = item
const pos = item.filename.lastIndexOf('/')
this.dialogRenameFile.newName = pos > 0 ? item.filename.slice(pos + 1) : item.filename
this.dialogRenameFile.show = true
setTimeout(() => {
this.$refs.inputFieldRenameFile?.focus()
}, 200)
}
renameFileAction() {
this.dialogRenameFile.show = false
const pos = this.dialogRenameFile.item.filename.lastIndexOf('/')
const path = pos > 0 ? this.dialogRenameFile.item.filename.slice(0, pos + 1) : ''
this.$socket.emit(
'server.files.move',
{
source: 'gcodes/' + this.dialogRenameFile.item.filename,
dest: 'gcodes/' + path + this.dialogRenameFile.newName,
},
{ action: 'files/getMove' }
)
}
removeFile(item: FileStateGcodefile) {
this.$socket.emit(
'server.files.delete_file',
{ path: 'gcodes/' + item.filename },
{ action: 'files/getDeleteFile' }
)
}
mounted() {
window.addEventListener('resize', this.eventListenerResize)
this.eventListenerResize()
}
destroyed() {
window.removeEventListener('resize', this.eventListenerResize)
}
eventListenerResize() {
this.contentTdWidth = this.$refs.filesGcodeCard?.$el?.clientWidth - 48 - 48 - 32
}
}
</script>
+213
View File
@@ -0,0 +1,213 @@
<style lang="scss" scoped></style>
<template>
<v-card flat>
<v-data-table
:items="jobsTable"
hide-default-footer
class="dashboard-jobqueue-table"
sort-by="time_added"
mobile-breakpoint="0"
@current-items="setFirst">
<template #no-data>
<div class="text-center">{{ $t('Panels.StatusPanel.EmptyJobqueue') }}</div>
</template>
<template #item="{ item }">
<tr :key="item.job_id">
<td class="pr-0 text-center" style="width: 32px">
<template v-if="getSmallThumbnail(item) && getBigThumbnail(item)">
<v-tooltip
v-if="!item.isDirectory && getSmallThumbnail(item) && getBigThumbnail(item)"
top
content-class="tooltip__content-opacity1">
<template #activator="{ on, attrs }">
<vue-load-image>
<img
slot="image"
:src="getSmallThumbnail(item)"
width="32"
height="32"
v-bind="attrs"
v-on="on" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
<span><img :src="getBigThumbnail(item)" width="250" /></span>
</v-tooltip>
</template>
<template v-else-if="getSmallThumbnail(item)">
<vue-load-image>
<img slot="image" :src="getSmallThumbnail(item)" width="32" height="32" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
<template v-else>
<v-icon>{{ mdiFile }}</v-icon>
</template>
</td>
<td class="pr-2">
<template v-if="item.isFirst">
<v-btn icon color="success" class="float-right minwidth-0 mt-1" @click="startJobqueue">
<v-icon>{{ mdiPlay }}</v-icon>
</v-btn>
</template>
{{ item.filename }}
<template v-if="existMetadata(item)">
<br />
<small>{{ getDescription(item) }}</small>
</template>
</td>
</tr>
</template>
<template v-if="jobs.length > jobsTable.length" #body.append>
<tr>
<td class="pr-0 text-center" style="width: 32px">
<v-icon>{{ mdiFileMultiple }}</v-icon>
</td>
<td class="pr-2">
{{
$tc('Panels.StatusPanel.JobqueueMoreFiles', jobs.length - jobsTable.length, {
count: jobs.length - jobsTable.length,
})
}}
<br />
<small>{{ descriptionRestJobs }}</small>
</td>
</tr>
</template>
</v-data-table>
</v-card>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { ServerJobQueueStateJob } from '@/store/server/jobQueue/types'
import { mdiFile, mdiPlay, mdiFileMultiple } from '@mdi/js'
@Component({
components: {},
})
export default class StatusPanelJobqueue extends Mixins(BaseMixin) {
mdiFile = mdiFile
mdiPlay = mdiPlay
mdiFileMultiple = mdiFileMultiple
get jobs() {
return this.$store.getters['server/jobQueue/getJobs'] ?? []
}
get jobsTable() {
return this.jobs.slice(0, 5)
}
get jobsRest() {
return this.jobs.slice(5)
}
get descriptionRestJobs() {
let filamentLength = 0
let filamentWeight = 0
let printTime = 0
this.jobsRest.forEach((item: ServerJobQueueStateJob) => {
if (item.metadata?.filament_total) filamentLength += item.metadata?.filament_total
if (item.metadata?.filament_weight_total) filamentWeight += item.metadata?.filament_weight_total
if (item.metadata?.estimated_time) printTime = item.metadata.estimated_time
})
let output = ''
output += this.$t('Files.Filament') + ': '
if (filamentLength || filamentWeight) {
if (filamentLength) output += filamentLength.toFixed() + ' mm'
if (filamentLength && filamentWeight) output += ' / '
if (filamentWeight) output += filamentWeight.toFixed(2) + ' g'
} else output += '--'
output += ', ' + this.$t('Files.PrintTime') + ': '
if (printTime) output += this.formatPrintTime(printTime)
else output += '--'
return output
}
getSmallThumbnail(item: ServerJobQueueStateJob) {
return this.$store.getters['server/jobQueue/getSmallThumbnail'](item)
}
getBigThumbnail(item: ServerJobQueueStateJob) {
return this.$store.getters['server/jobQueue/getBigThumbnail'](item)
}
getDescription(item: ServerJobQueueStateJob) {
let output = ''
output += this.$t('Panels.StatusPanel.Filament') + ': '
if (item.metadata?.filament_total || item.metadata.filament_weight_total) {
if (item.metadata?.filament_total) output += item.metadata.filament_total.toFixed() + ' mm'
if (item.metadata?.filament_total && item.metadata.filament_weight_total) output += ' / '
if (item.metadata?.filament_weight_total) output += item.metadata.filament_weight_total.toFixed(2) + ' g'
} else output += '--'
output += ', ' + this.$t('Panels.StatusPanel.PrintTime') + ': '
if (item.metadata?.estimated_time) output += this.formatPrintTime(item.metadata.estimated_time)
else output += '--'
return output
}
existMetadata(item: ServerJobQueueStateJob) {
return item?.metadata?.metadataPulled
}
setFirst(currItems: ServerJobQueueStateJob[]) {
// first check that actually exists values
if (currItems.length) {
// toggle all to false
currItems.forEach((x: ServerJobQueueStateJob) => (x.isFirst = false))
// just set first to true
currItems[0].isFirst = true
}
}
formatPrintTime(totalSeconds: number) {
if (totalSeconds) {
let output = ''
const days = Math.floor(totalSeconds / (3600 * 24))
if (days) {
totalSeconds %= 3600 * 24
output += days + 'd'
}
const hours = Math.floor(totalSeconds / 3600)
totalSeconds %= 3600
if (hours) output += ' ' + hours + 'h'
const minutes = Math.floor(totalSeconds / 60)
if (minutes) output += ' ' + minutes + 'm'
const seconds = totalSeconds % 60
if (seconds) output += ' ' + seconds.toFixed(0) + 's'
return output
}
return '--'
}
startJobqueue() {
this.$store.dispatch('server/jobQueue/start')
}
}
</script>
@@ -0,0 +1,28 @@
<style lang="scss" scoped></style>
<template>
<div>
<template v-if="['printing', 'paused', 'error', 'cancelled'].includes(printer_state)">
<status-panel-printstatus-printing></status-panel-printstatus-printing>
</template>
<template v-if="['complete'].includes(printer_state)">
<status-panel-printstatus-complete></status-panel-printstatus-complete>
</template>
</div>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import StatusPanelPrintstatusPrinting from '@/components/panels/Status/PrintstatusPrinting.vue'
import StatusPanelPrintstatusComplete from '@/components/panels/Status/PrintstatusComplete.vue'
@Component({
components: {
StatusPanelPrintstatusPrinting,
StatusPanelPrintstatusComplete,
},
})
export default class StatusPanelPrintstatus extends Mixins(BaseMixin) {}
</script>
@@ -0,0 +1,78 @@
<style lang="scss" scoped></style>
<template>
<v-card-text class="pa-0">
<v-container class="py-0">
<v-row class="text-center pt-5 pb-2 mb-0" align="center">
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Filament') }}</strong>
<br />
<span class="text-no-wrap">
{{ outputFilamentUsed }}
</span>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Slicer') }}</strong>
<br />
<span class="text-no-wrap">
{{ 'estimated_time' in current_file ? formatTime(current_file.estimated_time) : '--' }}
</span>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Print') }}</strong>
<br />
<span class="text-no-wrap">{{ print_time ? formatTime(print_time) : '--' }}</span>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Total') }}</strong>
<br />
<span class="text-no-wrap">
{{ print_time_total ? formatTime(print_time_total) : '--' }}
</span>
</v-col>
</v-row>
</v-container>
</v-card-text>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
@Component({
components: {},
})
export default class StatusPanelPrintstatusComplete extends Mixins(BaseMixin) {
get current_file() {
return this.$store.state.printer.current_file ?? {}
}
get filament_used() {
return this.$store.state.printer.print_stats?.filament_used ?? 0
}
get outputFilamentUsed() {
return this.filament_used >= 1000
? (this.filament_used / 1000).toFixed(2) + ' m'
: this.filament_used.toFixed(2) + ' mm'
}
get print_time() {
return this.$store.state.printer.print_stats?.print_duration ?? 0
}
get print_time_total() {
return this.$store.state.printer.print_stats?.total_duration ?? 0
}
formatTime(seconds: number) {
let h = Math.floor(seconds / 3600)
seconds %= 3600
let m = ('0' + Math.floor(seconds / 60)).slice(-2)
let s = ('0' + (seconds % 60).toFixed(0)).slice(-2)
return h + ':' + m + ':' + s
}
}
</script>
@@ -0,0 +1,286 @@
<style lang="scss" scoped></style>
<template>
<v-card-text class="pa-0">
<v-container class="py-0">
<v-row class="text-center py-5" align="center">
<v-col class="col-3 pa-0">
<template v-if="live_velocity !== null">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Speed') }}</strong>
<br />
<span class="text-no-wrap">{{ live_velocity }} mm/s</span>
</div>
</template>
<span>{{ $t('Panels.StatusPanel.Requested') }}: {{ requested_speed + ' mm/s' }}</span>
</v-tooltip>
</template>
<template v-else>
<strong>{{ $t('Panels.StatusPanel.Speed') }}</strong>
<br />
<span class="text-no-wrap">{{ requested_speed }} mm/s</span>
</template>
</v-col>
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Flow') }}</strong>
<br />
<span class="d-block text-center text-no-wrap">
{{ live_flow + ' mm&sup3;/s' }}
</span>
</div>
</template>
<span>{{ $t('Panels.StatusPanel.Max') }}: {{ outputMaxFlow }}</span>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Filament') }}</strong>
<br />
<span class="d-block text-center text-no-wrap">
{{ outputFilamentUsed }}
</span>
</div>
</template>
<span v-if="'filament_total' in current_file">
{{ (filament_used / 1000).toFixed(2) }} /
{{ (current_file.filament_total / 1000).toFixed(2) }} m =
{{ ((100 / current_file.filament_total) * filament_used).toFixed(0) }} %
</span>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0 text-center">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" class="text-center" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Layer') }}</strong>
<br />
<span class="text-no-wrap">{{ current_layer }} of {{ max_layers }}</span>
</div>
</template>
<span v-if="'object_height' in current_file && current_file.object_height > 0">
{{ $t('Panels.StatusPanel.ObjectHeight') }}: {{ current_file.object_height }} mm
</span>
</v-tooltip>
</v-col>
</v-row>
</v-container>
<v-divider class="my-0"></v-divider>
<v-container class="py-0">
<v-row class="text-center pt-5 pb-2 mb-0" align="center">
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" class="text-center" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Estimate') }}</strong>
<br />
<span class="text-no-wrap">
{{ estimated_time_avg ? formatTime(estimated_time_avg) : '--' }}
</span>
</div>
</template>
<div class="text-right">
{{ $t('Panels.StatusPanel.File') }}:
{{ estimated_time_file ? formatTime(estimated_time_file) : '--' }}
<br />
{{ $t('Panels.StatusPanel.Filament') }}:
{{ estimated_time_filament ? formatTime(estimated_time_filament) : '--' }}
</div>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Slicer') }}</strong>
<br />
<span class="text-no-wrap">
{{ estimated_time_slicer ? formatTime(estimated_time_slicer) : '--' }}
</span>
</v-col>
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" class="text-center" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Total') }}</strong>
<br />
<span class="text-no-wrap">
{{ print_time_total ? formatTime(print_time_total) : '--' }}
</span>
</div>
</template>
<div class="text-right">
{{ $t('Panels.StatusPanel.Print') }}:
{{ print_time ? formatTime(print_time) : '--' }}
<br />
{{ $t('Panels.StatusPanel.Difference') }}:
{{ print_time && print_time_total ? formatTime(print_time_total - print_time) : '--' }}
</div>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.ETA') }}</strong>
<br />
<span class="text-no-wrap">{{ outputEta }}</span>
</v-col>
</v-row>
</v-container>
</v-card-text>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import StatusPanelFilesJobqueue from '@/components/panels/Status/Jobqueue.vue'
import StatusPanelFilesGcodes from '@/components/panels/Status/Gcodefiles.vue'
@Component({
components: {
StatusPanelFilesJobqueue,
StatusPanelFilesGcodes,
},
})
export default class StatusPanelPrintstatusPrinting extends Mixins(BaseMixin) {
private maxFlow: number = 0
get current_file() {
return this.$store.state.printer.current_file ?? {}
}
get live_velocity() {
return Math.abs(this.$store.state.printer.motion_report?.live_velocity?.toFixed(0)) ?? null
}
get live_extruder_velocity() {
const live_extruder_velocity = this.$store.state.printer.motion_report?.live_extruder_velocity ?? null
if (live_extruder_velocity === null) return null
return live_extruder_velocity > 0 ? live_extruder_velocity : 0
}
get live_flow() {
if (this.live_extruder_velocity === null) return null
const filamentCrossSection = Math.pow(this.filament_diameter / 2, 2) * Math.PI
const currentFlow = filamentCrossSection * this.live_extruder_velocity
if (currentFlow && this.maxFlow < currentFlow) this.maxFlow = currentFlow
return currentFlow?.toFixed(1)
}
get outputMaxFlow() {
return this.maxFlow ? this.maxFlow.toFixed(1) + ' mm³/s' : '--'
}
get requested_speed() {
const requested_speed = this.$store.state.printer.gcode_move?.speed ?? 0
const speed_factor = this.$store.state.printer.gcode_move?.speed_factor ?? 0
const max_velocity = this.$store.state.printer.toolhead?.max_velocity ?? 0
const speed = (requested_speed / 60) * speed_factor
if (speed > max_velocity) return max_velocity
return speed.toFixed(0)
}
get max_layers() {
if (
'first_layer_height' in this.current_file &&
'layer_height' in this.current_file &&
'object_height' in this.current_file
) {
const max = Math.ceil(
(this.current_file.object_height - this.current_file.first_layer_height) /
this.current_file.layer_height +
1
)
return max > 0 ? max : 0
}
return 0
}
get current_layer() {
if (this.print_time > 0 && 'first_layer_height' in this.current_file && 'layer_height' in this.current_file) {
const gcodePositionZ = this.$store.state.printer.gcode_move?.gcode_position[2] ?? 0
let current_layer = Math.ceil(
(gcodePositionZ - this.current_file.first_layer_height) / this.current_file.layer_height + 1
)
current_layer = current_layer <= this.max_layers ? current_layer : this.max_layers
return current_layer > 0 ? current_layer : 0
}
return 0
}
get estimated_time_file() {
return this.$store.getters['printer/getEstimatedTimeFile']
}
get estimated_time_filament() {
return this.$store.getters['printer/getEstimatedTimeFilament']
}
get estimated_time_slicer() {
return this.$store.getters['printer/getEstimatedTimeSlicer']
}
get estimated_time_avg() {
return this.$store.getters['printer/getEstimatedTimeAvg']
}
get eta() {
return this.$store.getters['printer/getEstimatedTimeETA']
}
get outputEta() {
return this.eta ? this.formatDateTime(this.eta) : '--'
}
get filament_diameter() {
return this.$store.state.printer.configfile?.settings?.extruder?.filament_diameter ?? 1.75
}
get print_time() {
return this.$store.state.printer.print_stats?.print_duration ?? 0
}
get print_time_total() {
return this.$store.state.printer.print_stats?.total_duration ?? 0
}
get filament_used() {
return this.$store.state.printer.print_stats?.filament_used ?? 0
}
get outputFilamentUsed() {
return this.filament_used >= 1000
? (this.filament_used / 1000).toFixed(2) + ' m'
: this.filament_used.toFixed(2) + ' mm'
}
formatTime(seconds: number) {
let h = Math.floor(seconds / 3600)
seconds %= 3600
let m = ('0' + Math.floor(seconds / 60)).slice(-2)
let s = ('0' + (seconds % 60).toFixed(0)).slice(-2)
return h + ':' + m + ':' + s
}
formatDateTime(msec: number) {
const date = new Date(msec)
const h = date.getHours() >= 10 ? date.getHours() : '0' + date.getHours()
const m = date.getMinutes() >= 10 ? date.getMinutes() : '0' + date.getMinutes()
const diff = msec - new Date().getTime()
return h + ':' + m + (diff > 60 * 60 * 24 * 1000 ? '+' + Math.round(diff / (60 * 60 * 24 * 1000)) : '')
}
}
</script>
@@ -0,0 +1,214 @@
<style lang="scss" scoped>
.statusPanel-big-thumbnail {
transition: height 0.25s ease-out;
}
</style>
<template>
<div v-if="current_filename">
<v-img
v-if="boolBigThumbnail"
ref="bigThumbnail"
:src="thumbnailBig"
tabindex="-1"
class="d-flex align-end statusPanel-big-thumbnail"
height="200"
@focus="focusBigThumbnail"
@blur="blurBigThumbnail">
<v-card-title
class="white--text py-2 px-2"
style="background-color: rgba(0, 0, 0, 0.3); backdrop-filter: blur(3px)">
<v-row>
<v-col style="width: 100px">
<span class="subtitle-2 text-truncate px-0 text--disabled d-block">
<v-icon small class="mr-2">{{ mdiFileOutline }}</v-icon>
{{ current_filename }}
</span>
</v-col>
</v-row>
</v-card-title>
</v-img>
<template v-else>
<v-container>
<v-row>
<v-col
:class="thumbnailSmall ? 'py-3' : 'py-2'"
:style="thumbnailSmall ? 'width: calc(100% - 40px);' : ''">
<span class="subtitle-2 text-truncate d-block px-0 text--disabled">
<v-icon small class="mr-2">{{ mdiFileOutline }}</v-icon>
{{ current_filename }}
</span>
</v-col>
<v-col v-if="thumbnailSmall" class="pa-2 pl-0 col-auto">
<template v-if="thumbnailSmall && thumbnailBig">
<v-tooltip top content-class="tooltip__content-opacity1">
<template #activator="{ on, attrs }">
<vue-load-image class="d-flex">
<img
slot="image"
:src="thumbnailSmall"
width="32"
height="32"
v-bind="attrs"
v-on="on" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
<span><img :src="thumbnailBig" width="250" /></span>
</v-tooltip>
</template>
<template v-else-if="thumbnailSmall">
<vue-load-image>
<img slot="image" :src="thumbnailSmall" width="32" height="32" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
</v-col>
</v-row>
</v-container>
</template>
</div>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { thumbnailBigMin, thumbnailSmallMax, thumbnailSmallMin } from '@/store/variables'
import { mdiFileOutline, mdiFile } from '@mdi/js'
@Component({
components: {},
})
export default class StatusPanelPrintstatusThumbnail extends Mixins(BaseMixin) {
mdiFileOutline = mdiFileOutline
mdiFile = mdiFile
declare $refs: {
bigThumbnail: any
}
get current_filename() {
return this.$store.state.printer.print_stats?.filename ?? ''
}
get current_file() {
return this.$store.state.printer.current_file ?? {}
}
get thumbnailBig() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
if (thumbnail && 'relative_path' in thumbnail) {
let relative_url = ''
if (this.current_file.filename.lastIndexOf('/') !== -1) {
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/') + 1)
}
if (thumbnail && 'relative_path' in thumbnail) {
return `${this.apiUrl}/server/files/gcodes/${encodeURI(
relative_url + thumbnail.relative_path
)}?timestamp=${this.current_file.modified}`
}
}
}
return ''
}
get thumbnailBigHeight() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
if (thumbnail && 'height' in thumbnail) {
return thumbnail.height
}
}
return 200
}
get thumbnailBigWidth() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
if (thumbnail && 'width' in thumbnail) {
return thumbnail.width
}
}
return 300
}
get thumbnailSmall() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find(
(thumb: any) =>
thumb.width >= thumbnailSmallMin &&
thumb.width <= thumbnailSmallMax &&
thumb.height >= thumbnailSmallMin &&
thumb.height <= thumbnailSmallMax
)
if (thumbnail && 'relative_path' in thumbnail) {
let relative_url = ''
if (this.current_file.filename.lastIndexOf('/') !== -1) {
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/') + 1)
}
if (thumbnail && 'relative_path' in thumbnail) {
return `${this.apiUrl}/server/files/gcodes/${encodeURI(
relative_url + thumbnail.relative_path
)}?timestamp=${this.current_file.modified}`
}
}
}
return ''
}
get boolBigThumbnail() {
const setting = this.$store.state.gui.uiSettings.boolBigThumbnail ?? true
return this.current_filename && setting && this.thumbnailBig
}
focusBigThumbnail() {
if (this.$refs.bigThumbnail) {
const clientWidth = this.$refs.bigThumbnail.$el.clientWidth
const thumbnailWidth = this.thumbnailBigWidth
const factor = clientWidth / thumbnailWidth
this.$refs.bigThumbnail.$el.style.height = (this.thumbnailBigHeight * factor).toFixed() + 'px'
}
}
blurBigThumbnail() {
if (this.$refs.bigThumbnail) {
this.$refs.bigThumbnail.$el.style.height = '200px'
}
}
created() {
window.addEventListener('resize', this.onResize)
}
destroyed() {
window.removeEventListener('resize', this.onResize)
}
onResize() {
const isFocused = document.activeElement === this.$refs.bigThumbnail?.$el
if (isFocused) this.focusBigThumbnail()
}
}
</script>
+85 -532
View File
@@ -1,15 +1,11 @@
<style lang="scss" scoped>
.statusPanel-big-thumbnail {
transition: height 0.25s ease-out;
}
</style>
<style lang="scss" scoped></style>
<template>
<div>
<min-settings-panel></min-settings-panel>
<klippy-state-panel></klippy-state-panel>
<panel
v-if="klipperState === 'ready'"
v-if="klipperReadyForGui"
:icon="mdiInformation"
:title="printerStateOutput"
:collapsible="true"
@@ -41,282 +37,45 @@
</v-tooltip>
</v-btn>
</template>
<v-card-text class="px-0 py-0 content">
<template v-if="boolBigThumbnail">
<v-img
ref="bigThumbnail"
:src="thumbnailBig"
tabindex="-1"
class="d-flex align-end statusPanel-big-thumbnail"
height="200"
@focus="focusBigThumbnail"
@blur="blurBigThumbnail">
<v-card-title
class="white--text py-2 px-2"
style="background-color: rgba(0, 0, 0, 0.3); backdrop-filter: blur(3px)">
<v-row>
<v-col style="width: 100px">
<span class="subtitle-2 text-truncate px-0 text--disabled d-block">
<v-icon small class="mr-2">{{ mdiFileOutline }}</v-icon>
{{ current_filename }}
</span>
</v-col>
</v-row>
</v-card-title>
</v-img>
</template>
<status-panel-exclude-object
:show-dialog.sync="boolShowObjects"
@update:showDialog="updateShowDialog"></status-panel-exclude-object>
<template v-if="display_message || print_stats_message">
<v-container>
<v-row>
<v-col class="py-2">
<span class="subtitle-2 d-block px-0 text--disabled">
<v-icon class="mr-2" small>{{ mdiMessageProcessingOutline }}</v-icon>
{{ print_stats_message ? print_stats_message : display_message }}
</span>
</v-col>
<v-col class="col-auto py-2">
<v-icon class="text--disabled cursor-pointer" small @click="clearDisplayMessage">
{{ mdiCloseCircle }}
</v-icon>
</v-col>
</v-row>
</v-container>
<v-divider class="mt-0 mb-0"></v-divider>
</template>
<template v-if="current_filename && !boolBigThumbnail">
<v-container>
<v-row>
<v-col
:class="thumbnailSmall ? 'py-3' : 'py-2'"
:style="thumbnailSmall ? 'width: calc(100% - 40px);' : ''">
<span class="subtitle-2 text-truncate d-block px-0 text--disabled">
<v-icon small class="mr-2">{{ mdiFileOutline }}</v-icon>
{{ current_filename }}
</span>
</v-col>
<v-col v-if="thumbnailSmall" class="pa-2 pl-0 col-auto">
<template v-if="thumbnailSmall && thumbnailBig">
<v-tooltip top content-class="tooltip__content-opacity1">
<template #activator="{ on, attrs }">
<vue-load-image class="d-flex">
<img
slot="image"
:src="thumbnailSmall"
width="32"
height="32"
v-bind="attrs"
v-on="on" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
<span><img :src="thumbnailBig" width="250" /></span>
</v-tooltip>
</template>
<template v-else-if="thumbnailSmall">
<vue-load-image>
<img slot="image" :src="thumbnailSmall" width="32" height="32" />
<v-progress-circular
slot="preloader"
indeterminate
color="primary"></v-progress-circular>
<v-icon slot="error">{{ mdiFile }}</v-icon>
</vue-load-image>
</template>
</v-col>
</v-row>
</v-container>
<v-divider class="mt-0 mb-0"></v-divider>
</template>
<template v-if="['printing', 'paused', 'error', 'cancelled'].includes(printer_state)">
<v-container class="py-0">
<v-row class="text-center py-5" align="center">
<v-col class="col-3 pa-0">
<template v-if="live_velocity !== null">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Speed') }}</strong>
<br />
<span class="text-no-wrap">{{ live_velocity }} mm/s</span>
</div>
</template>
<span>
{{ $t('Panels.StatusPanel.Requested') }}: {{ requested_speed + ' mm/s' }}
</span>
</v-tooltip>
</template>
<template v-else>
<strong>{{ $t('Panels.StatusPanel.Speed') }}</strong>
<br />
<span class="text-no-wrap">{{ requested_speed }} mm/s</span>
</template>
</v-col>
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Flow') }}</strong>
<br />
<span class="d-block text-center text-no-wrap">
{{ live_flow + ' mm&sup3;/s' }}
</span>
</div>
</template>
<span>
{{ $t('Panels.StatusPanel.Max') }}:
{{ maxFlow ? maxFlow + ' mm&sup3;/s' : '--' }}
</span>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Filament') }}</strong>
<br />
<span class="d-block text-center text-no-wrap">
{{
filament_used >= 1000
? (filament_used / 1000).toFixed(2) + ' m'
: filament_used.toFixed(2) + ' mm'
}}
</span>
</div>
</template>
<span v-if="'filament_total' in current_file">
{{ (filament_used / 1000).toFixed(2) }} /
{{ (current_file.filament_total / 1000).toFixed(2) }} m =
{{ ((100 / current_file.filament_total) * filament_used).toFixed(0) }} %
</span>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0 text-center">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" class="text-center" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Layer') }}</strong>
<br />
<span class="text-no-wrap">{{ current_layer }} of {{ max_layers }}</span>
</div>
</template>
<span v-if="'object_height' in current_file && current_file.object_height > 0">
{{ $t('Panels.StatusPanel.ObjectHeight') }}: {{ current_file.object_height }} mm
</span>
</v-tooltip>
</v-col>
</v-row>
</v-container>
<v-divider class="my-0"></v-divider>
<v-container class="py-0">
<v-row class="text-center pt-5 pb-2 mb-0" align="center">
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" class="text-center" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Estimate') }}</strong>
<br />
<span class="text-no-wrap">
{{ estimated_time_avg ? formatTime(estimated_time_avg) : '--' }}
</span>
</div>
</template>
<div class="text-right">
{{ $t('Panels.StatusPanel.File') }}:
{{ estimated_time_file ? formatTime(estimated_time_file) : '--' }}
<br />
{{ $t('Panels.StatusPanel.Filament') }}:
{{ estimated_time_filament ? formatTime(estimated_time_filament) : '--' }}
</div>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Slicer') }}</strong>
<br />
<span class="text-no-wrap">
{{ estimated_time_slicer ? formatTime(estimated_time_slicer) : '--' }}
</span>
</v-col>
<v-col class="col-3 pa-0">
<v-tooltip top>
<template #activator="{ on, attrs }">
<div v-bind="attrs" class="text-center" v-on="on">
<strong>{{ $t('Panels.StatusPanel.Total') }}</strong>
<br />
<span class="text-no-wrap">
{{ print_time_total ? formatTime(print_time_total) : '--' }}
</span>
</div>
</template>
<div class="text-right">
{{ $t('Panels.StatusPanel.Print') }}:
{{ print_time ? formatTime(print_time) : '--' }}
<br />
{{ $t('Panels.StatusPanel.Difference') }}:
{{
print_time && print_time_total
? formatTime(print_time_total - print_time)
: '--'
}}
</div>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.ETA') }}</strong>
<br />
<span class="text-no-wrap">{{ eta ? formatDateTime(eta) : '--' }}</span>
</v-col>
</v-row>
</v-container>
</template>
<template v-if="['complete'].includes(printer_state)">
<v-divider class="my-0"></v-divider>
<v-container class="py-0">
<v-row class="text-center pt-5 pb-2 mb-0" align="center">
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Filament') }}</strong>
<br />
<span class="text-no-wrap">
{{
filament_used >= 1000
? (filament_used / 1000).toFixed(2) + ' m'
: filament_used.toFixed(2) + ' mm'
}}
</span>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Slicer') }}</strong>
<br />
<span class="text-no-wrap">
{{
'estimated_time' in current_file
? formatTime(current_file.estimated_time)
: '--'
}}
</span>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Print') }}</strong>
<br />
<span class="text-no-wrap">{{ print_time ? formatTime(print_time) : '--' }}</span>
</v-col>
<v-col class="col-3 pa-0">
<strong>{{ $t('Panels.StatusPanel.Total') }}</strong>
<br />
<span class="text-no-wrap">
{{ print_time_total ? formatTime(print_time_total) : '--' }}
</span>
</v-col>
</v-row>
</v-container>
</template>
</v-card-text>
<status-panel-printstatus-thumbnail></status-panel-printstatus-thumbnail>
<status-panel-exclude-object
:show-dialog.sync="boolShowObjects"
@update:showDialog="updateShowDialog"></status-panel-exclude-object>
<template v-if="display_message || print_stats_message">
<v-container>
<v-row>
<v-col class="py-2">
<span class="subtitle-2 d-block px-0 text--disabled">
<v-icon class="mr-2" small>{{ mdiMessageProcessingOutline }}</v-icon>
{{ print_stats_message ? print_stats_message : display_message }}
</span>
</v-col>
<v-col class="col-auto py-2">
<v-icon class="text--disabled cursor-pointer" small @click="clearDisplayMessage">
{{ mdiCloseCircle }}
</v-icon>
</v-col>
</v-row>
</v-container>
<v-divider class="mt-0 mb-0"></v-divider>
</template>
<v-tabs v-model="activeTab" fixed-tabs dark>
<v-tab v-if="current_filename" href="#status">{{ $t('Panels.StatusPanel.Status') }}</v-tab>
<v-tab href="#files">{{ $t('Panels.StatusPanel.Files') }}</v-tab>
<v-tab href="#jobqueue">{{ $t('Panels.StatusPanel.Jobqueue', { count: jobsCount }) }}</v-tab>
</v-tabs>
<v-divider class="my-0"></v-divider>
<v-tabs-items v-model="activeTab">
<v-tab-item v-if="current_filename" value="status">
<status-panel-printstatus></status-panel-printstatus>
</v-tab-item>
<v-tab-item value="files">
<status-panel-gcodefiles></status-panel-gcodefiles>
</v-tab-item>
<v-tab-item value="jobqueue">
<status-panel-jobqueue></status-panel-jobqueue>
</v-tab-item>
</v-tabs-items>
</panel>
</div>
</template>
@@ -324,16 +83,17 @@
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins, Watch } from 'vue-property-decorator'
import { thumbnailSmallMin, thumbnailSmallMax, thumbnailBigMin } from '@/store/variables'
import BaseMixin from '@/components/mixins/base'
import MinSettingsPanel from '@/components/panels/MinSettingsPanel.vue'
import KlippyStatePanel from '@/components/panels/KlippyStatePanel.vue'
import StatusPanelExcludeObject from '@/components/panels/StatusPanelExcludeObject.vue'
import StatusPanelPrintstatus from '@/components/panels/Status/Printstatus.vue'
import StatusPanelGcodefiles from '@/components/panels/Status/Gcodefiles.vue'
import StatusPanelJobqueue from '@/components/panels/Status/Jobqueue.vue'
import StatusPanelExcludeObject from '@/components/panels/Status/ExcludeObject.vue'
import StatusPanelPrintstatusThumbnail from '@/components/panels/Status/PrintstatusThumbnail.vue'
import Panel from '@/components/ui/Panel.vue'
import {
mdiCloseCircle,
mdiBroom,
mdiFileOutline,
mdiInformation,
mdiPause,
mdiPlay,
@@ -341,7 +101,7 @@ import {
mdiSelectionRemove,
mdiStop,
mdiMessageProcessingOutline,
mdiFile,
mdiCloseCircle,
} from '@mdi/js'
@Component({
@@ -350,50 +110,42 @@ import {
MinSettingsPanel,
Panel,
StatusPanelExcludeObject,
StatusPanelGcodefiles,
StatusPanelJobqueue,
StatusPanelPrintstatus,
StatusPanelPrintstatusThumbnail,
},
})
export default class StatusPanel extends Mixins(BaseMixin) {
mdiInformation = mdiInformation
mdiFileOutline = mdiFileOutline
mdiFile = mdiFile
mdiCloseCircle = mdiCloseCircle
mdiMessageProcessingOutline = mdiMessageProcessingOutline
mdiCloseCircle = mdiCloseCircle
maxFlow = 0
boolShowObjects = false
private boolShowObjects = false
private boolFirstLoad = true
declare $refs: {
bigThumbnail: any
}
private activeTab = 'files'
get jobs() {
return this.$store.getters['server/jobQueue/getJobs']
}
get jobsCount() {
return this.jobs?.length ?? 0
}
get current_filename() {
return this.$store.state.printer.print_stats?.filename ?? ''
}
get display_message() {
return this.$store.state.printer.display_status?.message ?? ''
}
get print_stats_message() {
return this.$store.state.printer.print_stats?.message ?? ''
}
get filament_used() {
return this.$store.state.printer.print_stats?.filament_used ?? 0
}
get current_file() {
return this.$store.state.printer.current_file ?? {}
}
get print_time() {
return this.$store.state.printer.print_stats?.print_duration ?? 0
}
get print_time_total() {
return this.$store.state.printer.print_stats?.total_duration ?? 0
}
get printPercent() {
return Math.round(this.$store.getters['printer/getPrintPercent'] * 100)
}
@@ -475,174 +227,31 @@ export default class StatusPanel extends Mixins(BaseMixin) {
})
}
get live_velocity() {
return Math.abs(this.$store.state.printer.motion_report?.live_velocity?.toFixed(0)) ?? null
}
get live_extruder_velocity() {
const live_extruder_velocity = this.$store.state.printer.motion_report?.live_extruder_velocity ?? null
if (live_extruder_velocity === null) return null
return live_extruder_velocity > 0 ? live_extruder_velocity : 0
}
get live_flow() {
if (this.live_extruder_velocity === null) return null
const filamentCrossSection = Math.pow(this.filament_diameter / 2, 2) * Math.PI
const currentFlow = filamentCrossSection * this.live_extruder_velocity
return currentFlow?.toFixed(1)
}
get requested_speed() {
const requested_speed = this.$store.state.printer.gcode_move?.speed ?? 0
const speed_factor = this.$store.state.printer.gcode_move?.speed_factor ?? 0
const max_velocity = this.$store.state.printer.toolhead?.max_velocity ?? 0
const speed = (requested_speed / 60) * speed_factor
if (speed > max_velocity) return max_velocity
return speed.toFixed(0)
}
get max_layers() {
if (
'first_layer_height' in this.current_file &&
'layer_height' in this.current_file &&
'object_height' in this.current_file
) {
const max = Math.ceil(
(this.current_file.object_height - this.current_file.first_layer_height) /
this.current_file.layer_height +
1
)
return max > 0 ? max : 0
}
return 0
}
get current_layer() {
if (this.print_time > 0 && 'first_layer_height' in this.current_file && 'layer_height' in this.current_file) {
const gcodePositionZ = this.$store.state.printer.gcode_move?.gcode_position[2] ?? 0
let current_layer = Math.ceil(
(gcodePositionZ - this.current_file.first_layer_height) / this.current_file.layer_height + 1
)
current_layer = current_layer <= this.max_layers ? current_layer : this.max_layers
return current_layer > 0 ? current_layer : 0
}
return 0
}
get estimated_time_file() {
return this.$store.getters['printer/getEstimatedTimeFile']
}
get estimated_time_filament() {
return this.$store.getters['printer/getEstimatedTimeFilament']
}
get estimated_time_slicer() {
return this.$store.getters['printer/getEstimatedTimeSlicer']
}
get estimated_time_avg() {
return this.$store.getters['printer/getEstimatedTimeAvg']
}
get eta() {
return this.$store.getters['printer/getEstimatedTimeETA']
}
get filament_diameter() {
return this.$store.state.printer.configfile?.settings?.extruder?.filament_diameter ?? 1.75
}
get thumbnailSmall() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find(
(thumb: any) =>
thumb.width >= thumbnailSmallMin &&
thumb.width <= thumbnailSmallMax &&
thumb.height >= thumbnailSmallMin &&
thumb.height <= thumbnailSmallMax
)
if (thumbnail && 'relative_path' in thumbnail) {
let relative_url = ''
if (this.current_file.filename.lastIndexOf('/') !== -1) {
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/') + 1)
}
if (thumbnail && 'relative_path' in thumbnail) {
return `${this.apiUrl}/server/files/gcodes/${encodeURI(
relative_url + thumbnail.relative_path
)}?timestamp=${this.current_file.modified}`
}
}
}
return ''
}
get thumbnailBig() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
if (thumbnail && 'relative_path' in thumbnail) {
let relative_url = ''
if (this.current_file.filename.lastIndexOf('/') !== -1) {
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/') + 1)
}
if (thumbnail && 'relative_path' in thumbnail) {
return `${this.apiUrl}/server/files/gcodes/${encodeURI(
relative_url + thumbnail.relative_path
)}?timestamp=${this.current_file.modified}`
}
}
}
return ''
}
get thumbnailBigHeight() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
if (thumbnail && 'height' in thumbnail) {
return thumbnail.height
}
}
return 200
}
get thumbnailBigWidth() {
if ('thumbnails' in this.current_file && this.current_file.thumbnails.length) {
const thumbnail = this.current_file.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
if (thumbnail && 'width' in thumbnail) {
return thumbnail.width
}
}
return 300
}
get boolBigThumbnail() {
const setting = this.$store.state.gui.uiSettings.boolBigThumbnail ?? true
return this.current_filename && setting && this.thumbnailBig
}
get printing_objects() {
return this.$store.state.printer.exclude_object?.objects ?? []
}
get display_message() {
return this.$store.state.printer.display_status?.message ?? ''
}
get print_stats_message() {
return this.$store.state.printer.print_stats?.message ?? ''
}
@Watch('current_filename')
current_filenameChanged(newVal: string) {
if (this.current_filename === '' && newVal !== '') this.activeTab = 'status'
if (this.boolFirstLoad && newVal !== '') {
this.boolFirstLoad = false
this.activeTab = 'status'
}
}
clearDisplayMessage() {
this.$socket.emit('printer.gcode.script', { script: 'M117' })
}
updateShowDialog(newVal: boolean) {
this.boolShowObjects = newVal
}
@@ -670,61 +279,5 @@ export default class StatusPanel extends Mixins(BaseMixin) {
btnReprintJob() {
this.$socket.emit('printer.print.start', { filename: this.current_filename }, { loading: 'statusPrintReprint' })
}
clearDisplayMessage() {
this.$socket.emit('printer.gcode.script', { script: 'M117' })
}
formatTime(seconds: number) {
let h = Math.floor(seconds / 3600)
seconds %= 3600
let m = ('0' + Math.floor(seconds / 60)).slice(-2)
let s = ('0' + (seconds % 60).toFixed(0)).slice(-2)
return h + ':' + m + ':' + s
}
formatDateTime(msec: number) {
const date = new Date(msec)
const h = date.getHours() >= 10 ? date.getHours() : '0' + date.getHours()
const m = date.getMinutes() >= 10 ? date.getMinutes() : '0' + date.getMinutes()
const diff = msec - new Date().getTime()
return h + ':' + m + (diff > 60 * 60 * 24 * 1000 ? '+' + Math.round(diff / (60 * 60 * 24 * 1000)) : '')
}
@Watch('live_flow')
live_flowChanged(newVal: number) {
if (newVal && this.maxFlow < newVal) this.maxFlow = newVal
}
focusBigThumbnail() {
if (this.$refs.bigThumbnail) {
const clientWidth = this.$refs.bigThumbnail.$el.clientWidth
const thumbnailWidth = this.thumbnailBigWidth
const factor = clientWidth / thumbnailWidth
this.$refs.bigThumbnail.$el.style.height = (this.thumbnailBigHeight * factor).toFixed() + 'px'
}
}
blurBigThumbnail() {
if (this.$refs.bigThumbnail) {
this.$refs.bigThumbnail.$el.style.height = '200px'
}
}
onResize() {
const isFocused = document.activeElement === this.$refs.bigThumbnail?.$el
if (isFocused) this.focusBigThumbnail()
}
created() {
window.addEventListener('resize', this.onResize)
}
destroyed() {
window.removeEventListener('resize', this.onResize)
}
}
</script>
+21 -1
View File
@@ -121,6 +121,15 @@
"SendCode": "Send code...",
"SetupConsole": "Setup Console"
},
"Dialogs": {
"StartPrint": {
"Cancel": "Cancel",
"DoYouWantToStartFilename": "Do you want to start {filename}?",
"Headline": "Start Job",
"Print": "print",
"Timelapse": "Timelapse"
}
},
"Editor": {
"Cancel": "Cancel",
"ConfigReference": "Config Reference",
@@ -156,7 +165,7 @@
"DeleteSelectedQuestion": "Do you really want to delete {count} selected files?",
"Download": "Download",
"Downloading": "Downloading",
"DoYouWantToStartFilename": "Do you want to start {filename}?",
"DropFilesToAddGcode": "Drag & Drop files to add G-Code.",
"EditFile": "Edit File",
"Empty": "Empty",
"Filament": "Filament",
@@ -170,8 +179,12 @@
"FreeDisk": "Free disk",
"GCodeFiles": "G-Code Files",
"HiddenFiles": "Hidden files",
"LastEndTime": "Last End Time",
"LastFilamentUsed": "Last Filament Used",
"LastModified": "Last modified",
"LastPrintDuration": "Last Print Duration",
"LastStartTime": "Last Start Time",
"LastTotalDuration": "Last Total Duration",
"LayerHeight": "Layer Height",
"Name": "Name",
"NewDirectory": "New Directory",
@@ -551,6 +564,12 @@
},
"Filament": "Filament",
"File": "File",
"Files": "Files",
"EmptyGcodes": "No G-Code available.",
"EmptyJobqueue": "There is currently no file in the job queue.",
"Jobqueue": "Jobqueue ({count})",
"JobqueueMoreFiles": "no more jobs | one more job | {count} more jobs",
"PrintTime": "Print Time",
"Flow": "Flow",
"Headline": "Status",
"Layer": "Layer",
@@ -563,6 +582,7 @@
"ResumePrint": "Resume print",
"Slicer": "Slicer",
"Speed": "Speed",
"Status": "Status",
"Total": "Total",
"Unknown": "Unknown"
},
+1 -1
View File
@@ -5,7 +5,7 @@ import { v4 as uuidv4 } from 'uuid'
export const actions: ActionTree<RootState, RootState> = {
switchToDashboard() {
router.push('/')
if (router.currentRoute.fullPath !== '/') router.push('/')
},
changePrinter({ dispatch, getters, state }, payload) {
+10 -2
View File
@@ -13,7 +13,15 @@ export const actions: ActionTree<EditorState, RootState> = {
},
openFile({ state, dispatch, commit, rootGetters, rootState }, payload) {
const fullFilepath = payload.root + payload.path + '/' + payload.filename
const fullFilepathArray = []
fullFilepathArray.push(payload.root)
let path = payload.path
if (path.slice(0, 1) === '/') path = path.slice(1)
if (path.slice(-1) === '/') path = path.slice(0, -1)
if (path !== '') fullFilepathArray.push(path)
fullFilepathArray.push(payload.filename)
const fullFilepath = fullFilepathArray.join('/')
const url = rootGetters['socket/getUrl'] + '/server/files/' + encodeURI(fullFilepath) + `?${Date.now()}`
if (state.cancelToken) dispatch('cancelLoad')
@@ -66,7 +74,7 @@ export const actions: ActionTree<EditorState, RootState> = {
commit('openFile', {
filename: payload.filename,
fileroot: payload.root,
filepath: payload.path,
filepath: path,
file,
})
})
+98 -21
View File
@@ -8,6 +8,7 @@ import {
import { GetterTree } from 'vuex'
import { FileState, FileStateFile, FileStateGcodefile } from '@/store/files/types'
import { ServerHistoryStateJob } from '@/store/server/history/types'
import { ServerJobQueueStateJob } from '@/store/server/jobQueue/types'
// eslint-disable-next-line
export const getters: GetterTree<FileState, any> = {
@@ -42,10 +43,31 @@ export const getters: GetterTree<FileState, any> = {
getGcodeFiles:
(state, getters, rootState, rootGetters) =>
(path: string, boolShowHiddenFiles: boolean, boolShowPrintedFiles: boolean) => {
const directory = getters['getDirectory']('gcodes' + path)
const baseURL = `${rootGetters['socket/getUrl']}/server/files/gcodes${encodeURI(path)}`
let files = directory?.childrens ?? []
(path: string | null, boolShowHiddenFiles: boolean, boolShowPrintedFiles: boolean) => {
let baseURL = `${rootGetters['socket/getUrl']}/server/files/gcodes`
let files: FileStateFile[] = []
if (path !== null) {
baseURL += encodeURI(path)
const directory = getters['getDirectory']('gcodes' + path)
files = directory?.childrens ?? []
} else {
const rootGcodes = getters['getDirectory']('gcodes')
const searchGcodes = (directory: FileStateFile, currentPath: string) => {
if (directory.isDirectory && directory.childrens?.length) {
directory.childrens?.forEach((file) => {
if (!file.isDirectory) {
const tmp = { ...file }
tmp.filename = currentPath + file.filename
files.push(tmp)
} else searchGcodes(file, currentPath + file.filename + '/')
})
}
}
searchGcodes(rootGcodes, '')
}
files = files.filter((file: FileStateFile) => {
// filter hidden files
@@ -74,12 +96,18 @@ export const getters: GetterTree<FileState, any> = {
last_start_time: null,
last_end_time: null,
last_filament_used: null,
last_status: '',
last_status: null,
last_print_duration: null,
last_total_duration: null,
}
if (file.thumbnails?.length) {
let subdirectory = ''
if (path === null) {
const pos = file.filename.lastIndexOf('/')
if (pos > 0) subdirectory = '/' + file.filename.slice(0, pos)
}
const small_thumbnail = file.thumbnails.find(
(thumb) =>
thumb.width >= thumbnailSmallMin &&
@@ -89,7 +117,7 @@ export const getters: GetterTree<FileState, any> = {
)
if (small_thumbnail && 'relative_path' in small_thumbnail) {
tmp.small_thumbnail = `${baseURL}/${encodeURI(
tmp.small_thumbnail = `${baseURL + subdirectory}/${encodeURI(
small_thumbnail.relative_path
)}?timestamp=${fileTimestamp}`
}
@@ -97,7 +125,7 @@ export const getters: GetterTree<FileState, any> = {
const big_thumbnail = file.thumbnails.find((thumb) => thumb.width >= thumbnailBigMin)
if (big_thumbnail && 'relative_path' in big_thumbnail) {
tmp.big_thumbnail = `${baseURL}/${encodeURI(
tmp.big_thumbnail = `${baseURL + subdirectory}/${encodeURI(
big_thumbnail.relative_path
)}?timestamp=${fileTimestamp}`
@@ -105,35 +133,50 @@ export const getters: GetterTree<FileState, any> = {
}
}
const fullFilename = path.length ? path + '/' + file.filename : file.filename
const histories = rootGetters['server/history/getPrintJobsForGcodes'](
const fullFilename = path && path.length ? path + '/' + file.filename : file.filename
let histories = rootGetters['server/history/getPrintJobsForGcodes'](
fullFilename,
fileTimestamp,
file.size,
file.uuid ?? null,
file.job_id
)
if (histories && histories.length) {
const history = histories[0]
tmp.last_end_time = new Date(history.end_time * 1000)
tmp.last_filament_used = history.filament_used
tmp.last_print_duration = history.print_duration
tmp.last_start_time = new Date(history.start_time * 1000)
tmp.last_status = history.status
tmp.last_total_duration = history.total_duration
tmp.count_printed = histories.filter(
(job: ServerHistoryStateJob) => job.status === 'completed'
).length
if (histories && histories.length) {
histories = histories.sort(
(a: ServerHistoryStateJob, b: ServerHistoryStateJob) => b.start_time - a.start_time
)
const histories_completed = histories.filter(
(history: ServerHistoryStateJob) => history.status === 'completed'
)
const last_history = [...histories].shift()
tmp.last_status = last_history.status
tmp.count_printed = histories_completed.length
tmp.last_start_time = new Date(last_history.start_time * 1000)
if (tmp.count_printed > 0) {
const history_completed = histories_completed[0]
tmp.last_start_time = new Date(history_completed.start_time * 1000)
tmp.last_end_time = new Date(history_completed.end_time * 1000)
tmp.last_filament_used = history_completed.filament_used
tmp.last_print_duration = history_completed.print_duration
tmp.last_total_duration = history_completed.total_duration
}
}
if (boolShowPrintedFiles) output.push(tmp)
else if (tmp.last_status !== 'completed') output.push(tmp)
else if (tmp.count_printed === 0) output.push(tmp)
})
return output
},
getAllGcodes: (state, getters) => {
return getters['getGcodeFiles'](null, false, true)
},
getThemeFileUrl: (state, getters, rootState, rootGetters) => (acceptName: string, acceptExtensions: string[]) => {
const directory = getters['getDirectory']('config/' + themeDir)
@@ -208,4 +251,38 @@ export const getters: GetterTree<FileState, any> = {
) !== -1
)
},
getSmallThumbnail: (state, getters, rootState, rootGetters) => (item: FileStateFile, currentPath: string) => {
if ('thumbnails' in item && item.thumbnails?.length) {
const thumbnail = item.thumbnails.find(
(thumb) =>
thumb.width >= thumbnailSmallMin &&
thumb.width <= thumbnailSmallMax &&
thumb.height >= thumbnailSmallMin &&
thumb.height <= thumbnailSmallMax
)
if (thumbnail && 'relative_path' in thumbnail) {
return `${rootGetters['socket/getUrl']}/server/files/${currentPath}/${encodeURI(
thumbnail.relative_path
)}?timestamp=${item.modified.getTime()}`
}
}
return ''
},
getBigThumbnail: (state, getters, rootState, rootGetters) => (item: FileStateFile, currentPath: string) => {
if ('thumbnails' in item && item.thumbnails?.length) {
const thumbnail = item.thumbnails.find((thumb) => thumb.width >= thumbnailBigMin)
if (thumbnail && 'relative_path' in thumbnail) {
return `${rootGetters['socket/getUrl']}/server/files/${encodeURI(currentPath)}/${encodeURI(
thumbnail.relative_path
)}?timestamp=${item.modified.getTime()}`
}
}
return ''
},
}
+5 -4
View File
@@ -22,14 +22,15 @@ export const mutations: MutationTree<ServerHistoryState> = {
},
addJob(state, payload) {
state.jobs.push(payload)
const jobs = [...state.jobs]
jobs.push(payload)
Vue.set(state, 'jobs', jobs)
},
updateJob(state, payload) {
const index = state.jobs.findIndex((job) => job.job_id === payload.job_id)
if (index !== -1) {
Vue.set(state.jobs, index, payload)
}
if (index !== -1) Vue.set(state.jobs, index, payload)
},
destroyJob(state, payload) {
+1 -1
View File
@@ -13,7 +13,7 @@ export const actions: ActionTree<ServerJobQueueState, RootState> = {
},
getEvent({ commit }, payload) {
if ('updated_queue' in payload) commit('setQueuedJobs', payload.updated_queue)
if ('updated_queue' in payload && payload.updated_queue !== null) commit('setQueuedJobs', payload.updated_queue)
if ('queue_state' in payload) commit('setQueueState', payload.queue_state)
},
+53
View File
@@ -1,6 +1,7 @@
import { GetterTree } from 'vuex'
import { ServerJobQueueState, ServerJobQueueStateJob } from '@/store/server/jobQueue/types'
import Vue from 'vue'
import { thumbnailBigMin, thumbnailSmallMax, thumbnailSmallMin } from '@/store/variables'
// eslint-disable-next-line
export const getters: GetterTree<ServerJobQueueState, any> = {
@@ -19,4 +20,56 @@ export const getters: GetterTree<ServerJobQueueState, any> = {
return jobs
},
getSmallThumbnail: (state, getters, rootState, rootGetters) => (item: ServerJobQueueStateJob) => {
if (item?.metadata?.thumbnails?.length) {
const thumbnail = item?.metadata?.thumbnails.find(
(thumb: any) =>
thumb.width >= thumbnailSmallMin &&
thumb.width <= thumbnailSmallMax &&
thumb.height >= thumbnailSmallMin &&
thumb.height <= thumbnailSmallMax
)
const path =
item.filename.lastIndexOf('/') !== -1
? 'gcodes/' + item.filename.slice(0, item.filename.lastIndexOf('/'))
: 'gcodes'
if (thumbnail && 'relative_path' in thumbnail)
return (
rootGetters['socket/getUrl'] +
'/server/files/' +
path +
'/' +
encodeURI(thumbnail.relative_path) +
'?timestamp=' +
item.metadata?.modified.getTime()
)
}
return ''
},
getBigThumbnail: (state, getters, rootState, rootGetters) => (item: ServerJobQueueStateJob) => {
if (item?.metadata?.thumbnails?.length) {
const thumbnail = item?.metadata?.thumbnails.find((thumb: any) => thumb.width >= thumbnailBigMin)
const path =
item.filename.lastIndexOf('/') !== -1
? 'gcodes/' + item.filename.slice(0, item.filename.lastIndexOf('/'))
: 'gcodes'
if (thumbnail && 'relative_path' in thumbnail)
return (
rootGetters['socket/getUrl'] +
'/server/files/' +
path +
'/' +
encodeURI(thumbnail.relative_path) +
'?timestamp=' +
item.metadata?.modified.getTime()
)
}
return ''
},
}
+1
View File
@@ -9,4 +9,5 @@ export interface ServerJobQueueStateJob {
time_added: number
time_in_queue: number
metadata?: any
isFirst?: boolean
}