From e5c18adc2d7bfb1e8be31df9ff4e63d8600242bf Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 21 Mar 2024 22:47:24 +0100 Subject: [PATCH 1/2] fix: ignore wrong default.json file while resetting moonraker db Signed-off-by: Stefan Dej --- .../LogfilesPanelRolloverDialog.vue | 2 +- .../settings/General/GeneralReset.vue | 21 ++++++++++--------- src/store/gui/actions.ts | 10 +++++---- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/components/panels/Machine/LogfilesPanel/LogfilesPanelRolloverDialog.vue b/src/components/panels/Machine/LogfilesPanel/LogfilesPanelRolloverDialog.vue index 2cbb1edab..61ef2eff7 100644 --- a/src/components/panels/Machine/LogfilesPanel/LogfilesPanelRolloverDialog.vue +++ b/src/components/panels/Machine/LogfilesPanel/LogfilesPanelRolloverDialog.vue @@ -65,7 +65,7 @@ export default class LogfilesPanelRolloverDialog extends Mixins(BaseMixin) { selectedRolloverLogs: string[] = [] get loadingRolloverLogs() { - return this.loadings.filter((log) => log.startsWith('rolloverLog_')).length > 0 + return this.loadings.filter((log) => log?.startsWith('rolloverLog_')).length > 0 } @Watch('loadingRolloverLogs') diff --git a/src/components/settings/General/GeneralReset.vue b/src/components/settings/General/GeneralReset.vue index d2553a1be..9444ddf01 100644 --- a/src/components/settings/General/GeneralReset.vue +++ b/src/components/settings/General/GeneralReset.vue @@ -85,17 +85,18 @@ export default class SettingsGeneralTabResetDatabase extends Mixins(BaseMixin, S async loadResetableNamespaces() { this.resetableNamespaces = await this.loadBackupableNamespaces() - if (this.moonrakerComponents.includes('history')) { - this.resetableNamespaces.push({ - value: 'history_jobs', - label: this.$t('Settings.GeneralTab.DbHistoryJobs'), - }) + // stop if history is not enabled + if (this.moonrakerComponents.includes('history')) return - this.resetableNamespaces.push({ - value: 'history_totals', - label: this.$t('Settings.GeneralTab.DbHistoryTotals'), - }) - } + this.resetableNamespaces.push({ + value: 'history_jobs', + label: this.$t('Settings.GeneralTab.DbHistoryJobs'), + }) + + this.resetableNamespaces.push({ + value: 'history_totals', + label: this.$t('Settings.GeneralTab.DbHistoryTotals'), + }) } closeDialog() { diff --git a/src/store/gui/actions.ts b/src/store/gui/actions.ts index ea4dd7363..1902d6e8a 100644 --- a/src/store/gui/actions.ts +++ b/src/store/gui/actions.ts @@ -236,11 +236,13 @@ export const actions: ActionTree = { const urlDefault = rootGetters['socket/getUrl'] + '/server/files/config/' + themeDir + '/default.json?time=' + Date.now() - const responseDefault = await fetch(urlDefault) + let defaults: any = {} - if (responseDefault) { - defaults = await responseDefault.json() - if (defaults.error?.code === 404) defaults = {} + try { + defaults = await fetch(urlDefault).then((result) => result.json()) + } catch (error) { + window.console.error('Error while fetching/parsing default.json', error) + defaults = {} } for (const key of payload) { From d01b26a83683f2c342c3b3536152994027390c61 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 27 Apr 2024 11:46:23 +0200 Subject: [PATCH 2/2] fix: fix wrong stop in loadResetableNamespaces Signed-off-by: Stefan Dej --- src/components/settings/General/GeneralReset.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/settings/General/GeneralReset.vue b/src/components/settings/General/GeneralReset.vue index 9444ddf01..5f46670fa 100644 --- a/src/components/settings/General/GeneralReset.vue +++ b/src/components/settings/General/GeneralReset.vue @@ -86,7 +86,7 @@ export default class SettingsGeneralTabResetDatabase extends Mixins(BaseMixin, S this.resetableNamespaces = await this.loadBackupableNamespaces() // stop if history is not enabled - if (this.moonrakerComponents.includes('history')) return + if (!this.moonrakerComponents.includes('history')) return this.resetableNamespaces.push({ value: 'history_jobs',