From aeaa016bde574b407fcb8fbd567e94d1479a5768 Mon Sep 17 00:00:00 2001 From: fatalbullethit Date: Fri, 16 Aug 2024 21:16:36 +0200 Subject: [PATCH] Added second layer confirmation for Cancel Job --- src/components/dialogs/CancelJobDialog.vue | 50 +++++++++++++++++++ src/components/panels/StatusPanel.vue | 12 +++++ .../settings/SettingsUiSettingsTab.vue | 15 ++++++ src/locales/de.json | 8 +++ src/locales/en.json | 8 +++ src/store/gui/index.ts | 1 + src/store/gui/types.ts | 1 + 7 files changed, 95 insertions(+) create mode 100644 src/components/dialogs/CancelJobDialog.vue diff --git a/src/components/dialogs/CancelJobDialog.vue b/src/components/dialogs/CancelJobDialog.vue new file mode 100644 index 000000000..3e2d493e8 --- /dev/null +++ b/src/components/dialogs/CancelJobDialog.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index ba405f501..49e4b0904 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -110,6 +110,7 @@ + @@ -392,6 +393,17 @@ export default class StatusPanel extends Mixins(BaseMixin) { } btnCancelJob() { + const confirmOnCancelJob = this.$store.state.gui.uiSettings.confirmOnCancelJob + if (confirmOnCancelJob) { + this.showCancelJobDialog = true + return + } + + this.cancelJob() + } + + cancelJob() { + this.showCancelJobDialog = false this.$socket.emit('printer.print.cancel', {}, { loading: 'statusPrintCancel' }) } diff --git a/src/components/settings/SettingsUiSettingsTab.vue b/src/components/settings/SettingsUiSettingsTab.vue index 0bc26e456..14bb0f33e 100644 --- a/src/components/settings/SettingsUiSettingsTab.vue +++ b/src/components/settings/SettingsUiSettingsTab.vue @@ -178,6 +178,13 @@ + + + + @@ -426,6 +433,14 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin, ThemeMixin) this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.confirmOnPowerDeviceChange', value: newVal }) } + get confirmOnCancelJob() { + return this.$store.state.gui.uiSettings.confirmOnCancelJob + } + + set confirmOnCancelJob(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.confirmOnCancelJob', value: newVal }) + } + get lockSliders() { return this.$store.state.gui.uiSettings.lockSlidersOnTouchDevices } diff --git a/src/locales/de.json b/src/locales/de.json index 6932890bb..2ce795304 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -144,6 +144,12 @@ "ScrewName": "Name der Schraube", "ScrewOutput": "{current} von {max}" }, + "CancelJobDialog": { + "AreYouSure": "Bist du sicher?", + "CancelJob": "Druck abbrechen", + "No": "Nein", + "Yes": "Ja" + }, "ConnectionDialog": { "CannotConnectTo": "Kann keine Verbindung zu Moonraker ({host}) herstellen.", "CheckMoonrakerLog": "Wenn diese Meldung wiederholt erscheint, schaue bitte in die Logdatei unter:", @@ -1202,6 +1208,8 @@ "ConfirmOnEmergencyStopDescription": "Zeige vor einem Notstop einen Bestätigungsdialog.", "ConfirmOnPowerDeviceChange": "Bestätigung für Änderung der Stromversorgung von Geräten", "ConfirmOnPowerDeviceChangeDescription": "Zeige vor Änderung der Stromversorgung von Geräten einen Bestätigungsdialog.", + "ConfirmOnCancelJob": "Bestätigung für Druck abbrechen erforderlich", + "ConfirmOnCancelJobDescription": "Zeige vor dem Druck abbrechen einen Bestätigungsdialog.", "DefaultNavigationState": "Standard Navigationszustand", "DefaultNavigationStateAlwaysClosed": "immer geschlossen", "DefaultNavigationStateAlwaysOpen": "immer geöffnet", diff --git a/src/locales/en.json b/src/locales/en.json index 5c403574b..e7785129d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -144,6 +144,12 @@ "ScrewName": "Screw Name", "ScrewOutput": "{current} of {max}" }, + "CancelJobDialog": { + "AreYouSure": "Are you sure?", + "CancelJob": "Cancel Job", + "No": "No", + "Yes": "Yes" + }, "ConnectionDialog": { "CannotConnectTo": "Cannot connect to Moonraker ({host}).", "CheckMoonrakerLog": "If this message appears repeatedly, please have a look in the log file located at:", @@ -1202,6 +1208,8 @@ "ConfirmOnEmergencyStopDescription": "Show a confirmation dialog on Emergency Stop", "ConfirmOnPowerDeviceChange": "Require confirm on Device Power changes", "ConfirmOnPowerDeviceChangeDescription": "Show a confirmation dialog on Device Power changes", + "ConfirmOnCancelJob": "Require confirm on Cancel Job", + "ConfirmOnCancelJobDescription": "Show a confirmation dialog on Cancel Job", "DefaultNavigationState": "Navigation default state", "DefaultNavigationStateAlwaysClosed": "always closed", "DefaultNavigationStateAlwaysOpen": "always open", diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 6f94a5344..b8aaa2903 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -166,6 +166,7 @@ export const getDefaultState = (): GuiState => { confirmOnEmergencyStop: false, confirmOnCoolDown: false, confirmOnPowerDeviceChange: false, + confirmOnCancelJob: false, boolBigThumbnail: true, bigThumbnailBackground: defaultBigThumbnailBackground, boolWideNavDrawer: false, diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index a1bef68e2..fb3589081 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -108,6 +108,7 @@ export interface GuiState { confirmOnEmergencyStop: boolean confirmOnCoolDown: boolean confirmOnPowerDeviceChange: boolean + confirmOnCancelJob: boolean boolBigThumbnail: boolean bigThumbnailBackground: string boolWideNavDrawer: boolean