From 618d165f340e7a957506239dca2e362c7463b459 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Sat, 11 Jul 2015 15:01:30 +0000 Subject: [PATCH] Add right template --- appinfo/application.php | 10 ++++++++++ css/style.css | 39 ++++++++++++++++++++++++++++++++++----- js/public/app.js | 7 ++++--- templates/main.php | 9 ++++++++- 4 files changed, 56 insertions(+), 9 deletions(-) diff --git a/appinfo/application.php b/appinfo/application.php index 4384aae..c6fc6f3 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -16,6 +16,7 @@ use \OCP\AppFramework\App; use \OCP\IContainer; use \OCA\Weather\Controller\CityController; +use \OCA\Weather\Controller\WeatherController; use \OCA\Weather\Db\CityMapper; @@ -51,5 +52,14 @@ class Application extends App { $c->query('CityMapper') ); }); + + $container->registerService('WeatherController', function(IContainer $c) { + return new WeatherController( + $c->query('AppName'), + $c->query('Request'), + $c->query('UserId'), + $c->query('CityMapper') + ); + }); } } diff --git a/css/style.css b/css/style.css index b708061..b3e5049 100644 --- a/css/style.css +++ b/css/style.css @@ -59,7 +59,7 @@ } #city-right { - padding: 15px; + padding: 45px; height: 100%; overflow-y: hidden; overflow-x: auto; @@ -67,10 +67,39 @@ bottom: 0; right: 0; left: 250px; - display: flex; - flex-direction: row; - position: absolute; - align-items: flex-start; + background: black; + color: #EEE; +} + +#city-right .city-name { + font-size: 6em; + line-height: 1em; +} + + +#city-right .city-current-temp { + font-size: 4em; + line-height: 1em; +} + +#city-right .city-current-pressure, #city-right .city-current-wind { + font-size: 3em; + line-height: 1em; +} + +#city-right .city-current-humidity { + font-size: 3em; + line-height: 1em; +} + +#city-right .city-current-weather { + font-size: 3em; + line-height: 1em; +} + +#city-right .city-current-sunrise { + font-size: 3em; + line-height: 1em; } .city-list hr { diff --git a/js/public/app.js b/js/public/app.js index 6b2e0ce..7742d62 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -25,11 +25,11 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil function ($scope, $interval, $timeout, $compile, $http) { $scope.userId = ''; $scope.cities = []; - $scope.selectedCityId = 0; $scope.showAddCity = false; $scope.addCityError = ''; $scope.cityLoadError = ''; + $scope.currentCity = null; $timeout(function () { $scope.loadCities(); @@ -57,9 +57,10 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil return; } - $http.get(OC.generateUrl('/apps/weather/weather/get'), {'name': city.name}). + $http.get(OC.generateUrl('/apps/weather/weather/get?name=' + city.name)). success(function (data, status, headers, config) { - if (data != null && !undef(data['id'])) { + if (data != null) { + $scope.currentCity = data; } else { $scope.cityLoadError = 'Failed to get city weather informations. Please contact your administrator'; diff --git a/templates/main.php b/templates/main.php index 34dae74..fcbfc84 100644 --- a/templates/main.php +++ b/templates/main.php @@ -30,6 +30,13 @@
{{ cityLoadError }}
-
+
+
{{ currentCity.name }}, {{ currentCity.sys.country }}
+
{{ currentCity.main.temp }}°C
+
Pressure: {{ currentCity.main.pressure }} hpa
+
Humidity: {{ currentCity.main.humidity}}%
+
Cloudiness: {{ currentCity.weather[0].description }}
+
Wind: {{ currentCity.wind.speed }} {{ currentCity.wind.deg }}
+
Sunrise: {{ currentCity.sys.sunrise * 1000 | date:'HH:mm' }} Sunset: {{ currentCity.sys.sunset * 1000 | date:'HH:mm' }}