Reload weather information for current city each minute

master
Loic Blot 2015-07-11 16:54:23 +00:00
parent 72feae63cf
commit a6f71267b3
1 changed files with 9 additions and 0 deletions

View File

@ -30,6 +30,7 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
$scope.cityLoadError = '';
$scope.currentCity = null;
$scope.domCity = null;
$scope.imageMapper = {
"Clear": "sun.png",
@ -41,6 +42,13 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
"Thunderstorm": "thunderstorm.png",
}
// Reload weather information each minute
$interval(function () {
if ($scope.currentCity != null) {
$scope.loadCity($scope.domCity);
}
}, 60000);
$timeout(function () {
$scope.loadCities();
});
@ -70,6 +78,7 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil
$http.get(OC.generateUrl('/apps/weather/weather/get?name=' + city.name)).
success(function (data, status, headers, config) {
if (data != null) {
$scope.domCity = city;
$scope.currentCity = data;
$scope.currentCity.image = $scope.imageMapper[$scope.currentCity.weather[0].main];
$scope.currentCity.wind.desc = "";