diff --git a/controller/citycontroller.php b/controller/citycontroller.php index cfc8796..3a03d08 100644 --- a/controller/citycontroller.php +++ b/controller/citycontroller.php @@ -85,7 +85,12 @@ class CityController extends IntermediateController { } if ($id = $this->mapper->create($this->userId, $name)) { - return new JSONResponse(array("id" => $id)); + // Load parameter is set to true if we don't found previous cities. + // This permit to trigger loading of the first city in UI + return new JSONResponse(array( + "id" => $id, + "load" => count($cities) == 0) + ); } return new JSONResponse(array()); diff --git a/controller/weathercontroller.php b/controller/weathercontroller.php index b1110ee..182c327 100644 --- a/controller/weathercontroller.php +++ b/controller/weathercontroller.php @@ -86,7 +86,7 @@ class WeatherController extends IntermediateController { return $cityDatas; } - private function windDegToString($deg) { + private static function windDegToString($deg) { if ($deg > 0 && $deg < 23 || $deg > 333) { return "North"; diff --git a/js/public/app.js b/js/public/app.js index 0077ca5..40733a2 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -11,7 +11,7 @@ var app = angular.module('Weather', []); -var g_error500 = 'Fatal Error: please check your owncloud.log and send a bug report here: https://github.com/nerzhul/weather/issues'; +var g_error500 = 'Fatal Error: please check your owncloud.log and send a bug report here: https://github.com/nextcloud/weather/issues'; function undef (obj) { return typeof obj === undefined || obj === undefined; @@ -246,6 +246,12 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil if (r.data != null && !undef(r.data['id'])) { $scope.cities.push({"name": city.name, "id": r.data['id']}) $scope.showAddCity = false; + + if (!undef(r.data['load']) && r.data['load']) { + loadingCity = angular.copy(city); + loadingCity.id = r.data['id']; + $scope.loadCity(loadingCity); + } city.name = ""; } else {