Skip to content

Commit

Permalink
Added second layer confirmation for Cancel Job
Browse files Browse the repository at this point in the history
  • Loading branch information
FatalBulletHit committed Aug 16, 2024
1 parent 85d898a commit aeaa016
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/components/dialogs/CancelJobDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<v-dialog :value="showDialog" width="400" persistent>
<panel
:title="$t('CancelJobDialog.CancelJob')"
toolbar-color="error"
card-class="cancel-job-dialog"
:icon="mdiStop"
:margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="closePrompt">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>{{ $t('CancelJobDialog.AreYouSure') }}</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text @click="closePrompt">{{ $t('CancelJobDialog.No') }}</v-btn>
<v-btn color="primary" text @click="cancelJob">{{ $t('CancelJobDialog.Yes') }}</v-btn>
</v-card-actions>
</panel>
</v-dialog>
</template>

<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import Panel from '@/components/ui/Panel.vue'
import { mdiCloseThick, mdiStop } from '@mdi/js'
@Component({
components: { Panel },
})
export default class CancelJobDialog extends Mixins(BaseMixin) {
mdiCloseThick = mdiCloseThick
mdiStop = mdiStop
@Prop({ type: Boolean, default: false }) showDialog!: boolean
cancelJob(): void {
this.$socket.emit('printer.print.cancel', {}, { loading: 'statusPrintCancel' })
}
closePrompt() {
this.$emit('close')
}
}
</script>

<style scoped></style>
12 changes: 12 additions & 0 deletions src/components/panels/StatusPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
</v-tab-item>
</v-tabs-items>
</panel>
<cancel-job-dialog :show-dialog="showCancelJobDialog" @close="showCancelJobDialog = false" />
</div>
</template>

Expand Down Expand Up @@ -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' })
}
Expand Down
15 changes: 15 additions & 0 deletions src/components/settings/SettingsUiSettingsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@
<v-switch v-model="confirmOnPowerDeviceChange" hide-details class="mt-0" />
</settings-row>
<v-divider class="my-2" />
<settings-row
:title="$t('Settings.UiSettingsTab.ConfirmOnCancelJob')"
:sub-title="$t('Settings.UiSettingsTab.ConfirmOnCancelJobDescription')"
:dynamic-slot-width="true">
<v-switch v-model="confirmOnCancelJob" hide-details class="mt-0" />
</settings-row>
<v-divider class="my-2" />
<settings-row
:title="$t('Settings.UiSettingsTab.NavigationStyle')"
:sub-title="$t('Settings.UiSettingsTab.NavigationStyleDescription')">
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down Expand Up @@ -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",

Check failure on line 1211 in src/locales/de.json

View workflow job for this annotation

GitHub Actions / ESLint

src/locales/de.json#L1211

Expected object keys to be in insensitive ascending order. 'ConfirmOnCancelJob' should be before 'ConfirmOnPowerDeviceChangeDescription' (jsonc/sort-keys)
"ConfirmOnCancelJobDescription": "Zeige vor dem Druck abbrechen einen Bestätigungsdialog.",
"DefaultNavigationState": "Standard Navigationszustand",
"DefaultNavigationStateAlwaysClosed": "immer geschlossen",
"DefaultNavigationStateAlwaysOpen": "immer geöffnet",
Expand Down
8 changes: 8 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down Expand Up @@ -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",

Check failure on line 1211 in src/locales/en.json

View workflow job for this annotation

GitHub Actions / ESLint

src/locales/en.json#L1211

Expected object keys to be in insensitive ascending order. 'ConfirmOnCancelJob' should be before 'ConfirmOnPowerDeviceChangeDescription' (jsonc/sort-keys)
"ConfirmOnCancelJobDescription": "Show a confirmation dialog on Cancel Job",
"DefaultNavigationState": "Navigation default state",
"DefaultNavigationStateAlwaysClosed": "always closed",
"DefaultNavigationStateAlwaysOpen": "always open",
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const getDefaultState = (): GuiState => {
confirmOnEmergencyStop: false,
confirmOnCoolDown: false,
confirmOnPowerDeviceChange: false,
confirmOnCancelJob: false,
boolBigThumbnail: true,
bigThumbnailBackground: defaultBigThumbnailBackground,
boolWideNavDrawer: false,
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface GuiState {
confirmOnEmergencyStop: boolean
confirmOnCoolDown: boolean
confirmOnPowerDeviceChange: boolean
confirmOnCancelJob: boolean
boolBigThumbnail: boolean
bigThumbnailBackground: string
boolWideNavDrawer: boolean
Expand Down

0 comments on commit aeaa016

Please sign in to comment.