diff --git a/www/css/style.css b/www/css/style.css index b123a9a..b8638e2 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -18,3 +18,50 @@ .o_textRight{ text-align: right; } +.o_loginBackground{ + height: 100%!important; + width: 100%; + min-height: auto; + -webkit-background-size: cover; + -moz-background-size: cover; + background-size: cover; + -o-background-size: cover; + background-position: center; + background-image: url('../img/loginWallpaper.png'); + text-align: center; + /*color: white;*/ + + /* Create the parallax scrolling effect */ + background-attachment: fixed; + background-position: center; + background-repeat: no-repeat; + background-size: cover; + + color: #000000; + + padding-top: 30%; +} +.o_loginBackground h1{ + color: #000000!important; + margin: 10px; +} +.o_loginInput{ + background: rgba(255, 255, 255, 0.2); + padding:10px; + color: #000000; + border: 0px; + width: 80%; + font-size: 120%; +} +.o_loginInput::-webkit-input-placeholder{ + color: rgba(0, 0, 0, 0.6); +} +.o_loginButton{ + color: rgba(0, 0, 0, 0.8); + font-weight: bold; + margin: 10%; +} +.o_signupLink{ + text-decoration: none; + color: #000000; +} diff --git a/www/img/loginWallpaper.png b/www/img/loginWallpaper.png new file mode 100644 index 0000000..9e9d10a Binary files /dev/null and b/www/img/loginWallpaper.png differ diff --git a/www/index.html b/www/index.html index e51c657..b869d2b 100644 --- a/www/index.html +++ b/www/index.html @@ -50,8 +50,10 @@ + + diff --git a/www/js/app.js b/www/js/app.js index 929b862..2c1edab 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1,5 +1,5 @@ -//var urlapi = "http://localhost:3000/api/"; -var urlapi = "http://192.168.1.34:3000/api/"; +var urlapi = "http://localhost:3000/api/"; +//var urlapi = "http://192.168.1.34:3000/api/"; @@ -13,8 +13,10 @@ angular.module('app', [ 'app.event', 'app.alerts', 'app.savedEvents', + 'app.byCategories', 'app.users', - 'app.user' + 'app.user', + 'app.login' ]) .run(function($ionicPlatform) { @@ -89,6 +91,15 @@ angular.module('app', [ } } }) + .state('app.byCategories', { + url: '/byCategories', + views: { + 'menuContent': { + templateUrl: 'templates/byCategories.html', + controller: 'ByCategoriesCtrl' + } + } + }) .state('app.users', { url: '/users', views: { @@ -106,6 +117,15 @@ angular.module('app', [ controller: 'UserCtrl' } } + }) + .state('app.login', { + url: '/login', + views: { + 'menuContent': { + templateUrl: 'templates/login.html', + controller: 'LoginCtrl' + } + } }); // if none of the above states are matched, use this as the fallback diff --git a/www/js/byCategories.js b/www/js/byCategories.js new file mode 100644 index 0000000..612d30d --- /dev/null +++ b/www/js/byCategories.js @@ -0,0 +1,78 @@ +angular.module('app.byCategories', ['pascalprecht.translate']) + +.controller('ByCategoriesCtrl', function($scope, $http, $ionicModal, + $timeout, $ionicLoading, $filter) { + + + $scope.events=[]; + $scope.alerts=[]; + $scope.page=0; + $scope.doRefresh = function() { + /* events refresh: */ + //$http.get(urlapi + 'events?page=' + $scope.page) + $http.get(urlapi + 'events') + .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 }); + + }); + $http.get(urlapi + 'alerts') + .then(function(data){ + $scope.alerts=data.data; + }, function(data){ + }); + }; + $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/login.js b/www/js/login.js new file mode 100644 index 0000000..ee269c0 --- /dev/null +++ b/www/js/login.js @@ -0,0 +1,39 @@ +angular.module('app.login', ['pascalprecht.translate']) + +.controller('LoginCtrl', function($scope, $ionicModal, $timeout, $http, $window, $ionicLoading) { + + // Form data for the login modal + $scope.loginData = {}; + // Perform the login action when the user submits the login form + $scope.doLogin = function() { + console.log('Doing login', $scope.loginData); + + $http({ + url: urlapi + 'login', + method: "POST", + data: $scope.loginData + }) + .then(function(response) { + // success + console.log("response: "); + console.log(response.data); + if (response.data.success == true) + { + localStorage.setItem("events_app_token", response.data.token); + localStorage.setItem("events_app_userdata", JSON.stringify(response.data.user)); + window.location.href="#/app/main"; + window.location.reload(); + }else{ + console.log("login failed"); + $ionicLoading.show({ template: 'Login failed, user or password error.', noBackdrop: true, duration: 2000 }); + } + + + }, + function(response) { // optional + // failed + console.log(response); + }); + + }; +}); diff --git a/www/js/menu.js b/www/js/menu.js index e0f3ebc..fb007dd 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -2,6 +2,7 @@ angular.module('app.menu', ['pascalprecht.translate']) .controller('MenuCtrl', function($scope, $window) { + $scope.storageuser; if (localStorage.getItem("events_app_userdata")) { $scope.storageuser = JSON.parse(localStorage.getItem("events_app_userdata")); console.log($scope.storageuser); diff --git a/www/templates/byCategories.html b/www/templates/byCategories.html new file mode 100644 index 0000000..57155c1 --- /dev/null +++ b/www/templates/byCategories.html @@ -0,0 +1,42 @@ + + + + + + {{alerts.length}} Emergency alerts! + + + + + {{event.user.username}} + {{event.user.shortDescription}} + + + + + + {{event.title}} + {{event.description}} + {{event.date | date: 'HH:mm, dd/MM/yyyy'}} + + + + + + + + + + + + + + + + + + diff --git a/www/templates/login.html b/www/templates/login.html new file mode 100644 index 0000000..f5519b0 --- /dev/null +++ b/www/templates/login.html @@ -0,0 +1,36 @@ + + + + + Log in to post + + v0.0.1 + + + + + + + + + + + + + + {{'LOG_IN' | translate}} + + + + + + + Need account? Contact us! + + + + + + diff --git a/www/templates/main.html b/www/templates/main.html index 700b061..48504bf 100644 --- a/www/templates/main.html +++ b/www/templates/main.html @@ -20,7 +20,7 @@ - + diff --git a/www/templates/menu.html b/www/templates/menu.html index 00092dd..00f8701 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -30,7 +30,7 @@ Saved Events - + By Categories @@ -45,8 +45,13 @@ Settings - - User login + + Login + + + Logout
{{event.user.shortDescription}}
{{event.description}}
{{event.date | date: 'HH:mm, dd/MM/yyyy'}}
+ + +
+ + {{'LOG_IN' | translate}} + +
+ + + Need account? Contact us! + +