From 5cbaf39d509bb4e802d1e68b90fc107bc7d1374a Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 24 Nov 2015 18:05:54 +0300 Subject: [PATCH] wheather init --- src/app/pages/dashboard/dashboard.html | 8 +++ .../dashboard/widgets/weather/_weather.scss | 28 ++++++++ .../dashboard/widgets/weather/weather.html | 14 ++++ .../dashboard/widgets/weather/weather.js | 65 +++++++++++++++++++ src/assets/css/main.scss | 1 + 5 files changed, 116 insertions(+) create mode 100644 src/app/pages/dashboard/widgets/weather/_weather.scss create mode 100644 src/app/pages/dashboard/widgets/weather/weather.html create mode 100644 src/app/pages/dashboard/widgets/weather/weather.js diff --git a/src/app/pages/dashboard/dashboard.html b/src/app/pages/dashboard/dashboard.html index 377a355..c9ed102 100644 --- a/src/app/pages/dashboard/dashboard.html +++ b/src/app/pages/dashboard/dashboard.html @@ -47,3 +47,11 @@ + +
+
+ + + +
+
diff --git a/src/app/pages/dashboard/widgets/weather/_weather.scss b/src/app/pages/dashboard/widgets/weather/_weather.scss new file mode 100644 index 0000000..7e47aba --- /dev/null +++ b/src/app/pages/dashboard/widgets/weather/_weather.scss @@ -0,0 +1,28 @@ +.rightHeading{ + display:block; + float:right; +} + +.center{ + text-align: center; +} + +.weather-info{ + padding-left: 15px; +} + +.font50up{ + font-size: 1.5em; +} + +.font-x2{ + font-size: 2em; +} + +.font-x3{ + font-size: 3em; +} + +.font-x4{ + font-size: 4em; +} diff --git a/src/app/pages/dashboard/widgets/weather/weather.html b/src/app/pages/dashboard/widgets/weather/weather.html new file mode 100644 index 0000000..d372f3a --- /dev/null +++ b/src/app/pages/dashboard/widgets/weather/weather.html @@ -0,0 +1,14 @@ +
+ {{geoData.geoplugin_countryName | uppercase}} - {{geoData.geoplugin_city}} {{ date | date : 'EEEE h:mm'}} +
+ + + + + + + + + +
{{weatherData.weather[0].main}} - {{weatherData.weather[0].description}}
{{weatherData.main.temp}} °C | °F
+ diff --git a/src/app/pages/dashboard/widgets/weather/weather.js b/src/app/pages/dashboard/widgets/weather/weather.js new file mode 100644 index 0000000..d6aafe1 --- /dev/null +++ b/src/app/pages/dashboard/widgets/weather/weather.js @@ -0,0 +1,65 @@ +'use strict'; + +blurAdminApp.directive('blurWeather', function () { + return { + restrict: 'EA', + controller: ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) { + $scope.url = 'http://api.openweathermap.org/data/2.5/weather'; + $scope.method = 'GET'; + $scope.key = '2de143494c0b295cca9337e1e96b00e0'; + $scope.units = 'metric'; + $scope.date = new Date(); + $scope.weatherIcons = { + '01d' : 'ion-ios-sunny-outline', + '02d' : 'ion-ios-partlysunny-outline', + '03d' : 'ion-ios-cloud-outline', + '04d' : 'ion-ios-cloud', + '09d' : 'ion-ios-rainy', + '10d' : 'ion-ios-rainy-outline', + '11d' : 'ion-ios-thunderstorm-outline', + '13d' : 'ion-ios-snowy', + '50d' : 'ion-ios-cloudy-outline', + '01n' : 'ion-ios-cloudy-night-outline', + '02n' : 'ion-ios-cloudy-night', + '03n' : 'ion-ios-cloud-outline', + '04n' : 'ion-ios-cloud', + '09n' : 'ion-ios-rainy', + '10n' : 'ion-ios-rainy-outline', + '11n' : 'ion-ios-thunderstorm', + '13n' : 'ion-ios-snowy', + '50n' : 'ion-ios-cloudy-outline' + }; + $scope.updateWeather = function () { + $http({ + method: $scope.method, url: $scope.url, params: { + appid: $scope.key, + lat: $scope.geoData.geoplugin_latitude, + lon: $scope.geoData.geoplugin_longitude, + units : $scope.units + } + }).then(function success(response) { + $scope.weatherData = response.data; + console.log(response.data); + }, function error(response) { + console.log("WEATHER FAILED") + }); + }; + + $scope.updateGeoData = function () { + $http.jsonp('http://www.geoplugin.net/json.gp?jsoncallback=JSON_CALLBACK').then(function success(response) { + $scope.geoData = response.data; + console.log(response.data); + $scope.updateWeather(); + }, function error() { + console.log("GEO FAILED") + }); + }; + + $timeout(function () { + $scope.updateGeoData(); + }, 100); + + }], + templateUrl: 'app/pages/dashboard/widgets/weather/weather.html' + }; +}); \ No newline at end of file diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index bff6c86..62f19e2 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -31,6 +31,7 @@ "../../app/pages/dashboard/widgets/trafficChart/trafficChart.scss", "../../app/pages/dashboard/widgets/popularApp/popularApp.scss", "../../app/pages/dashboard/widgets/blurFeed/blurFeed.scss", +"../../app/pages/dashboard/widgets/weather/weather.scss", "../../app/pages/maps/widgets/leaflet/leaflet.scss", "../../app/pages/maps/widgets/google-maps/google-maps.scss", "../../app/pages/maps/widgets/map-bubbles/map-bubbles.scss",