From 900bc9577a56f3bf4395e2d6789a9e4e203ea73d Mon Sep 17 00:00:00 2001
From: Stefan Dej <meteyou@gmail.com>
Date: Tue, 28 Feb 2023 23:36:52 +0100
Subject: [PATCH 1/3] fix: only display PAUSE AT LAYER button, when the macros
 exists

Signed-off-by: Stefan Dej <meteyou@gmail.com>
---
 src/components/panels/StatusPanel.vue | 31 +++++++++++++++++++++------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue
index 40b393b2d..3ce0ae7dd 100644
--- a/src/components/panels/StatusPanel.vue
+++ b/src/components/panels/StatusPanel.vue
@@ -63,7 +63,7 @@
                         <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 }}
+                                {{ print_stats_message ?? display_message }}
                             </span>
                         </v-col>
                         <v-col class="col-auto py-2">
@@ -83,13 +83,13 @@
             <v-divider class="my-0"></v-divider>
             <v-tabs-items v-model="activeTab" class="_border-radius">
                 <v-tab-item v-if="current_filename" value="status">
-                    <status-panel-printstatus></status-panel-printstatus>
+                    <status-panel-printstatus />
                 </v-tab-item>
                 <v-tab-item value="files">
-                    <status-panel-gcodefiles></status-panel-gcodefiles>
+                    <status-panel-gcodefiles />
                 </v-tab-item>
                 <v-tab-item value="jobqueue">
-                    <status-panel-jobqueue></status-panel-jobqueue>
+                    <status-panel-jobqueue />
                 </v-tab-item>
             </v-tabs-items>
         </panel>
@@ -122,6 +122,7 @@ import {
     mdiLayersPlus,
     mdiDotsVertical,
 } from '@mdi/js'
+import { PrinterStateMacro } from '@/store/printer/types'
 
 @Component({
     components: {
@@ -295,10 +296,10 @@ export default class StatusPanel extends Mixins(BaseMixin) {
                 click: this.btnExcludeObject,
             },
             {
-                text: this.$t('Panels.StatusPanel.PauseAtLayer.PauseAtLayer'),
+                text: this.$t('Panels.StatusPanel.PauseAtLayer.PauseAtLayer') + ' - ' + this.displayPauseAtLayerButton,
                 loadingName: 'pauseAtLayer',
                 icon: mdiLayersPlus,
-                status: () => this.layer_count !== null,
+                status: () => this.displayPauseAtLayerButton,
                 disabled: () => ['paused', 'printing'].includes(this.printer_state),
                 click: this.btnPauseAtLayer,
             },
@@ -306,7 +307,7 @@ export default class StatusPanel extends Mixins(BaseMixin) {
     }
 
     get multiFunctionMenuButtonsFiltered() {
-        return this.multiFunctionMenuButtons.filter((button) => button.status)
+        return this.multiFunctionMenuButtons.filter((button) => button.status())
     }
 
     get multiFunctionButton() {
@@ -315,6 +316,22 @@ export default class StatusPanel extends Mixins(BaseMixin) {
         return this.multiFunctionMenuButtonsFiltered.length > 1
     }
 
+    get macros() {
+        return this.$store.getters['printer/getMacros'] ?? []
+    }
+
+    get existsSetPauseAtLayer() {
+        return this.macros.findIndex((macro: PrinterStateMacro) => macro.name === 'SET_PAUSE_AT_LAYER') !== -1
+    }
+
+    get existsSetPauseNextLayer() {
+        return this.macros.findIndex((macro: PrinterStateMacro) => macro.name === 'SET_PAUSE_NEXT_LAYER') !== -1
+    }
+
+    get displayPauseAtLayerButton() {
+        return this.layer_count !== null && (this.existsSetPauseAtLayer || this.existsSetPauseNextLayer)
+    }
+
     mounted() {
         if (this.current_filename !== '') this.activeTab = 'status'
     }

From 614363d181a323c8a6e7d8a427b4bcfb4c09c0c5 Mon Sep 17 00:00:00 2001
From: Stefan Dej <meteyou@gmail.com>
Date: Thu, 2 Mar 2023 22:38:21 +0100
Subject: [PATCH 2/3] refactor: add ENABLE=1 to SET_PAUSE_AT_LAYER and
 SET_PAUSE_NEXT_LAYER

Signed-off-by: Stefan Dej <meteyou@gmail.com>
---
 src/components/panels/Status/PauseAtLayerDialog.vue | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/components/panels/Status/PauseAtLayerDialog.vue b/src/components/panels/Status/PauseAtLayerDialog.vue
index c21a4c88e..5d28589d0 100644
--- a/src/components/panels/Status/PauseAtLayerDialog.vue
+++ b/src/components/panels/Status/PauseAtLayerDialog.vue
@@ -189,12 +189,12 @@ export default class StatusPanelPauseAtLayerDialog extends Mixins(BaseMixin) {
 
     sendCommand() {
         if (this.type === 'atLayer') {
-            this.doSend(`SET_PAUSE_AT_LAYER LAYER=${this.layer} MACRO=${this.call}`)
+            this.doSend(`SET_PAUSE_AT_LAYER ENABLE=1 LAYER=${this.layer} MACRO=${this.call}`)
             this.hideDialog()
             return
         }
 
-        this.doSend(`SET_PAUSE_NEXT_LAYER MACRO=${this.call}`)
+        this.doSend(`SET_PAUSE_NEXT_LAYER ENABLE=1 MACRO=${this.call}`)
         this.hideDialog()
     }
 

From 523837c050eefe2f894e94738f971a0c0793f837 Mon Sep 17 00:00:00 2001
From: Stefan Dej <meteyou@gmail.com>
Date: Thu, 2 Mar 2023 22:56:57 +0100
Subject: [PATCH 3/3] fix: fix button in status panel toolbar

Signed-off-by: Stefan Dej <meteyou@gmail.com>
---
 src/components/panels/StatusPanel.vue | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue
index 3ce0ae7dd..f2198dfec 100644
--- a/src/components/panels/StatusPanel.vue
+++ b/src/components/panels/StatusPanel.vue
@@ -244,7 +244,7 @@ export default class StatusPanel extends Mixins(BaseMixin) {
 
                     return ['paused', 'printing'].includes(this.printer_state)
                 },
-                click: this.btnExcludeObject,
+                click: this.btnPauseAtLayer,
             },
             {
                 text: this.$t('Panels.StatusPanel.ClearPrintStats'),