From 601249ddefbcc598d804fb28db34d365ef93a37a Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Wed, 24 May 2023 10:59:30 +0200 Subject: [PATCH 1/2] add web theme selection --- src/components/OpenwbBaseHeading.vue | 3 +- .../web_themes/OpenwbWebThemeFallback.vue | 39 +++++++ .../web_themes/OpenwbWebThemeProxy.vue | 37 +++++++ src/views/GeneralConfig.vue | 102 +++++++++++++++++- 4 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 src/components/web_themes/OpenwbWebThemeFallback.vue create mode 100644 src/components/web_themes/OpenwbWebThemeProxy.vue diff --git a/src/components/OpenwbBaseHeading.vue b/src/components/OpenwbBaseHeading.vue index b259289c..aee732b2 100644 --- a/src/components/OpenwbBaseHeading.vue +++ b/src/components/OpenwbBaseHeading.vue @@ -1,5 +1,5 @@ + + diff --git a/src/components/web_themes/OpenwbWebThemeProxy.vue b/src/components/web_themes/OpenwbWebThemeProxy.vue new file mode 100644 index 00000000..418c3b9f --- /dev/null +++ b/src/components/web_themes/OpenwbWebThemeProxy.vue @@ -0,0 +1,37 @@ + + + diff --git a/src/views/GeneralConfig.vue b/src/views/GeneralConfig.vue index 25185157..a21034a3 100644 --- a/src/views/GeneralConfig.vue +++ b/src/views/GeneralConfig.vue @@ -411,7 +411,7 @@ --> - +
Diese Einstellungen sind nicht verfügbar, solange sich @@ -419,6 +419,57 @@
+ + Hauptseite + +
+ + +
+
+ + Lade-Log + import ComponentState from "../components/mixins/ComponentState.vue"; +import OpenwbWebThemeProxy from "../components/web_themes/OpenwbWebThemeProxy.vue"; export default { name: "OpenwbGeneralConfig", mixins: [ComponentState], + components: { OpenwbWebThemeProxy }, data() { return { mqttTopicsToSubscribe: [ @@ -482,8 +535,55 @@ export default { "openWB/general/notifications/smart_home", "openWB/general/price_kwh", "openWB/general/range_unit", + "openWB/general/web_theme", + "openWB/system/configurable/web_themes", ], }; }, + computed: { + webThemeList: { + get() { + return this.$store.state.mqtt[ + "openWB/system/configurable/web_themes" + ]; + }, + }, + }, + methods: { + getWebThemeDefaultConfiguration(webThemeType) { + const webThemeDefaults = this.webThemeList.find( + (element) => element.value == webThemeType + ); + if ( + Object.prototype.hasOwnProperty.call( + webThemeDefaults, + "defaults" + ) + ) { + return { ...webThemeDefaults.defaults.configuration }; + } + console.warn( + "no default configuration found for web theme type!", + webThemeType + ); + return {}; + }, + updateSelectedWebTheme($event) { + this.updateState( + "openWB/general/web_theme", + $event, + "type" + ); + this.updateState( + "openWB/general/web_theme", + this.getWebThemeDefaultConfiguration($event), + "configuration" + ); + }, + updateConfiguration(key, event) { + console.debug("updateConfiguration", key, event); + this.updateState(key, event.value, event.object); + }, + }, }; From 9269c9559119f8de356e6b1b695cb66282f8b788 Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Wed, 24 May 2023 11:08:00 +0200 Subject: [PATCH 2/2] linting --- .../OpenwbDisplayThemeFallback.vue | 8 +++- .../web_themes/OpenwbWebThemeFallback.vue | 8 +++- .../web_themes/OpenwbWebThemeProxy.vue | 3 +- src/views/GeneralConfig.vue | 39 +++++++------------ 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/components/display_themes/OpenwbDisplayThemeFallback.vue b/src/components/display_themes/OpenwbDisplayThemeFallback.vue index 9f7e296c..2e66e8f2 100644 --- a/src/components/display_themes/OpenwbDisplayThemeFallback.vue +++ b/src/components/display_themes/OpenwbDisplayThemeFallback.vue @@ -1,5 +1,8 @@