diff --git a/www/css/colors.css b/www/css/colors.css index 4ff6899..3c16bbe 100644 --- a/www/css/colors.css +++ b/www/css/colors.css @@ -13,31 +13,31 @@ } .c_red300{ background: #E57373; - color: #ffffff; + color: #ffffff!important; } .c_red400{ background: #EF5350; - color: #ffffff; + color: #ffffff!important; } .c_red500{ background: #F44336; - color: #ffffff; + color: #ffffff!important; } .c_red600{ background: #E53935; - color: #ffffff; + color: #ffffff!important; } .c_red700{ background: #D32F2F; - color: #ffffff; + color: #ffffff!important; } .c_red800{ background: #C62828; - color: #ffffff; + color: #ffffff!important; } .c_red900{ background: #B71C1C; - color: #ffffff; + color: #ffffff!important; } .ctext_red400{ diff --git a/www/index.html b/www/index.html index 787e04a..e51c657 100644 --- a/www/index.html +++ b/www/index.html @@ -48,6 +48,7 @@ + diff --git a/www/js/alerts.js b/www/js/alerts.js new file mode 100644 index 0000000..28274fc --- /dev/null +++ b/www/js/alerts.js @@ -0,0 +1,72 @@ +angular.module('app.alerts', ['pascalprecht.translate']) + +.controller('AlertsCtrl', function($scope, $http, $ionicModal, + $timeout, $ionicLoading, $filter) { + + + $scope.events=[]; + $scope.page=0; + $scope.doRefresh = function() { + /* events refresh: */ + //$http.get(urlapi + 'events?page=' + $scope.page) + $http.get(urlapi + 'alerts') + .then(function(data){ + console.log('data success events'); + console.log(data); // for browser console + //$scope.events = data.data; // for UI + $scope.events=data.data; + $scope.$broadcast('scroll.refreshComplete');//refresher stop + + }, function(data){ + console.log('data error'); + $scope.$broadcast('scroll.refreshComplete');//refresher stop + $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); + + }); + }; + $scope.doRefresh(); + + $scope.share = function(event){ + var message = "[" + event.title + "]" + event.description; + /*var subject = event.title; + var file= ['',''];*/ + var link = "http://duckduckgo.com"; + $cordovaSocialSharing + .share(message, link) // Share via native share sheet + .then(function(result) { + // Success! + }, function(err) { + // An error occured. Show a message to the user + }); + }; + $scope.savedEvents=[]; + $scope.$on('$ionicView.enter', function(){//per executar-ho cada cop que es carrega el view + if (localStorage.getItem("events_app_savedEvents")) { + $scope.savedEvents = JSON.parse(localStorage.getItem("events_app_savedEvents")); + console.log("savedEvents"); + console.log($scope.savedEvents); + } + }); + $scope.saveEvent = function(event){ + $scope.savedEvents.push(event); + localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents)); + $ionicLoading.show({ template: 'Event saved', noBackdrop: true, duration: 1000 }); + }; + $scope.unsaveEvent = function(event){ + for(var i=0; i<$scope.savedEvents.length; i++) { + if ($scope.savedEvents[i]._id === event._id){ + $scope.savedEvents.splice(i, 1); + } + } + localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents)); + $ionicLoading.show({ template: 'Event unsaved', noBackdrop: true, duration: 1000 }); + }; + $scope.isEventSaved = function(event) { + for(var i=0; i<$scope.savedEvents.length; i++) { + if ($scope.savedEvents[i]._id === event._id){ + return true; + } + } + return false; + }; +}); diff --git a/www/js/app.js b/www/js/app.js index 50ad71b..929b862 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -11,6 +11,7 @@ angular.module('app', [ 'app.main', 'app.events', 'app.event', + 'app.alerts', 'app.savedEvents', 'app.users', 'app.user' @@ -70,6 +71,15 @@ angular.module('app', [ } } }) + .state('app.alerts', { + url: '/alerts', + views: { + 'menuContent': { + templateUrl: 'templates/alerts.html', + controller: 'AlertsCtrl' + } + } + }) .state('app.savedEvents', { url: '/savedEvents', views: { diff --git a/www/js/events.js b/www/js/events.js index ba20016..8d53b90 100644 --- a/www/js/events.js +++ b/www/js/events.js @@ -5,6 +5,7 @@ angular.module('app.events', ['pascalprecht.translate']) $scope.events=[]; + $scope.alerts=[]; $scope.page=0; $scope.doRefresh = function() { /* events refresh: */ @@ -23,6 +24,11 @@ angular.module('app.events', ['pascalprecht.translate']) $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); }); + $http.get(urlapi + 'alerts') + .then(function(data){ + $scope.alerts=data.data; + }, function(data){ + }); }; $scope.doRefresh(); diff --git a/www/templates/alerts.html b/www/templates/alerts.html new file mode 100644 index 0000000..174fe79 --- /dev/null +++ b/www/templates/alerts.html @@ -0,0 +1,34 @@ + + + + + + + + {{event.user.username}} + {{event.user.shortDescription}} + + + {{event.title}} + {{event.description}} + {{event.date | date: 'HH:mm, dd/MM/yyyy'}} + + + + + + + + + + + + + + + + + + diff --git a/www/templates/events.html b/www/templates/events.html index 0acad43..e939fcf 100644 --- a/www/templates/events.html +++ b/www/templates/events.html @@ -2,19 +2,24 @@ + + {{alerts.length}} Emergency alerts! + {{event.user.username}} {{event.user.shortDescription}} - - - - {{event.title}} - {{event.description}} - {{event.date | date: 'HH:mm, dd/MM/yyyy'}} - + + + + + {{event.title}} + {{event.description}} + {{event.date | date: 'HH:mm, dd/MM/yyyy'}} diff --git a/www/templates/main.html b/www/templates/main.html index 3e7d237..700b061 100644 --- a/www/templates/main.html +++ b/www/templates/main.html @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -25,7 +25,7 @@ - + diff --git a/www/templates/menu.html b/www/templates/menu.html index af11104..00092dd 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -14,7 +14,7 @@ - Left + Menu
{{event.user.shortDescription}}
{{event.description}}
{{event.date | date: 'HH:mm, dd/MM/yyyy'}}