diff --git a/src/components/settings/SettingsEditorTab.vue b/src/components/settings/SettingsEditorTab.vue
index 3646ea42..9bc074ec 100644
--- a/src/components/settings/SettingsEditorTab.vue
+++ b/src/components/settings/SettingsEditorTab.vue
@@ -16,6 +16,32 @@
+
+
+
+
+
+
+
+
+
+
@@ -30,6 +56,17 @@ import SettingsRow from '@/components/settings/SettingsRow.vue'
components: { SettingsRow },
})
export default class SettingsEditorTab extends Mixins(BaseMixin) {
+ private klipperRestartMethods = [
+ {
+ text: 'FIRMWARE_RESTART',
+ value: 'FIRMWARE_RESTART',
+ },
+ {
+ text: 'RESTART',
+ value: 'RESTART',
+ },
+ ]
+
get escToClose() {
return this.$store.state.gui.editor.escToClose
}
@@ -45,5 +82,27 @@ export default class SettingsEditorTab extends Mixins(BaseMixin) {
set confirmUnsavedChanges(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'editor.confirmUnsavedChanges', value: newVal })
}
+
+ get klipperRestartMethod() {
+ return this.$store.state.gui.editor.klipperRestartMethod
+ }
+
+ set klipperRestartMethod(newVal) {
+ this.$store.dispatch('gui/saveSetting', { name: 'editor.klipperRestartMethod', value: newVal })
+ }
+
+ get moonrakerRestartInstance() {
+ return this.$store.state.gui.editor.moonrakerRestartInstance
+ }
+
+ set moonrakerRestartInstance(newVal) {
+ this.$store.dispatch('gui/saveSetting', { name: 'editor.moonrakerRestartInstance', value: newVal })
+ }
+
+ get availableMoonrakerInstances() {
+ const available_instances = this.$store.state.server.system_info?.available_services ?? []
+
+ return available_instances.filter((name: string) => name.startsWith('moonraker')).sort()
+ }
}
diff --git a/src/locales/de.json b/src/locales/de.json
index c19f8d12..70c0df0c 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -149,7 +149,11 @@
"UnsavedChangesSubMessage": "Deine Änderungen werden verloren gehen wenn du sie nicht speicherst. Du kannst diese Meldung in den Editor-Einstellungen deaktivieren.",
"DontSave": "Nicht speichern",
"Cancel": "Abbrechen",
- "FileReadOnly": "schreibgeschützt"
+ "FileReadOnly": "schreibgeschützt",
+ "KlipperRestartMethod": "Klipper Neustartmethode",
+ "KlipperRestartMethodDescription": "Wählen der Neustartmethode die bei 'Speichern & Neustarten' verwendet wird, wenn Klipper-Konfigurationsdateien bearbeitet werden.",
+ "MoonrakerRestartInstance": "Moonraker Neustartinstanz",
+ "MoonrakerRestartInstanceDescription": "Wählen der Moonraker-Instanz die bei 'Speichern & Neustarten' neu gestartet wird, wenn Moonraker-Konfigurationsdateien bearbeitet werden."
},
"Files": {
"GCodeFiles": "G-Code Dateien",
diff --git a/src/locales/en.json b/src/locales/en.json
index b512a1d8..8913398b 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -917,7 +917,11 @@
"UseEscToClose": "Use ESC to close editor",
"UseEscToCloseDescription": "Allows the ESC key to close the editor",
"ConfirmUnsavedChanges": "Prompt to save or discard unsaved changes",
- "ConfirmUnsavedChangesDescription": "If enabled, the editor requires a confirmation to either save or discard the changes made. If disabled, changes are silently discarded."
+ "ConfirmUnsavedChangesDescription": "If enabled, the editor requires a confirmation to either save or discard the changes made. If disabled, changes are silently discarded.",
+ "KlipperRestartMethod": "Klipper restart method",
+ "KlipperRestartMethodDescription": "Select which restart method will be used on 'Save & Restart' when editing Klipper config files.",
+ "MoonrakerRestartInstance": "Moonraker restart instance",
+ "MoonrakerRestartInstanceDescription": "Select which Moonraker service will restart on 'Save & Restart' when editing Moonraker config files."
}
},
"GCodeViewer": {
diff --git a/src/store/editor/actions.ts b/src/store/editor/actions.ts
index 4f40ed20..ed923413 100644
--- a/src/store/editor/actions.ts
+++ b/src/store/editor/actions.ts
@@ -77,7 +77,7 @@ export const actions: ActionTree = {
},
async saveFile(
- { state, commit, rootGetters, dispatch },
+ { state, commit, getters, rootGetters, dispatch },
payload: { content: string; restartServiceName: string | null }
) {
const content = new Blob([payload.content], { type: 'text/plain' })
@@ -133,8 +133,12 @@ export const actions: ActionTree = {
dispatch('clearLoader')
Vue.$toast.success(i18n.t('Editor.SuccessfullySaved', { filename: data.item.path }).toString())
if (payload.restartServiceName === 'klipper') {
+ const klipperRestartMethod = getters['getKlipperRestartMethod']
//dispatch('server/addEvent', { message: 'FIRMWARE_RESTART', type: 'command' })
- Vue.$socket.emit('printer.gcode.script', { script: 'FIRMWARE_RESTART' })
+ Vue.$socket.emit('printer.gcode.script', { script: klipperRestartMethod })
+ } else if (payload.restartServiceName === 'moonraker') {
+ const moonrakerRestartInstance = getters['getMoonrakerRestartInstance']
+ Vue.$socket.emit('machine.services.restart', { service: moonrakerRestartInstance })
} else if (payload.restartServiceName !== null) {
Vue.$socket.emit('machine.services.restart', { service: payload.restartServiceName })
}
diff --git a/src/store/editor/getters.ts b/src/store/editor/getters.ts
index fb020f6b..0e0da0cf 100644
--- a/src/store/editor/getters.ts
+++ b/src/store/editor/getters.ts
@@ -1,4 +1,17 @@
import { GetterTree } from 'vuex'
import { EditorState } from '@/store/editor/types'
-export const getters: GetterTree = {}
+export const getters: GetterTree = {
+ getKlipperRestartMethod: (state, getters, rootState) => {
+ return rootState.gui.editor?.klipperRestartMethod ?? 'FIRMWARE_RESTART'
+ },
+
+ getMoonrakerRestartInstance: (state, getters, rootState) => {
+ const available_services = rootState.server?.system_info?.available_services ?? []
+ const setting = rootState.gui.editor?.moonrakerRestartInstance ?? 'moonraker'
+
+ if (available_services.includes(setting)) return setting
+
+ return 'moonraker'
+ },
+}
diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts
index 333cbb16..1d6333f2 100644
--- a/src/store/gui/index.ts
+++ b/src/store/gui/index.ts
@@ -104,6 +104,8 @@ export const getDefaultState = (): GuiState => {
editor: {
escToClose: true,
confirmUnsavedChanges: true,
+ klipperRestartMethod: 'FIRMWARE_RESTART',
+ moonrakerRestartInstance: null,
},
gcodeViewer: {
extruderColors: ['#E76F51FF', '#F4A261FF', '#E9C46AFF', '#2A9D8FFF', '#264653FF'],
diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts
index 8fbcfaee..e43c627c 100644
--- a/src/store/gui/types.ts
+++ b/src/store/gui/types.ts
@@ -48,6 +48,8 @@ export interface GuiState {
editor: {
escToClose: boolean
confirmUnsavedChanges: boolean
+ klipperRestartMethod: 'FIRMWARE_RESTART' | 'RESTART'
+ moonrakerRestartInstance: string | null
}
gcodeViewer: {
extruderColors: string[]