Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add confirmation dialog to cooldown button #1808

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/components/dialogs/CoolDownDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<v-dialog :value="showDialog" width="400" persistent>
<panel
:title="$t('CoolDownDialog.CoolDown')"
card-class="cool-down-dialog"
:icon="mdiSnowflake"
:margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="closePrompt">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>{{ $t('CoolDownDialog.AreYouSure') }}</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text @click="closePrompt">{{ $t('CoolDownDialog.No') }}</v-btn>
<v-btn color="primary" text @click="cooldown">{{ $t('CoolDownDialog.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, mdiSnowflake } from '@mdi/js'

@Component({
components: { Panel },
})
export default class CoolDownDialog extends Mixins(BaseMixin) {
mdiCloseThick = mdiCloseThick
mdiSnowflake = mdiSnowflake

@Prop({ type: Boolean, default: false }) showDialog!: boolean

get cooldownGcode(): string {
return this.$store.getters['gui/presets/getCooldownGcode']
}

cooldown(): void {
this.$store.dispatch('server/addEvent', { message: this.cooldownGcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: this.cooldownGcode })

this.closePrompt()
}

closePrompt() {
this.$emit('close')
}
}
</script>

<style scoped></style>
29 changes: 25 additions & 4 deletions src/components/panels/Temperature/TemperaturePanelPresets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</v-list>
<v-divider class="_fix_transparency" />
<v-list dense class="py-0">
<v-list-item link @click="cooldown">
<v-list-item link @click="btnCoolDown">
<div class="d-flex align-center _preset-title">
<v-icon small color="primary" class="mr-1">{{ mdiSnowflake }}</v-icon>
<span class="primary--text">{{ $t('Panels.TemperaturePanel.Cooldown') }}</span>
Expand All @@ -39,10 +39,11 @@
:text="$vuetify.breakpoint.mdAndUp"
tile
color="primary"
@click="cooldown">
@click="btnCoolDown">
<v-icon small>{{ mdiSnowflake }}</v-icon>
<span class="d-none ml-1 d-md-inline">{{ $t('Panels.TemperaturePanel.Cooldown') }}</span>
</v-btn>
<cool-down-dialog :show-dialog="showCoolDownDialog" @close="showCoolDownDialog = false" />
</div>
</template>

Expand All @@ -51,13 +52,19 @@ import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { GuiPresetsStatePreset } from '@/store/gui/presets/types'
import { mdiFire, mdiMenuDown, mdiSnowflake } from '@mdi/js'
import { mdiFire, mdiMenuDown, mdiSnowflake, mdiCloseThick } from '@mdi/js'
import CoolDownDialog from '@/components/dialogs/CoolDownDialog.vue'

@Component
@Component({
components: { CoolDownDialog },
})
export default class TemperaturePanelPresets extends Mixins(BaseMixin) {
mdiFire = mdiFire
mdiMenuDown = mdiMenuDown
mdiSnowflake = mdiSnowflake
mdiCloseThick = mdiCloseThick

showCoolDownDialog = false

get presets(): GuiPresetsStatePreset[] {
return this.$store.getters['gui/presets/getPresets'] ?? []
Expand All @@ -67,6 +74,10 @@ export default class TemperaturePanelPresets extends Mixins(BaseMixin) {
return this.$store.getters['gui/presets/getCooldownGcode']
}

get confirmOnCoolDown(): boolean {
return this.$store.state.gui.uiSettings.confirmOnCoolDown
}

preheat(preset: GuiPresetsStatePreset): void {
for (const [name, attributes] of Object.entries(preset.values)) {
if (attributes.bool) {
Expand Down Expand Up @@ -100,7 +111,17 @@ export default class TemperaturePanelPresets extends Mixins(BaseMixin) {
}
}

btnCoolDown(): void {
if (this.confirmOnCoolDown) {
this.showCoolDownDialog = true
return
}

this.cooldown()
}

cooldown(): void {
this.showCoolDownDialog = false
this.$store.dispatch('server/addEvent', { message: this.cooldownGcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: this.cooldownGcode })
}
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 @@ -142,6 +142,13 @@
<v-switch v-model="confirmOnEmergencyStop" hide-details class="mt-0" />
</settings-row>
<v-divider class="my-2" />
<settings-row
:title="$t('Settings.UiSettingsTab.ConfirmOnCoolDown')"
:sub-title="$t('Settings.UiSettingsTab.ConfirmOnCoolDownDescription')"
:dynamic-slot-width="true">
<v-switch v-model="confirmOnCoolDown" hide-details class="mt-0" />
</settings-row>
<v-divider class="my-2" />
<settings-row
:title="$t('Settings.UiSettingsTab.ConfirmOnPowerDeviceChange')"
:sub-title="$t('Settings.UiSettingsTab.ConfirmOnPowerDeviceChangeDescription')"
Expand Down Expand Up @@ -341,6 +348,14 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin) {
this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.confirmOnEmergencyStop', value: newVal })
}

get confirmOnCoolDown() {
return this.$store.state.gui.uiSettings.confirmOnCoolDown
}

set confirmOnCoolDown(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.confirmOnCoolDown', value: newVal })
}

get confirmOnPowerDeviceChange() {
return this.$store.state.gui.uiSettings.confirmOnPowerDeviceChange
}
Expand Down
8 changes: 8 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@
"SendCode": "Send code...",
"SetupConsole": "Setup Console"
},
"CoolDownDialog": {
"AreYouSure": "Are you sure?",
"CoolDown": "CoolDown",
"No": "No",
"Yes": "Yes"
},
"DevicesDialog": {
"CanBusInfo": "Only unassigned nodes can be detected. It’s recommended to have only one unassigned device connected to the can bus to avoid communication issues. For more details, please click on the link:",
"ClickRefresh": "Click on the refresh button to search for devices.",
Expand Down Expand Up @@ -1142,6 +1148,8 @@
"BoolBigThumbnailDescription": "Display a large thumbnail in the status panel during a print.",
"BoolHideUploadAndPrintButton": "Hide Upload and Print Button",
"BoolHideUploadAndPrintButtonDescription": "Show or hide the \"Upload and Print\" button in the top bar.",
"ConfirmOnCoolDown": "Require confirm on CoolDown",
"ConfirmOnCoolDownDescription": "Show a confirmation dialog on CoolDown",
"ConfirmOnEmergencyStop": "Require confirm on Emergency Stop",
"ConfirmOnEmergencyStopDescription": "Show a confirmation dialog on Emergency Stop",
"ConfirmOnPowerDeviceChange": "Require confirm on Device Power changes",
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 @@ -156,6 +156,7 @@ export const getDefaultState = (): GuiState => {
lockSlidersOnTouchDevices: true,
lockSlidersDelay: 1.5,
confirmOnEmergencyStop: false,
confirmOnCoolDown: false,
confirmOnPowerDeviceChange: false,
boolBigThumbnail: true,
bigThumbnailBackground: defaultBigThumbnailBackground,
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 @@ -105,6 +105,7 @@ export interface GuiState {
lockSlidersOnTouchDevices: boolean
lockSlidersDelay: number
confirmOnEmergencyStop: boolean
confirmOnCoolDown: boolean
confirmOnPowerDeviceChange: boolean
boolBigThumbnail: boolean
bigThumbnailBackground: string
Expand Down
Loading