Load city when server ask for loading it
it's used when no city were found previously and it's the first citymaster
parent
4f810ec04a
commit
992378f166
|
@ -85,7 +85,12 @@ class CityController extends IntermediateController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id = $this->mapper->create($this->userId, $name)) {
|
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());
|
return new JSONResponse(array());
|
||||||
|
|
|
@ -86,7 +86,7 @@ class WeatherController extends IntermediateController {
|
||||||
return $cityDatas;
|
return $cityDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function windDegToString($deg) {
|
private static function windDegToString($deg) {
|
||||||
if ($deg > 0 && $deg < 23 ||
|
if ($deg > 0 && $deg < 23 ||
|
||||||
$deg > 333) {
|
$deg > 333) {
|
||||||
return "North";
|
return "North";
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
var app = angular.module('Weather', []);
|
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) {
|
function undef (obj) {
|
||||||
return typeof obj === undefined || obj === undefined;
|
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'])) {
|
if (r.data != null && !undef(r.data['id'])) {
|
||||||
$scope.cities.push({"name": city.name, "id": r.data['id']})
|
$scope.cities.push({"name": city.name, "id": r.data['id']})
|
||||||
$scope.showAddCity = false;
|
$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 = "";
|
city.name = "";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue