From d56ab7863b7b5455428118c7b300cd75dee9e6fd Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 29 Jan 2023 14:48:23 +0100 Subject: [PATCH 01/25] feat: add jobs to queue in batches WIP Signed-off-by: Stefan Dej --- src/components/panels/GcodefilesPanel.vue | 53 ++++++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index f7e5a72cb..bfc3d2ff2 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -319,7 +319,7 @@ + @click="openAddToQueueDialog(contextMenu.item)"> {{ mdiPlaylistPlus }} {{ $t('Files.AddToQueue') }} @@ -495,6 +495,33 @@ + + + + + + + + + + {{ $t('Files.Cancel') }} + {{ $t('Files.AddToQueue') }} + + + @@ -554,6 +581,12 @@ interface dialogPrintFile { item: FileStateGcodefile } +interface dialogAddToQueue { + show: boolean + count: number + item: FileStateGcodefile +} + interface dialogRenameObject { show: boolean newName: string @@ -648,6 +681,12 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { item: { ...this.contextMenu.item }, } + private dialogAddToQueue: dialogAddToQueue = { + show: false, + count: 1, + item: { ...this.contextMenu.item }, + } + private dialogRenameFile: dialogRenameObject = { show: false, newName: '', @@ -673,6 +712,10 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { (value: string) => !!value || this.$t('Files.InvalidNameEmpty'), (value: string) => !this.existsFilename(value) || this.$t('Files.InvalidNameAlreadyExists'), ] + private countInputRules = [ + (value: string) => !!value || this.$t('Files.InvalidNameEmpty'), + (value: string) => !this.existsFilename(value) || this.$t('Files.InvalidNameAlreadyExists'), + ] existsFilename(name: string) { return this.files.findIndex((file: FileStateFile) => file.filename === name) >= 0 @@ -1099,7 +1142,13 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { this.currentPath = this.currentPath.slice(0, this.currentPath.lastIndexOf('/')) } - addToQueue(item: FileStateGcodefile | FileStateFile) { + openAddToQueueDialog(item: FileStateGcodefile) { + this.dialogAddToQueue.show = true + this.dialogAddToQueue.count = 1 + this.dialogAddToQueue.item = item + } + + addToQueueAction(item: FileStateGcodefile | FileStateFile) { let filename = [this.currentPath, item.filename].join('/') if (filename.startsWith('/')) filename = filename.slice(1) From adbd8a5bee0b3cd139b55c98a54fc4c02e8fece9 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 4 Feb 2023 12:26:36 +0100 Subject: [PATCH 02/25] feat(gcodefiles): add jobs to queue in batches Signed-off-by: Stefan Dej --- src/components/panels/GcodefilesPanel.vue | 13 ++++++++++--- src/locales/en.json | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index bfc3d2ff2..ed54bcdc6 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -1148,11 +1148,18 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { this.dialogAddToQueue.item = item } - addToQueueAction(item: FileStateGcodefile | FileStateFile) { - let filename = [this.currentPath, item.filename].join('/') + async addToQueueAction() { + let filename = [this.currentPath, this.dialogAddToQueue.item.filename].join('/') if (filename.startsWith('/')) filename = filename.slice(1) - this.$store.dispatch('server/jobQueue/addToQueue', [filename]) + const array: string[] = [] + for (let i = 0; i < this.dialogAddToQueue.count; i++) { + array.push(filename) + } + + await this.$store.dispatch('server/jobQueue/addToQueue', array) + + this.dialogAddToQueue.show = false } changeMetadataVisible(name: string, value: boolean) { diff --git a/src/locales/en.json b/src/locales/en.json index 58a43ff0d..9767113b3 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -169,6 +169,7 @@ "BedTemp": "Bed Temp.", "Cancel": "Cancel", "ChamberTemp": "Chamber Temp.", + "Count": "Count", "Create": "Create", "CreateNewDirectory": "Create new Directory", "CurrentPath": "Current path", From 3d1f7fa96b1af7ef2a618b21e3ceabe31010fbfd Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 09:36:58 +0100 Subject: [PATCH 03/25] refactor: add seperate button for "add patch to queue Signed-off-by: Stefan Dej --- src/components/panels/GcodefilesPanel.vue | 48 +++++++++++++++-------- src/locales/en.json | 1 + 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index ff6fd83d8..c50fbba10 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -320,10 +320,17 @@ + @click="addToQueue(contextMenu.item)"> {{ mdiPlaylistPlus }} {{ $t('Files.AddToQueue') }} + + {{ mdiPlaylistPlus }} + {{ $t('Files.AddPatchToQueue') }} + - + @@ -510,16 +517,16 @@ + @keyup.enter="dialogAddPatchToQueue"> - {{ $t('Files.Cancel') }} - {{ $t('Files.AddToQueue') }} + {{ $t('Files.Cancel') }} + {{ $t('Files.AddToQueue') }} @@ -579,7 +586,7 @@ interface dialogPrintFile { item: FileStateGcodefile } -interface dialogAddToQueue { +interface dialogAddPatchToQueue { show: boolean count: number item: FileStateGcodefile @@ -679,7 +686,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { item: { ...this.contextMenu.item }, } - private dialogAddToQueue: dialogAddToQueue = { + private dialogAddPatchToQueue: dialogAddPatchToQueue = { show: false, count: 1, item: { ...this.contextMenu.item }, @@ -1140,24 +1147,31 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { this.currentPath = this.currentPath.slice(0, this.currentPath.lastIndexOf('/')) } - openAddToQueueDialog(item: FileStateGcodefile) { - this.dialogAddToQueue.show = true - this.dialogAddToQueue.count = 1 - this.dialogAddToQueue.item = item + async addToQueue(item: FileStateGcodefile) { + let filename = [this.currentPath, this.dialogAddPatchToQueue.item.filename].join('/') + if (filename.startsWith('/')) filename = filename.slice(1) + + await this.$store.dispatch('server/jobQueue/addToQueue', [filename]) + } + + openAddPatchToQueueDialog(item: FileStateGcodefile) { + this.dialogAddPatchToQueue.show = true + this.dialogAddPatchToQueue.count = 1 + this.dialogAddPatchToQueue.item = item } - async addToQueueAction() { - let filename = [this.currentPath, this.dialogAddToQueue.item.filename].join('/') + async addPatchToQueueAction() { + let filename = [this.currentPath, this.dialogAddPatchToQueue.item.filename].join('/') if (filename.startsWith('/')) filename = filename.slice(1) const array: string[] = [] - for (let i = 0; i < this.dialogAddToQueue.count; i++) { + for (let i = 0; i < this.dialogAddPatchToQueue.count; i++) { array.push(filename) } await this.$store.dispatch('server/jobQueue/addToQueue', array) - this.dialogAddToQueue.show = false + this.dialogAddPatchToQueue.show = false } changeMetadataVisible(name: string, value: boolean) { diff --git a/src/locales/en.json b/src/locales/en.json index 97e9844a8..f81679529 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -164,6 +164,7 @@ "Yes": "Yes" }, "Files": { + "AddPatchToQueue": "Add patch to Queue", "AddToQueue": "Add to Queue", "AllFiles": "All", "BedTemp": "Bed Temp.", From 676047c64f6363f3536baea453a6c60f921aa6fd Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 12:22:47 +0100 Subject: [PATCH 04/25] fix: add jobs to queue with enter Signed-off-by: Stefan Dej --- src/components/panels/GcodefilesPanel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index c50fbba10..43365fff9 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -521,7 +521,7 @@ :label="$t('Files.Count')" required :rules="countInputRules" - @keyup.enter="dialogAddPatchToQueue"> + @keyup.enter="addPatchToQueueAction"> From 1e45c5988995478798fcf61dcacd23c2d8078e00 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 12:23:09 +0100 Subject: [PATCH 05/25] feat: combine multiple same jobs in job queue Signed-off-by: Stefan Dej --- src/store/server/jobQueue/getters.ts | 9 ++++++++- src/store/server/jobQueue/types.ts | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/store/server/jobQueue/getters.ts b/src/store/server/jobQueue/getters.ts index 62265776f..6508d599d 100644 --- a/src/store/server/jobQueue/getters.ts +++ b/src/store/server/jobQueue/getters.ts @@ -10,10 +10,17 @@ export const getters: GetterTree = { state.queued_jobs.forEach((queuedJob) => { const job = { ...queuedJob } + + if (jobs.length && jobs[jobs.length - 1].filename === job.filename) { + jobs[jobs.length - 1].count = (jobs[jobs.length - 1].count ?? 1) + 1 + return + } + const file = rootGetters['files/getFile']('gcodes/' + job.filename) if (!file?.metadataPulled) Vue.$socket.emit('server.files.metadata', { filename: job.filename }, { action: 'files/getMetadata' }) - job['metadata'] = file + job.metadata = file + job.count = 1 jobs.push(job) }) diff --git a/src/store/server/jobQueue/types.ts b/src/store/server/jobQueue/types.ts index 1b0072566..297f546e5 100644 --- a/src/store/server/jobQueue/types.ts +++ b/src/store/server/jobQueue/types.ts @@ -10,4 +10,5 @@ export interface ServerJobQueueStateJob { time_in_queue: number metadata?: any isFirst?: boolean + count?: number } From 8cd2eb22b7163f70f7ac680719d15b6e9f4a5d1c Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 12:25:26 +0100 Subject: [PATCH 06/25] refactor: thumbnail vue-load-image slots in status panel jobqueue Signed-off-by: Stefan Dej --- src/components/panels/Status/Jobqueue.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/panels/Status/Jobqueue.vue b/src/components/panels/Status/Jobqueue.vue index 4e8a76f91..fbc66e8f2 100644 --- a/src/components/panels/Status/Jobqueue.vue +++ b/src/components/panels/Status/Jobqueue.vue @@ -32,11 +32,12 @@ height="32" v-bind="attrs" v-on="on" /> - - {{ mdiFile }} +
+ +
+
+ {{ mdiFile }} +
From 9f27494548df0d7a081bd936cf2fe2f415ba6055 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 12:25:58 +0100 Subject: [PATCH 07/25] refactor: thumbnail vue-load-image slots in status panel jobqueue Signed-off-by: Stefan Dej --- src/components/panels/Status/Jobqueue.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/panels/Status/Jobqueue.vue b/src/components/panels/Status/Jobqueue.vue index fbc66e8f2..e37757506 100644 --- a/src/components/panels/Status/Jobqueue.vue +++ b/src/components/panels/Status/Jobqueue.vue @@ -46,11 +46,12 @@ -
{{ item.filename }}
+
+ {{ item.count }}x + {{ item.filename }} +
{{ getDescription(item) }} From 5c3ece66a498e442666c622cec8a20c46075bb75 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 12:29:43 +0100 Subject: [PATCH 09/25] feat: display count of jobqueue on status panel Signed-off-by: Stefan Dej --- src/components/panels/JobqueuePanel.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/panels/JobqueuePanel.vue b/src/components/panels/JobqueuePanel.vue index 09c1cd14c..765bf9cc2 100644 --- a/src/components/panels/JobqueuePanel.vue +++ b/src/components/panels/JobqueuePanel.vue @@ -93,7 +93,10 @@ -
{{ item.filename }}
+
+ {{ item.count }}x + {{ item.filename }} +
{{ getDescription(item) }} From a669db468ab22eaceea16b7e274a6e511b004a56 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 12:29:57 +0100 Subject: [PATCH 10/25] refactor: thumbnail vue-load-image slots in gcode jobqueuepanel Signed-off-by: Stefan Dej --- src/components/panels/JobqueuePanel.vue | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/panels/JobqueuePanel.vue b/src/components/panels/JobqueuePanel.vue index 765bf9cc2..9aa066ac8 100644 --- a/src/components/panels/JobqueuePanel.vue +++ b/src/components/panels/JobqueuePanel.vue @@ -68,11 +68,12 @@ height="32" v-bind="attrs" v-on="on" /> - - {{ mdiFile }} +
+ +
+
+ {{ mdiFile }} +
@@ -81,11 +82,12 @@
- {{ item.count }}x + {{ item.combinedIds.length + 1 }}x {{ item.filename }}
{{ getDescription(item) }} @@ -147,9 +147,11 @@ export default class StatusPanelJobqueue extends Mixins(BaseMixin) { 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 + const count = (item.combinedIds?.length ?? 0) + 1 + + if (item.metadata?.filament_total) filamentLength += item.metadata?.filament_total * count + if (item.metadata?.filament_weight_total) filamentWeight += item.metadata?.filament_weight_total * count + if (item.metadata?.estimated_time) printTime = item.metadata.estimated_time * count }) let output = '' @@ -255,7 +257,10 @@ export default class StatusPanelJobqueue extends Mixins(BaseMixin) { } removeFromJobqueue(item: ServerJobQueueStateJob) { - this.$store.dispatch('server/jobQueue/deleteFromQueue', [item.job_id]) + const ids = [...(item.combinedIds ?? [])] + ids.push(item.job_id) + + this.$store.dispatch('server/jobQueue/deleteFromQueue', ids) } mounted() { diff --git a/src/store/server/jobQueue/getters.ts b/src/store/server/jobQueue/getters.ts index 6508d599d..23c8d3487 100644 --- a/src/store/server/jobQueue/getters.ts +++ b/src/store/server/jobQueue/getters.ts @@ -12,7 +12,7 @@ export const getters: GetterTree = { const job = { ...queuedJob } if (jobs.length && jobs[jobs.length - 1].filename === job.filename) { - jobs[jobs.length - 1].count = (jobs[jobs.length - 1].count ?? 1) + 1 + jobs[jobs.length - 1].combinedIds?.push(job.job_id) return } @@ -20,7 +20,7 @@ export const getters: GetterTree = { if (!file?.metadataPulled) Vue.$socket.emit('server.files.metadata', { filename: job.filename }, { action: 'files/getMetadata' }) job.metadata = file - job.count = 1 + job.combinedIds = [] jobs.push(job) }) diff --git a/src/store/server/jobQueue/types.ts b/src/store/server/jobQueue/types.ts index 297f546e5..2d162b45d 100644 --- a/src/store/server/jobQueue/types.ts +++ b/src/store/server/jobQueue/types.ts @@ -10,5 +10,5 @@ export interface ServerJobQueueStateJob { time_in_queue: number metadata?: any isFirst?: boolean - count?: number + combinedIds?: string[] } From c6f1727606c03b4763ddc8cc9f3167db1b731858 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 11 Feb 2023 13:18:03 +0100 Subject: [PATCH 12/25] style: fix syntax Signed-off-by: Stefan Dej --- src/components/panels/JobqueuePanel.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/panels/JobqueuePanel.vue b/src/components/panels/JobqueuePanel.vue index 55286e586..2fa8cb59c 100644 --- a/src/components/panels/JobqueuePanel.vue +++ b/src/components/panels/JobqueuePanel.vue @@ -1,6 +1,10 @@