diff --git a/apps/weather_status/appinfo/routes.php b/apps/weather_status/appinfo/routes.php
index 8737bfd2dc6c0..fa6481e24fea8 100644
--- a/apps/weather_status/appinfo/routes.php
+++ b/apps/weather_status/appinfo/routes.php
@@ -30,7 +30,7 @@
['name' => 'WeatherStatus#getLocation', 'url' => '/api/v1/location', 'verb' => 'GET'],
['name' => 'WeatherStatus#setLocation', 'url' => '/api/v1/location', 'verb' => 'PUT'],
['name' => 'WeatherStatus#getForecast', 'url' => '/api/v1/forecast', 'verb' => 'GET'],
- ['name' => 'WeatherStatus#getFavorites', 'url' => '/api/v1/favorites', 'verb' => 'GET'],
- ['name' => 'WeatherStatus#setFavorites', 'url' => '/api/v1/favorites', 'verb' => 'PUT'],
+ ['name' => 'WeatherStatus#getOptions', 'url' => '/api/v1/options', 'verb' => 'GET'],
+ ['name' => 'WeatherStatus#setOptions', 'url' => '/api/v1/options', 'verb' => 'PUT'],
],
];
diff --git a/apps/weather_status/lib/Controller/WeatherStatusController.php b/apps/weather_status/lib/Controller/WeatherStatusController.php
index 7ec6c71493e6e..03abb1337644c 100644
--- a/apps/weather_status/lib/Controller/WeatherStatusController.php
+++ b/apps/weather_status/lib/Controller/WeatherStatusController.php
@@ -125,23 +125,24 @@ public function getForecast(): DataResponse {
/**
* @NoAdminRequired
*
- * Get favorites list
+ * Get option values
*
- * @return DataResponse which contains the favorite list
+ * @return DataResponse
*/
- public function getFavorites(): DataResponse {
- return new DataResponse($this->service->getFavorites());
+ public function getOptions(): DataResponse {
+ return new DataResponse($this->service->getOptions());
}
/**
* @NoAdminRequired
*
- * Set favorites list
+ * Set option values
*
- * @param array $favorites
+ * @param ?array $favorites
+ * @param ?int $forecastOffset
* @return DataResponse success state
*/
- public function setFavorites(array $favorites): DataResponse {
- return new DataResponse($this->service->setFavorites($favorites));
+ public function setOptions(?array $favorites = null, ?int $forecastOffset = null): DataResponse {
+ return new DataResponse($this->service->setOptions($favorites, $forecastOffset));
}
}
diff --git a/apps/weather_status/lib/Service/WeatherStatusService.php b/apps/weather_status/lib/Service/WeatherStatusService.php
index 0d7b31f90429d..cba7e6a134598 100644
--- a/apps/weather_status/lib/Service/WeatherStatusService.php
+++ b/apps/weather_status/lib/Service/WeatherStatusService.php
@@ -134,22 +134,31 @@ public function setMode(int $mode): array {
}
/**
- * Get favorites list
- * @param array $favorites
- * @return array success state
+ * Get option values
+ * @return array the values
*/
- public function getFavorites(): array {
+ public function getOptions(): array {
$favoritesJson = $this->config->getUserValue($this->userId, Application::APP_ID, 'favorites', '');
- return json_decode($favoritesJson, true) ?: [];
+ $forecastOffset = $this->config->getUserValue($this->userId, Application::APP_ID, 'forecastOffset', '5');
+ return [
+ 'favorites' => json_decode($favoritesJson, true) ?: [],
+ 'forecastOffset' => $forecastOffset,
+ ];
}
/**
- * Set favorites list
- * @param array $favorites
+ * Set option values
+ * @param ?array $favorites
+ * @param ?int $forecastOffset
* @return array success state
*/
- public function setFavorites(array $favorites): array {
- $this->config->setUserValue($this->userId, Application::APP_ID, 'favorites', json_encode($favorites));
+ public function setOptions(?array $favorites, ?int $forecastOffset): array {
+ if (!is_null($favorites)) {
+ $this->config->setUserValue($this->userId, Application::APP_ID, 'favorites', json_encode($favorites));
+ }
+ if (!is_null($forecastOffset)) {
+ $this->config->setUserValue($this->userId, Application::APP_ID, 'forecastOffset', strval($forecastOffset));
+ }
return ['success' => true];
}
diff --git a/apps/weather_status/src/App.vue b/apps/weather_status/src/App.vue
index 81edc28eaf458..82a8f3eee1669 100644
--- a/apps/weather_status/src/App.vue
+++ b/apps/weather_status/src/App.vue
@@ -25,7 +25,8 @@