diff --git a/src/locales/de.json b/src/locales/de.json index e8b227864e..10ab43ba86 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -17,7 +17,9 @@ }, "MoonrakerWarnings": { "MoonrakerComponent": "Moonraker: {component}", - "MoonrakerFailedComponentDescription": "Beim Laden der Moonraker-Komponenten wurde ein Fehler festgestellt. Bitte prüfe die Logdatei und behebe das Problem.", + "MoonrakerFailedComponentDescription": "Beim Laden der Moonraker-Komponente '{component}' wurde ein Fehler festgestellt. Bitte prüfe die Logdatei und behebe das Problem.", + "MoonrakerFailedInitComponentDescription": "Beim Initialisieren der Moonraker-Komponente '{component}' wurde ein Fehler festgestellt. Bitte prüfe die Logdatei und behebe das Problem.", + "MoonrakerInitComponent": "Init. Moonraker: {component}", "MoonrakerWarning": "Moonraker Warnung", "UnparsedConfigOption": "Nicht erkannte Config-Option '{option}: {value}' in Abschnitt [{section}] entdeckt. Dies kann eine Option sein, die nicht mehr verfügbar ist, oder das Ergebnis eines Moduls sein, das nicht geladen werden konnte. In Zukunft wird dies zu einem Startfehler führen.", "UnparsedConfigSection": "Nicht erkannter Config-Abschnitt [{section}] gefunden. Dies kann das Ergebnis einer Komponente sein, die nicht geladen werden konnte. In Zukunft wird dies zu einem Startfehler führen." diff --git a/src/locales/en.json b/src/locales/en.json index c0f99508fc..6624ccb3cd 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -18,6 +18,8 @@ "MoonrakerWarnings": { "MoonrakerComponent": "Moonraker: {component}", "MoonrakerFailedComponentDescription": "An error was detected while loading the moonraker component '{component}'. Please check the log file and fix the issue.", + "MoonrakerFailedInitComponentDescription": "An error was detected during initialization the moonraker component '{component}'. Please check the log file and fix the issue.", + "MoonrakerInitComponent": "Init. Moonraker: {component}", "MoonrakerWarning": "Moonraker warning", "UnparsedConfigOption": "Unparsed config option '{option}: {value}' detected in section [{section}]. This may be an option no longer available or could be the result of a module that failed to load. In the future this will result in a startup error.", "UnparsedConfigSection": "Unparsed config section [{section}] detected. This may be the result of a component that failed to load. In the future this will result in a startup error." diff --git a/src/plugins/webSocketClient.ts b/src/plugins/webSocketClient.ts index b79d5cc35d..ec5a34f849 100644 --- a/src/plugins/webSocketClient.ts +++ b/src/plugins/webSocketClient.ts @@ -61,10 +61,21 @@ export class WebSocketClient { // report error messages if (data.error?.message) { - if (data.error?.message !== 'Klippy Disconnected') + // only report errors, if not disconnected and no init component + if (data.error?.message !== 'Klippy Disconnected' && !wait?.action?.startsWith('server/')) { window.console.error(`Response Error: ${data.error.message} (${wait?.action ?? 'no action'})`) - - if (wait?.id) this.removeWaitById(wait.id) + } + + if (wait?.id) { + if (wait.action?.startsWith('server/')) { + const component = wait.action.replace('server/', '').split('/')[0] + window.console.error(`init server component ${component} failed`) + this.store?.dispatch('server/addFailedInitComponent', component) + this.store?.dispatch('socket/removeInitComponent', `server/${component}/`) + } + + this.removeWaitById(wait.id) + } return } diff --git a/src/store/gui/notifications/getters.ts b/src/store/gui/notifications/getters.ts index a4072f1869..2384c1d906 100644 --- a/src/store/gui/notifications/getters.ts +++ b/src/store/gui/notifications/getters.ts @@ -28,6 +28,9 @@ export const getters: GetterTree = { // moonraker failed components notifications = notifications.concat(getters['getNotificationsMoonrakerFailedComponents']) + // moonraker failed init components + notifications = notifications.concat(getters['getNotificationsMoonrakerFailedInitComponents']) + // klipper warnings notifications = notifications.concat(getters['getNotificationsKlipperWarnings']) @@ -224,6 +227,44 @@ export const getters: GetterTree = { return notifications }, + getNotificationsMoonrakerFailedInitComponents: (state, getters, rootState, rootGetters) => { + const notifications: GuiNotificationStateEntry[] = [] + + let failedInitCompontents = rootState.server.failed_init_components ?? [] + if (failedInitCompontents.length) { + const date = rootState.server.system_boot_at ?? new Date() + + // get all dismissed failed components and convert it to a string[] + const flagDismisses = rootGetters['gui/notifications/getDismissByCategory']( + 'moonrakerFailedInitComponent' + ).map((dismiss: GuiNotificationStateDismissEntry) => { + return dismiss.id + }) + + // filter all dismissed failed init components + failedInitCompontents = failedInitCompontents.filter( + (component: string) => !flagDismisses.includes(component) + ) + + failedInitCompontents.forEach((component: string) => { + notifications.push({ + id: `moonrakerFailedInitComponent/${component}`, + priority: 'high', + title: i18n + .t('App.Notifications.MoonrakerWarnings.MoonrakerInitComponent', { component }) + .toString(), + description: i18n + .t('App.Notifications.MoonrakerWarnings.MoonrakerFailedInitComponentDescription', { component }) + .toString(), + date, + dismissed: false, + } as GuiNotificationStateEntry) + }) + } + + return notifications + }, + getNotificationsKlipperWarnings: (state, getters, rootState, rootGetters) => { const notifications: GuiNotificationStateEntry[] = [] diff --git a/src/store/server/actions.ts b/src/store/server/actions.ts index b5a9157356..93aeb4ce39 100644 --- a/src/store/server/actions.ts +++ b/src/store/server/actions.ts @@ -292,4 +292,9 @@ export const actions: ActionTree = { serviceStateChanged({ commit }, payload) { commit('updateServiceState', payload) }, + + addFailedInitComponent({ commit }, payload) { + commit('removeComponent', payload) + commit('addFailedInitComponent', payload) + }, } diff --git a/src/store/server/index.ts b/src/store/server/index.ts index 643e9ce4c2..1fde111a34 100644 --- a/src/store/server/index.ts +++ b/src/store/server/index.ts @@ -23,6 +23,7 @@ export const getDefaultState = (): ServerState => { klippy_message: '', components: [], failed_components: [], + failed_init_components: [], warnings: [], registered_directories: [], events: [], diff --git a/src/store/server/mutations.ts b/src/store/server/mutations.ts index d31d006931..da27774908 100644 --- a/src/store/server/mutations.ts +++ b/src/store/server/mutations.ts @@ -160,4 +160,21 @@ export const mutations: MutationTree = { if (state.system_info?.service_state) Vue.set(state.system_info.service_state, name, payload[name]) }, + + addFailedInitComponent(state, payload) { + const failed_init_components = state.failed_init_components + if (!failed_init_components.includes(payload)) failed_init_components.push(payload) + + Vue.set(state, 'failed_init_components', failed_init_components) + }, + + removeComponent(state, payload) { + const components = state.components + const index = components.indexOf(payload) + + if (index === -1) return + + components.splice(index, 1) + Vue.set(state, 'components', components) + }, } diff --git a/src/store/server/types.ts b/src/store/server/types.ts index 03c5f0c11b..69d6fe3992 100644 --- a/src/store/server/types.ts +++ b/src/store/server/types.ts @@ -11,6 +11,7 @@ export interface ServerState { klippy_message: string components: string[] failed_components: string[] + failed_init_components: string[] warnings: string[] registered_directories: string[] events: ServerStateEvent[] diff --git a/src/store/socket/actions.ts b/src/store/socket/actions.ts index a58a016d13..30f8cf7c85 100644 --- a/src/store/socket/actions.ts +++ b/src/store/socket/actions.ts @@ -153,10 +153,16 @@ export const actions: ActionTree = { commit('addInitModule', payload) }, + // remove only one module from init component like 'server/spoolman/getActiveSpoolId' removeInitModule({ commit }, payload: string) { commit('removeInitModule', payload) }, + // remove a complete init component like 'server/spoolman' + removeInitComponent({ commit }, payload: string) { + commit('removeInitComponent', payload) + }, + reportDebug(_, payload) { window.console.log(payload) }, diff --git a/src/store/socket/mutations.ts b/src/store/socket/mutations.ts index 61972f40f5..9399eb1697 100644 --- a/src/store/socket/mutations.ts +++ b/src/store/socket/mutations.ts @@ -61,4 +61,22 @@ export const mutations: MutationTree = { list.splice(index, 1) Vue.set(state, 'initializationList', list) }, + + removeInitComponent(state, payload) { + const list = [...state.initializationList] + + // remove all components witch starts with payload + const indexes = list.reduce((acc: number[], item, index) => { + if (item.startsWith(payload)) acc.push(index) + return acc + }, []) + + // stop if no items found + if (!indexes.length) return + + // remove all items + indexes.forEach((index) => list.splice(index, 1)) + + Vue.set(state, 'initializationList', list) + }, }