From 5cb308064c53ddc5a19108b65182fc14f15d6e54 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 4 Sep 2024 23:07:43 +0200 Subject: [PATCH 1/7] refactor(ExtruderPanel): add `_` prefix to gcode_state name (#1989) --- .../Extruder/ExtruderControlPanelControl.vue | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/components/panels/Extruder/ExtruderControlPanelControl.vue b/src/components/panels/Extruder/ExtruderControlPanelControl.vue index 25d1d053b..b430f68ab 100644 --- a/src/components/panels/Extruder/ExtruderControlPanelControl.vue +++ b/src/components/panels/Extruder/ExtruderControlPanelControl.vue @@ -93,7 +93,7 @@ @@ -141,9 +145,11 @@ import { mdiDotsVertical, } from '@mdi/js' import { PrinterStateMacro } from '@/store/printer/types' +import CancelJobDialog from '@/components/dialogs/CancelJobDialog.vue' @Component({ components: { + CancelJobDialog, KlippyStatePanel, MinSettingsPanel, Panel, @@ -166,6 +172,7 @@ export default class StatusPanel extends Mixins(BaseMixin) { bigThumbnail: any } + showCancelJobDialog = false boolShowObjects = false boolShowPauseAtLayer = false @@ -392,6 +399,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 67220131d..bc4ac382c 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:", @@ -1196,6 +1202,8 @@ "BoolBigThumbnailDescription": "Zeige ein großes Thumbnail in der Status-Anzeige während eines Drucks.", "BoolHideUploadAndPrintButton": "\"Hochladen & Drucken\" Schaltfläche ausblenden", "BoolHideUploadAndPrintButtonDescription": "Blendet die \"Hochladen & Drucken\" Schaltfläche in der Kopfleiste ein oder aus.", + "ConfirmOnCancelJob": "Bestätigung für Druck abbrechen erforderlich", + "ConfirmOnCancelJobDescription": "Zeige vor dem Druck abbrechen einen Bestätigungsdialog.", "ConfirmOnCoolDown": "Bestätigung für Abkühlen erforderlich", "ConfirmOnCoolDownDescription": "Zeige vor dem Abkühlen einen Bestätigungsdialog.", "ConfirmOnEmergencyStop": "Bestätigung für Notstopp erforderlich", diff --git a/src/locales/en.json b/src/locales/en.json index 2f0c91bf3..002e964e7 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:", @@ -1197,6 +1203,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.", + "ConfirmOnCancelJob": "Require confirm on Cancel Job", + "ConfirmOnCancelJobDescription": "Show a confirmation dialog on Cancel Job", "ConfirmOnCoolDown": "Require confirm on CoolDown", "ConfirmOnCoolDownDescription": "Show a confirmation dialog on CoolDown", "ConfirmOnEmergencyStop": "Require confirm on Emergency Stop", 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 From 695832a6d013e1988b63e9f7cc649a84dfe8c51c Mon Sep 17 00:00:00 2001 From: CF3B5 Date: Sun, 8 Sep 2024 06:23:19 +0800 Subject: [PATCH 3/7] feat: adds a file structure sidebar in the editor (#1943) Co-authored-by: Stefan Dej --- src/components/TheEditor.vue | 141 +++++++++++++++++++++++++-- src/components/inputs/Codemirror.vue | 26 +++-- src/locales/en.json | 1 + src/locales/zh.json | 1 + src/store/files/types.ts | 10 ++ 5 files changed, 164 insertions(+), 15 deletions(-) diff --git a/src/components/TheEditor.vue b/src/components/TheEditor.vue index e740c7db8..215ed1ccd 100644 --- a/src/components/TheEditor.vue +++ b/src/components/TheEditor.vue @@ -31,6 +31,10 @@ {{ mdiHelp }} {{ $t('Editor.ConfigReference') }} + + {{ mdiFormatListCheckbox }} + {{ $t('Editor.FileStructure') }} + {{ mdiCloseThick }} - + + :file-extension="fileExtension" + class="codemirror" + @lineChange="lineChanges" /> +
+ + + + +
- +
{{ snackbarHeadline }}
@@ -123,7 +160,7 @@ diff --git a/src/locales/en.json b/src/locales/en.json index 002e964e7..b12da347f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -203,6 +203,7 @@ "Downloading": "Downloading", "FailedSave": "{filename} could not be uploaded!", "FileReadOnly": "read-only", + "FileStructure": "File Structure", "SaveClose": "Save & close", "SaveRestart": "Save & Restart", "SuccessfullySaved": "{filename} successfully saved.", diff --git a/src/locales/zh.json b/src/locales/zh.json index 884c60b6d..9b522bb45 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -197,6 +197,7 @@ "Downloading": "正在下载", "FailedSave": "上传{filename}失败!", "FileReadOnly": "只读文件", + "FileStructure": "结构", "SaveClose": "保存并关闭", "SaveRestart": "保存并重启", "SuccessfullySaved": "{filename}保存成功!", diff --git a/src/store/files/types.ts b/src/store/files/types.ts index 55197c159..e862daf16 100644 --- a/src/store/files/types.ts +++ b/src/store/files/types.ts @@ -97,3 +97,13 @@ export interface ApiGetDirectoryReturnFile { filename: string permissions: string } + +export interface ConfigFileKey { + name: string + type: string + line: number +} + +export interface ConfigFileSection extends ConfigFileKey { + children: ConfigFileKey[] +} From c2226dcc03009b42eeadc6a782b9b4551a8a8ab3 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 8 Sep 2024 00:28:16 +0200 Subject: [PATCH 4/7] feat: add output on connection dialog for unauthorized (#1996) --- src/components/TheConnectingDialog.vue | 39 +++++++++++--------------- src/locales/en.json | 1 + src/plugins/webSocketClient.ts | 5 ++++ src/store/socket/actions.ts | 4 +++ src/store/socket/index.ts | 1 + src/store/socket/mutations.ts | 4 ++- src/store/socket/types.ts | 1 + 7 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/components/TheConnectingDialog.vue b/src/components/TheConnectingDialog.vue index d32bdd7c9..68bff8c66 100644 --- a/src/components/TheConnectingDialog.vue +++ b/src/components/TheConnectingDialog.vue @@ -1,35 +1,30 @@ - - @@ -52,10 +47,6 @@ export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) { counter = 0 - get protocol() { - return this.$store.state.socket.protocol - } - get hostname() { return this.$store.state.socket.hostname } @@ -94,6 +85,10 @@ export default class TheConnectingDialog extends Mixins(BaseMixin, ThemeMixin) { return this.formatHostname } + get connectionFailedMessage() { + return this.$store.state.socket.connectionFailedMessage ?? null + } + reconnect() { this.counter++ this.$store.dispatch('socket/setData', { connectingFailed: false }) diff --git a/src/locales/en.json b/src/locales/en.json index b12da347f..9cafae33c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -154,6 +154,7 @@ "CannotConnectTo": "Cannot connect to Moonraker ({host}).", "CheckMoonrakerLog": "If this message appears repeatedly, please have a look in the log file located at:", "Connecting": "Connecting to {host}", + "ErrorMessage": "Error message: {message}", "Failed": "Connection failed", "Initializing": "Initializing", "TryAgain": "try again" diff --git a/src/plugins/webSocketClient.ts b/src/plugins/webSocketClient.ts index 1208bb7cb..6e4820240 100644 --- a/src/plugins/webSocketClient.ts +++ b/src/plugins/webSocketClient.ts @@ -36,6 +36,11 @@ export class WebSocketClient { window.console.error(`Response Error: ${data.error.message} (${wait?.action ?? 'no action'})`) } + if (data.error.message === 'Unauthorized' && wait?.action === 'server/setConnectionId') { + this.close() + this.store?.dispatch('socket/setConnectionFailed', data.error.message) + } + if (wait?.id) { const modulename = wait.action?.split('/')[1] ?? null diff --git a/src/store/socket/actions.ts b/src/store/socket/actions.ts index 0a207d48b..24263cd2d 100644 --- a/src/store/socket/actions.ts +++ b/src/store/socket/actions.ts @@ -173,4 +173,8 @@ export const actions: ActionTree = { reportDebug(_, payload) { window.console.log(payload) }, + + setConnectionFailed({ commit }, payload) { + commit('setDisconnected', payload) + }, } diff --git a/src/store/socket/index.ts b/src/store/socket/index.ts index c50c7bc7a..f9f1a8681 100644 --- a/src/store/socket/index.ts +++ b/src/store/socket/index.ts @@ -20,6 +20,7 @@ export const getDefaultState = (): SocketState => { isConnected: false, isConnecting: false, connectingFailed: false, + connectionFailedMessage: null, loadings: [], initializationList: ['server'], connection_id: null, diff --git a/src/store/socket/mutations.ts b/src/store/socket/mutations.ts index 9399eb169..96ed25d60 100644 --- a/src/store/socket/mutations.ts +++ b/src/store/socket/mutations.ts @@ -16,11 +16,13 @@ export const mutations: MutationTree = { Vue.set(state, 'connectingFailed', false) }, - setDisconnected(state) { + setDisconnected(state, message?: string) { Vue.set(state, 'isConnected', false) Vue.set(state, 'isConnecting', false) Vue.set(state, 'connectingFailed', true) Vue.set(state, 'connection_id', null) + + if (message) Vue.set(state, 'connectionFailedMessage', message) }, setData(state, payload) { diff --git a/src/store/socket/types.ts b/src/store/socket/types.ts index c2675e784..9c8d0c1ee 100644 --- a/src/store/socket/types.ts +++ b/src/store/socket/types.ts @@ -7,6 +7,7 @@ export interface SocketState { isConnected: boolean isConnecting: boolean connectingFailed: boolean + connectionFailedMessage: string | null loadings: string[] initializationList: string[] connection_id: number | null From d4357c88e721af09349311c3d89a02d4261eba47 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 8 Sep 2024 00:28:29 +0200 Subject: [PATCH 5/7] refactor(webcam): refactor Mjpegstreamer-Adaptive Webcam mode (#1994) --- .../streamers/MjpegstreamerAdaptive.vue | 271 ++++++++++-------- src/locales/en.json | 2 + 2 files changed, 148 insertions(+), 125 deletions(-) diff --git a/src/components/webcams/streamers/MjpegstreamerAdaptive.vue b/src/components/webcams/streamers/MjpegstreamerAdaptive.vue index 39f04cc30..cac1ee5f8 100644 --- a/src/components/webcams/streamers/MjpegstreamerAdaptive.vue +++ b/src/components/webcams/streamers/MjpegstreamerAdaptive.vue @@ -1,55 +1,58 @@ diff --git a/src/locales/en.json b/src/locales/en.json index c45e91e90..e13f50b3a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -822,6 +822,7 @@ "WebcamPanel": { "All": "All", "ConnectingTo": "Connecting to {url}", + "Disconnected": "Disconnected", "ErrorWhileConnecting": "Error while connecting to {url}", "FPS": "FPS", "Headline": "Webcam",