From a169c39373ca79f7d15f80980dba1f35fa665a70 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 15 Mar 2023 11:02:42 -0600 Subject: [PATCH] Home: Get weather directly without reload --- home/inc/class.home_ui.inc.php | 4 ++++ home/inc/class.home_weather_portlet.inc.php | 1 + home/js/Et2PortletFavorite.ts | 3 +-- home/js/Et2PortletWeather.ts | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/home/inc/class.home_ui.inc.php b/home/inc/class.home_ui.inc.php index 2fbf8bd526..a960b8abe5 100644 --- a/home/inc/class.home_ui.inc.php +++ b/home/inc/class.home_ui.inc.php @@ -635,6 +635,10 @@ class home_ui // Update client side $update = array('attributes' => $attributes); + if($content && is_array($content)) + { + $update['attributes'] = array_merge_recursive($update['attributes'], $content); + } // New portlet? Flag going straight to edit mode if($add) diff --git a/home/inc/class.home_weather_portlet.inc.php b/home/inc/class.home_weather_portlet.inc.php index 35b5529a28..5085d35b7e 100644 --- a/home/inc/class.home_weather_portlet.inc.php +++ b/home/inc/class.home_weather_portlet.inc.php @@ -103,6 +103,7 @@ class home_weather_portlet extends home_portlet public function exec($id = null, Etemplate &$etemplate = null) { + return ['settings' => $this->get_value()]; } /** diff --git a/home/js/Et2PortletFavorite.ts b/home/js/Et2PortletFavorite.ts index a01a52a79a..9b867d2bf0 100644 --- a/home/js/Et2PortletFavorite.ts +++ b/home/js/Et2PortletFavorite.ts @@ -127,8 +127,7 @@ export class Et2PortletFavorite extends Et2Portlet return super.update_settings(settings) .then(result => { - // Response did not ask for settings, and was not understandable for us - if(result == false && !this.nm) + if(!this.nm) { // If child was added recently (not loaded in normal reload), resize them all etemplate2.getByTemplate("home.favorite").forEach(et => (et).resize(undefined)) diff --git a/home/js/Et2PortletWeather.ts b/home/js/Et2PortletWeather.ts index e28c391ddb..3386307fa1 100644 --- a/home/js/Et2PortletWeather.ts +++ b/home/js/Et2PortletWeather.ts @@ -131,7 +131,7 @@ export class Et2PortletWeather extends Et2Portlet const current = this.settings?.weather?.current || {weather: [{icon: "question-lg"}], temp: {temp: "?"}}; // Get the forecast, excluding today - let list = this.settings.weather && (Object.values(this.settings?.weather?.list || {}).slice(1) || []); + let list = this.settings.weather && (Object.values(this.settings?.weather?.list || {}).slice(1) || []) || []; return html`