From 15d7be5cc26ff1fd35565fae799608290b32ff23 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Sun, 18 Aug 2024 13:03:44 +0200 Subject: [PATCH] new button to force load the default theme --- src/components/settings/GeneralSettings.vue | 32 ++++++++++++++++++++- src/locales/en.yaml | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/settings/GeneralSettings.vue b/src/components/settings/GeneralSettings.vue index 4874faf270..68f3b5b9e6 100644 --- a/src/components/settings/GeneralSettings.vue +++ b/src/components/settings/GeneralSettings.vue @@ -291,10 +291,20 @@ outlined small color="primary" + class="mr-2" @click="uploadSettingsFile.click()" > {{ $t('app.setting.btn.restore') }} + + + {{ $t('app.setting.btn.default') }} + @@ -312,7 +322,7 @@ import { Component, Mixins, Ref } from 'vue-property-decorator' import StateMixin from '@/mixins/state' import type { VInput } from '@/types' -import { SupportedLocales, DateFormats, TimeFormats } from '@/globals' +import { SupportedLocales, DateFormats, TimeFormats, Globals } from '@/globals' import type { OutputPin } from '@/store/printer/types' import type { Device } from '@/store/power/types' import type { PrintEtaCalculation, PrintInProgressLayout, PrintProgressCalculation } from '@/store/config/types' @@ -321,6 +331,7 @@ import consola from 'consola' import { readFileAsTextAsync } from '@/util/file-system-entry' import { EventBus } from '@/eventBus' import { isFluiddContent, toFluiddContent } from '@/util/fluidd-content' +import { appInit } from '@/init' @Component({ components: {} @@ -678,6 +689,25 @@ export default class GeneralSettings extends Mixins(StateMixin) { } } + async handleDefaultSettings () { + try { + await httpClientActions.serverDatabaseItemDelete(Globals.MOONRAKER_DB.fluidd.NAMESPACE, Globals.MOONRAKER_DB.fluidd.ROOTS.charts.name) + await httpClientActions.serverDatabaseItemDelete(Globals.MOONRAKER_DB.fluidd.NAMESPACE, Globals.MOONRAKER_DB.fluidd.ROOTS.console.name) + await httpClientActions.serverDatabaseItemDelete(Globals.MOONRAKER_DB.fluidd.NAMESPACE, Globals.MOONRAKER_DB.fluidd.ROOTS.layout.name) + await httpClientActions.serverDatabaseItemDelete(Globals.MOONRAKER_DB.fluidd.NAMESPACE, Globals.MOONRAKER_DB.fluidd.ROOTS.macros.name) + await httpClientActions.serverDatabaseItemDelete(Globals.MOONRAKER_DB.fluidd.NAMESPACE, Globals.MOONRAKER_DB.fluidd.ROOTS.uiSettings.name) + const instance = this.$store.getters['config/getCurrentInstance'] + const config = await appInit(instance, this.$store.state.config.hostConfig) + if (config.apiConnected && config.apiAuthenticated) { + consola.debug('Activating socket with config', config) + this.$socket.connect(config.apiConfig.socketUrl) + } + } catch (e) { + console.error('handleDefaultSettings failed ' + e) + consola.error('handleDefaultSettings failed', e) + } + } + async handleRestoreSettings () { try { if (this.uploadSettingsFile?.files?.length === 1) { diff --git a/src/locales/en.yaml b/src/locales/en.yaml index 82725021f2..8c0274524b 100644 --- a/src/locales/en.yaml +++ b/src/locales/en.yaml @@ -531,6 +531,7 @@ app: backup: Backup reset: Reset restore: Restore + default: Default select_theme: Select Theme camera_type_options: mjpegadaptive: MJPEG Adaptive