From 18ce88649fdd7f8e1a54c2912e0d37ac0ad42453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Wed, 14 Feb 2024 23:49:46 +0100 Subject: [PATCH 01/14] feat: Add ability to add history item to queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/components/panels/HistoryListPanel.vue | 22 ++++++++++++++++++++++ src/locales/en.json | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/components/panels/HistoryListPanel.vue b/src/components/panels/HistoryListPanel.vue index 3ef8af0b9..3cafc1d74 100644 --- a/src/components/panels/HistoryListPanel.vue +++ b/src/components/panels/HistoryListPanel.vue @@ -223,6 +223,12 @@ {{ mdiPrinter }} {{ $t('History.Reprint') }} + + {{ mdiPlaylistPlus }} + {{ $t('History.AddToQueue') }} + {{ mdiDelete }} {{ $t('History.Delete') }} @@ -509,6 +515,7 @@ import { mdiDatabaseArrowDownOutline, mdiCog, mdiPrinter, + mdiPlaylistPlus, mdiTextBoxSearch, mdiFile, mdiFileDocumentMultipleOutline, @@ -529,6 +536,7 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { mdiDatabaseArrowDownOutline = mdiDatabaseArrowDownOutline mdiCog = mdiCog mdiPrinter = mdiPrinter + mdiPlaylistPlus = mdiPlaylistPlus mdiFileDocumentMultipleOutline = mdiFileDocumentMultipleOutline mdiTextBoxSearch = mdiTextBoxSearch mdiFile = mdiFile @@ -785,6 +793,10 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { return this.$store.state.gui.general?.language ?? 'en' } + get isJobQueueAvailable() { + return this.moonrakerComponents.includes('job_queue') + } + refreshHistory() { this.$store.dispatch('socket/addLoading', { name: 'historyLoadAll' }) @@ -941,6 +953,16 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { this.$socket.emit('printer.print.start', { filename: item.filename }, { action: 'switchToDashboard' }) } + async addToQueue(item: ServerHistoryStateJob) { + if (!item.exists || !this.isJobQueueAvailable) { + return + } + + await this.$store.dispatch('server/jobQueue/addToQueue', [item.filename]) + + this.$toast.info(this.$t('History.AddToQueueSuccessful', { filename: item.filename }).toString()) + } + deleteJob() { this.$socket.emit( 'server.history.delete_job', diff --git a/src/locales/en.json b/src/locales/en.json index 58639460a..80d2e0a42 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -321,6 +321,8 @@ }, "History": { "AddNote": "Add note", + "AddToQueue": "Add to Queue", + "AddToQueueSuccessful": "File {filename} added to Queue.", "AllJobs": "All", "AvgPrinttime": "Print Time - Ø", "Cancel": "Cancel", From 64e2b4e52b607e226948be8943ed14b73b064823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Thu, 15 Feb 2024 00:56:27 +0100 Subject: [PATCH 02/14] feat: Add reusable AddBatchToQueueDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- .../dialogs/AddBatchToQueueDialog.vue | 116 ++++++++++++++++++ src/locales/en.json | 5 + 2 files changed, 121 insertions(+) create mode 100644 src/components/dialogs/AddBatchToQueueDialog.vue diff --git a/src/components/dialogs/AddBatchToQueueDialog.vue b/src/components/dialogs/AddBatchToQueueDialog.vue new file mode 100644 index 000000000..d6c61105d --- /dev/null +++ b/src/components/dialogs/AddBatchToQueueDialog.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/src/locales/en.json b/src/locales/en.json index 80d2e0a42..749827185 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -154,6 +154,11 @@ "Headline": "Start Job", "Print": "print", "Timelapse": "Timelapse" + }, + "AddBatchToQueue": { + "AddToQueue": "Add to Queue", + "Count": "Count", + "Cancel": "Cancel" } }, "Editor": { From cdfe97fb3b308c7fbe5b064f2445066ebe52800a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Thu, 15 Feb 2024 00:58:44 +0100 Subject: [PATCH 03/14] feat: Use AddBatchToQueueDialog in Gcode files panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/components/panels/GcodefilesPanel.vue | 90 ++++------------------- 1 file changed, 13 insertions(+), 77 deletions(-) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index 052a61bde..944d94727 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -568,53 +568,10 @@ - - - - - - - - - - - - {{ $t('Files.Cancel') }} - {{ $t('Files.AddToQueue') }} - - - + @@ -628,8 +585,6 @@ import Panel from '@/components/ui/Panel.vue' import SettingsRow from '@/components/settings/SettingsRow.vue' import draggable from 'vuedraggable' import { - mdiChevronDown, - mdiChevronUp, mdiDragVertical, mdiCheckboxBlankOutline, mdiCheckboxMarked, @@ -654,6 +609,7 @@ import { mdiContentCopy, } from '@mdi/js' import StartPrintDialog from '@/components/dialogs/StartPrintDialog.vue' +import AddBatchToQueueDialog, { addBatchToQueueDialogProps } from '@/components/dialogs/AddBatchToQueueDialog.vue' import ControlMixin from '@/components/mixins/control' import PathNavigation from '@/components/ui/PathNavigation.vue' @@ -675,12 +631,6 @@ interface dialogPrintFile { item: FileStateGcodefile } -interface dialogAddBatchToQueue { - show: boolean - count: number - item: FileStateGcodefile -} - interface dialogRenameObject { show: boolean newName: string @@ -698,11 +648,9 @@ interface tableColumnSetting { } @Component({ - components: { StartPrintDialog, Panel, SettingsRow, PathNavigation, draggable }, + components: { StartPrintDialog, AddBatchToQueueDialog, Panel, SettingsRow, PathNavigation, draggable }, }) export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { - mdiChevronDown = mdiChevronDown - mdiChevronUp = mdiChevronUp mdiContentCopy = mdiContentCopy mdiFile = mdiFile mdiFileDocumentMultipleOutline = mdiFileDocumentMultipleOutline @@ -779,10 +727,9 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { item: { ...this.contextMenu.item }, } - private dialogAddBatchToQueue: dialogAddBatchToQueue = { - show: false, - count: 1, - item: { ...this.contextMenu.item }, + private dialogAddBatchToQueue: addBatchToQueueDialogProps = { + isVisible: false, + filename: '', } private dialogRenameFile: dialogRenameObject = { @@ -1272,23 +1219,12 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { } openAddBatchToQueueDialog(item: FileStateGcodefile) { - this.dialogAddBatchToQueue.show = true - this.dialogAddBatchToQueue.count = 1 - this.dialogAddBatchToQueue.item = item + this.dialogAddBatchToQueue.isVisible = true + this.dialogAddBatchToQueue.filename = item.filename } - async addBatchToQueueAction() { - let filename = [this.currentPath, this.dialogAddBatchToQueue.item.filename].join('/') - if (filename.startsWith('/')) filename = filename.slice(1) - - const array: string[] = [] - for (let i = 0; i < this.dialogAddBatchToQueue.count; i++) { - array.push(filename) - } - - await this.$store.dispatch('server/jobQueue/addToQueue', array) - - this.dialogAddBatchToQueue.show = false + closeAddBatchToQueueDialog() { + this.dialogAddBatchToQueue.isVisible = false } changeMetadataVisible(name: string, value: boolean) { From 390b9ad10b86303e6a3fb97ed8fd6de8a60913eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Thu, 15 Feb 2024 01:02:07 +0100 Subject: [PATCH 04/14] feat: Use AddBatchToQueueDialog in History list panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/components/panels/HistoryListPanel.vue | 28 +++++++++++++++++++++- src/locales/en.json | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/components/panels/HistoryListPanel.vue b/src/components/panels/HistoryListPanel.vue index 3cafc1d74..872f6ea86 100644 --- a/src/components/panels/HistoryListPanel.vue +++ b/src/components/panels/HistoryListPanel.vue @@ -229,6 +229,12 @@ {{ mdiPlaylistPlus }} {{ $t('History.AddToQueue') }} + + {{ mdiPlaylistPlus }} + {{ $t('History.AddBatchToQueue') }} + {{ mdiDelete }} {{ $t('History.Delete') }} @@ -499,6 +505,10 @@ + @@ -527,8 +537,10 @@ import { mdiNotebook, mdiFileCancel, } from '@mdi/js' +import AddBatchToQueueDialog, { addBatchToQueueDialogProps } from '@/components/dialogs/AddBatchToQueueDialog.vue' + @Component({ - components: { Panel }, + components: { Panel, AddBatchToQueueDialog }, }) export default class HistoryListPanel extends Mixins(BaseMixin) { mdiDatabaseExportOutline = mdiDatabaseExportOutline @@ -567,6 +579,11 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { boolShow: false, } + private dialogAddBatchToQueue: addBatchToQueueDialogProps = { + isVisible: false, + filename: '', + } + private noteDialog: { item: ServerHistoryStateJob | null note: string @@ -963,6 +980,15 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { this.$toast.info(this.$t('History.AddToQueueSuccessful', { filename: item.filename }).toString()) } + openAddBatchToQueueDialog(item: ServerHistoryStateJob) { + this.dialogAddBatchToQueue.isVisible = true + this.dialogAddBatchToQueue.filename = item.filename + } + + closeAddBatchToQueueDialog() { + this.dialogAddBatchToQueue.isVisible = false + } + deleteJob() { this.$socket.emit( 'server.history.delete_job', diff --git a/src/locales/en.json b/src/locales/en.json index 749827185..830ddc21d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -326,6 +326,7 @@ }, "History": { "AddNote": "Add note", + "AddBatchToQueue": "Add batch to Queue", "AddToQueue": "Add to Queue", "AddToQueueSuccessful": "File {filename} added to Queue.", "AllJobs": "All", From 689d7e757d76ff15dd60e9e6d6669c09cf00e321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Thu, 15 Feb 2024 01:30:48 +0100 Subject: [PATCH 05/14] feat: Use AddBatchToQueueDialog in Status Gcode files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/components/panels/Status/Gcodefiles.vue | 92 +++------------------ 1 file changed, 13 insertions(+), 79 deletions(-) diff --git a/src/components/panels/Status/Gcodefiles.vue b/src/components/panels/Status/Gcodefiles.vue index 6ddcb7a66..b62e4e260 100644 --- a/src/components/panels/Status/Gcodefiles.vue +++ b/src/components/panels/Status/Gcodefiles.vue @@ -173,53 +173,10 @@ - - - - - - - - - - - - {{ $t('Files.Cancel') }} - {{ $t('Files.AddToQueue') }} - - - + @@ -246,6 +203,7 @@ import { } from '@mdi/js' import Panel from '@/components/ui/Panel.vue' import { defaultBigThumbnailBackground } from '@/store/variables' +import AddBatchToQueueDialog, { addBatchToQueueDialogProps } from '@/components/dialogs/AddBatchToQueueDialog.vue' interface dialogRenameObject { show: boolean @@ -253,16 +211,11 @@ interface dialogRenameObject { item: FileStateGcodefile } -interface dialogAddBatchToQueue { - show: boolean - count: number - item: FileStateGcodefile -} - @Component({ components: { Panel, StartPrintDialog, + AddBatchToQueueDialog, }, }) export default class StatusPanelGcodefiles extends Mixins(BaseMixin, ControlMixin) { @@ -320,10 +273,9 @@ export default class StatusPanelGcodefiles extends Mixins(BaseMixin, ControlMixi item: { ...this.dialogFile }, } - private dialogAddBatchToQueue: dialogAddBatchToQueue = { - show: false, - count: 1, - item: { ...this.contextMenu.item }, + private dialogAddBatchToQueue: addBatchToQueueDialogProps = { + isVisible: false, + filename: '', } private countInputRules = [ @@ -470,23 +422,12 @@ export default class StatusPanelGcodefiles extends Mixins(BaseMixin, ControlMixi } openAddBatchToQueueDialog(item: FileStateGcodefile) { - this.dialogAddBatchToQueue.show = true - this.dialogAddBatchToQueue.count = 1 - this.dialogAddBatchToQueue.item = item + this.dialogAddBatchToQueue.isVisible = true + this.dialogAddBatchToQueue.filename = item.filename } - async addBatchToQueueAction() { - let filename = [this.currentPath, this.dialogAddBatchToQueue.item.filename].join('/') - if (filename.startsWith('/')) filename = filename.slice(1) - - const array: string[] = [] - for (let i = 0; i < this.dialogAddBatchToQueue.count; i++) { - array.push(filename) - } - - await this.$store.dispatch('server/jobQueue/addToQueue', array) - - this.dialogAddBatchToQueue.show = false + closeAddBatchToQueueDialog() { + this.dialogAddBatchToQueue.isVisible = false } view3D(item: FileStateGcodefile) { @@ -571,11 +512,4 @@ export default class StatusPanelGcodefiles extends Mixins(BaseMixin, ControlMixi .filesGcodeCard { position: relative; } - -._spin_button_group { - width: 24px; - margin-top: -6px; - margin-left: -6px; - margin-bottom: -6px; -} From db148f4c6a50c3763b3d14f0cb8e12105c8ee8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Thu, 15 Feb 2024 01:33:07 +0100 Subject: [PATCH 06/14] feat: Remove dead code & adjust filename creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/components/panels/GcodefilesPanel.vue | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index 944d94727..66ec7d5a9 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -1219,8 +1219,11 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { } openAddBatchToQueueDialog(item: FileStateGcodefile) { + let filename = [this.currentPath, item.filename].join('/') + if (filename.startsWith('/')) filename = filename.slice(1) + this.dialogAddBatchToQueue.isVisible = true - this.dialogAddBatchToQueue.filename = item.filename + this.dialogAddBatchToQueue.filename = filename } closeAddBatchToQueueDialog() { @@ -1485,15 +1488,6 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { } - -