diff --git a/src/components/panels/Temperature/TemperaturePanelListItem.vue b/src/components/panels/Temperature/TemperaturePanelListItem.vue index 311e7b140..8ba995c6c 100644 --- a/src/components/panels/Temperature/TemperaturePanelListItem.vue +++ b/src/components/panels/Temperature/TemperaturePanelListItem.vue @@ -1,12 +1,12 @@ @@ -66,6 +78,7 @@ import { Mixins, Prop } from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' import { convertName } from '@/plugins/helpers' import { + mdiCog, mdiFan, mdiFire, mdiMemory, @@ -73,16 +86,24 @@ import { mdiPrinter3dNozzleAlert, mdiRadiator, mdiRadiatorDisabled, + mdiSnowflake, mdiThermometer, } from '@mdi/js' import { additionalSensors, opacityHeaterActive, opacityHeaterInactive } from '@/store/variables' +import { EventBus } from '@/plugins/eventBus' @Component export default class TemperaturePanelListItem extends Mixins(BaseMixin) { + mdiCog = mdiCog + mdiSnowflake = mdiSnowflake + @Prop({ type: String, required: true }) readonly objectName!: string @Prop({ type: Boolean, required: true }) readonly isResponsiveMobile!: boolean showEditDialog = false + showContextMenu = false + contextMenuX = 0 + contextMenuY = 0 get printerObject() { if (!(this.objectName in this.$store.state.printer)) return {} @@ -270,6 +291,49 @@ export default class TemperaturePanelListItem extends Mixins(BaseMixin) { return '' } + + get availableHeaters() { + return this.$store.state.printer.heaters?.available_heaters ?? [] + } + + get isHeater() { + return this.availableHeaters.includes(this.objectName) + } + + get isHeaterActive() { + return this.target > 0 + } + + mounted() { + EventBus.$on('close-temperature-context-menu', this.closeContextMenu) + } + + beforeDestroy() { + EventBus.$off('close-temperature-context-menu', this.closeContextMenu) + } + + openContentMenu(event: MouseEvent) { + EventBus.$emit('close-temperature-context-menu') + + this.showContextMenu = true + this.contextMenuX = event?.clientX || event?.pageX || window.screenX / 2 + this.contextMenuY = event?.clientY || event?.pageY || window.screenY / 2 + } + + closeContextMenu() { + this.showContextMenu = false + } + + openEditDialog() { + this.closeContextMenu() + this.showEditDialog = true + } + + turnOffHeater() { + const gcode = `SET_HEATER_TEMPERATURE HEATER=${this.name} TARGET=0` + this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' }) + this.$socket.emit('printer.gcode.script', { script: gcode }) + } } diff --git a/src/locales/en.json b/src/locales/en.json index c897531ac..79016a546 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -799,6 +799,7 @@ "Min": "min", "Name": "Name", "Presets": "Presets", + "Settings": "Settings", "SetupTemperatures": "Setup Temperatures", "ShowChart": "Show Chart", "ShowNameInChart": "Show {name} in chart", @@ -807,7 +808,8 @@ "Target": "Target", "TemperaturesInChart": "Temperature [°C]", "TempTooHigh": "Temperature too high for {name}! (max: {max})", - "TempTooLow": "Temperature too low for {name}! (min: {min})" + "TempTooLow": "Temperature too low for {name}! (min: {min})", + "TurnHeaterOff": "Turn Heater Off" }, "ToolheadControlPanel": { "Absolute": "absolute", diff --git a/src/plugins/eventBus.ts b/src/plugins/eventBus.ts new file mode 100644 index 000000000..d64d4799e --- /dev/null +++ b/src/plugins/eventBus.ts @@ -0,0 +1,2 @@ +import Vue from 'vue' +export const EventBus = new Vue()