From 7b4eb5662f8052a6b6910935c837ab75216b54f4 Mon Sep 17 00:00:00 2001 From: nau Date: Fri, 26 Aug 2016 19:58:29 +0200 Subject: [PATCH] implemented in the app: show selected travel, add new travels to the server, menu icons --- app/www/css/style.css | 14 ++++ app/www/img/box.png | Bin 0 -> 555 bytes app/www/img/community.png | Bin 0 -> 1058 bytes app/www/img/from-to.png | Bin 0 -> 1231 bytes app/www/img/road.png | Bin 0 -> 1118 bytes app/www/img/rss-symbol.png | Bin 0 -> 1194 bytes app/www/img/smartphone.png | Bin 0 -> 893 bytes app/www/js/app.js | 2 +- app/www/js/controllers.js | 88 ++++++++++++++++++++----- app/www/templates/menu.html | 8 +++ app/www/templates/newtravel.html | 54 +++++++++++++++ app/www/templates/travel.html | 20 +++++- app/www/templates/travels.html | 12 +++- server/controllers/travelController.js | 3 +- server/models/travelModel.js | 3 +- server/server.js | 3 +- 16 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 app/www/img/box.png create mode 100644 app/www/img/community.png create mode 100644 app/www/img/from-to.png create mode 100644 app/www/img/road.png create mode 100644 app/www/img/rss-symbol.png create mode 100644 app/www/img/smartphone.png create mode 100644 app/www/templates/newtravel.html diff --git a/app/www/css/style.css b/app/www/css/style.css index fa22927..2afdee5 100644 --- a/app/www/css/style.css +++ b/app/www/css/style.css @@ -1 +1,15 @@ /* Empty. Add your own CSS if you like */ +.o-imgMenu{ + width: 25px!important; + height: 25px!important; +} +.o-imgTitle{ + width: 40px!important; + height: 40px!important; +} +.o-bold{ + font-weight: bold!important; +} +.o-float-right{ + float: right; +} diff --git a/app/www/img/box.png b/app/www/img/box.png new file mode 100644 index 0000000000000000000000000000000000000000..cfdf84b66bfd628b37645699616df617e9b88221 GIT binary patch literal 555 zcmV+`0@VG9P)c^_|)x8>6b}s+`01b3fPE!B^7BE+Ur_1B&^85Z? zQ=An5007@fL_t(I%cat56M;Y!fZ?Smk+SZz;*?ujR+j(&(^N8=bTWie~GN3~_0R1&@0S2Iz%$r>tbel2I00*EEqPkVU zRY_;@$-Ad{xup&g5-u&wghk#lXNgDZnSh z_5c6>K=lkj3J5|O7y<$m)~}y`|Nf`V4$mv+ai^q+wYEC%*^__b^7r))k4k6$T;upF zUGYn*!jE+h>Q+}7!|Yj45nbF3cT3M)4*ymO!3-AiHB#)Wt9 ze@l~pQa1bhIy;VpB+=Gxhh2M%&Yb(P)`1hm?Q-0+ujusor)9HVw6uKBPqoZ% zyI+9Jf+d>kH&4EKOQf|+w4*oo^w~n7u5?AtgcQf!`z0sMNI!9kD<#8r#~$vC9Fwg( z*<<3YckCAJ>?=KYo;@@|YT9h0&D-0qT;(e)m7F#Q$c{d8OrX3*X3k>WjoU&F9bxqV zI&Z^*yZ3>P=SoZg+9Ew|w(;iej=T2(Eh;*9L9n(-W8G%ig)4ma9pp>|TDtH1TKli7 zoPjC}PM?)uzSecme)gysiT)`T+jrGnye!<@p}b}jM|={{K%g3twr+>r`yi$jo;}az z;l<|T2a%FnvI=Om>e@{Z*%`O)%)fgd=<)CA3Q6z(wE|ECyg_UvJI zI924Tls6%-HN|p@*oIAKma&F8Zjj2cKD;NE*V2#oP0fv!jT=;cUNsO1VBW9NYI?vs zD1cX%&y>SUXg%X@dx`H$=Dq4<|NCu9uLQHhw)M3+ix#V~GpIfLSsi#R?W5cNd4`q0 z<5r*AV#t=ia<SbAf{l&zEBPZv-sQT4kny+ktF?dhxIwl4nj1J}F$kL-MZZdIPFZ2sre x*ZXd7N%V<6wp=fS?83{1OO*i`k?>- literal 0 HcmV?d00001 diff --git a/app/www/img/from-to.png b/app/www/img/from-to.png new file mode 100644 index 0000000000000000000000000000000000000000..92b2cac64725fb6741413e887a5303c78f4f96a2 GIT binary patch literal 1231 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+081LLFspAgso|Npy(hI;u2 zd-(-<`2op5FJB-7f&zgIcfU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?d00001 diff --git a/app/www/img/smartphone.png b/app/www/img/smartphone.png new file mode 100644 index 0000000000000000000000000000000000000000..35bacf1a0edf3419d74ddb74c9c6b4e2b8809364 GIT binary patch literal 893 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10;#Gi8i0l9V|2_Rfz5Ii` z{D3GJNc#Hv1_T6n0g->8pP!$%Uyx5gfRBHWn_DbUHZ(NU%P-K&H^@66z}q(vDB|fK zuWzW24^TT0K`agO0NUsW z@+4R`7^uB0$QgB*-tAL2J$LZ4Dv<28Al#W`W%Q*gRGkm){BJOTXa8+Pq=j!i@)c z#FT!rzgM)pVRFw%;REAKjdht3POq8#pE#a6y0np#w_?VsbERK|Cf>GZ6Q0%!G?y{S z+ug-r-5uR0Kn`btM`STD+OC5zqm#z$3ZNi+iKnkC`vVRsVHv}kUfwXE&_7QX#}JFt zZzrD&JLDkXD$lY)K}EnM&}4;%M@RvOMFW@P%#;7?`&kP+a?QQN@40?`efj&Gb!VBC zggkY77OD#W@YI^CsAN0)?x~kDMlY{i55D&xQLJlq&Q!14*4MN|xz+rY&--uNyqlft zG?QZD{{tI+cZkZ!ZA{?YQ1E8aqeWSBGM4LbSU0vt{XMf{(Zjj%4tfXneUZx8wr*X% z$f33OvliWLtW_6(CogB6TT=byi;j4l%&XGIe+-Q=9}Hd;OZ^Ja<*ffv8Om}04|l!B z9s<@sNdt6RG{natu+$r*Z zd1{5}+VA|QjsrtNwZt`|BqgyV)hf9t6-Y4{85o-B8d&HWnS~fyS{YebnOJHY7+Dz@ z9gP2 RNC6cwc)I$ztaD0e0ssYVIVb=C literal 0 HcmV?d00001 diff --git a/app/www/js/app.js b/app/www/js/app.js index a313e16..a197ebe 100644 --- a/app/www/js/app.js +++ b/app/www/js/app.js @@ -59,7 +59,7 @@ angular.module('starter', ['ionic', 'starter.controllers']) } }) - .state('app.single', { + .state('app.travel', { url: '/travels/:travelId', views: { 'menuContent': { diff --git a/app/www/js/controllers.js b/app/www/js/controllers.js index 2c43a3c..d0cac2e 100644 --- a/app/www/js/controllers.js +++ b/app/www/js/controllers.js @@ -42,31 +42,83 @@ angular.module('starter.controllers', []) }) -.controller('TravelsCtrl', function($scope, $http) { - /*$scope.travels = [ - { id: 1, title: 'Travel1', description: "description for travel 1", owner: "user1", icon: "car" }, - { id: 2, title: 'Travel2', description: "description for travel 2", owner: "user2", icon: "station-wagon" }, - { id: 3, title: 'Travel3', description: "description for travel 3", owner: "user3", icon: "van" }, - { id: 4, title: 'Travel4', description: "description for travel 4", owner: "user1", icon: "station-wagon" }, - { id: 5, title: 'Travel5', description: "description for travel 5", owner: "user2", icon: "minivan" }, - { id: 6, title: 'Travel6', description: "description for travel 6", owner: "user3", icon: "lorry" }, - { id: 7, title: 'Travel7', description: "description for travel 7", owner: "user1", icon: "sport-car" }, - { id: 8, title: 'Travel8', description: "description for travel 8", owner: "user2", icon: "jeep" } -];*/ +.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout) { $scope.travels=""; $http.get('http://localhost:3000/api/travels') .success(function(data, status, headers,config){ - console.log('data success'); - console.log(data); // for browser console - $scope.travels = data; // for UI + console.log('data success'); + console.log(data); // for browser console + $scope.travels = data; // for UI }) .error(function(data, status, headers,config){ - console.log('data error'); + console.log('data error'); }) .then(function(result){ - travels = result.data; + travels = result.data; + }); + + + $scope.newtravel={}; + + // Create the login modal that we will use later + $ionicModal.fromTemplateUrl('templates/newtravel.html', { + scope: $scope + }).then(function(modal) { + $scope.modal = modal; }); + // Triggered in the login modal to close it + $scope.closeNewTravel = function() { + $scope.modal.hide(); + }; + + // Open the login modal + $scope.showNewTravel = function() { + $scope.modal.show(); + }; + // Perform the login action when the user submits the login form + $scope.doNewTravel = function() { + console.log('Doing new travel', $scope.newtravel); + $scope.newtravel.icon="lorry"; + $scope.newtravel.generateddate=$scope.newtravel.date; + $scope.newtravel.owner="user"; + console.log($scope.newtravel); + $http({ + url: 'http://localhost:3000/api/travels', + method: "POST", + data: $scope.newtravel + }) + .then(function(response) { + // success + console.log("response: "); + console.log(response); + $scope.newtravel._id=response.data._id; + $scope.travels.push($scope.newtravel); + }, + function(response) { // optional + // failed + }); + + // Simulate a login delay. Remove this and replace with your login + // code if using a login system + $timeout(function() { + $scope.closeNewTravel(); + }, 1000); + }; }) -.controller('TravelCtrl', function($scope, $stateParams) { - //$scope.travel=travels.get($stateParams.travelId); + +.controller('TravelCtrl', function($scope, $stateParams, $http) { + $scope.travel=""; + console.log($stateParams.travelId); + $http.get('http://localhost:3000/api/travels/'+$stateParams.travelId) + .success(function(data, status, headers,config){ + console.log('data success'); + console.log(data); // for browser console + $scope.travel = data; // for UI + }) + .error(function(data, status, headers,config){ + console.log('data error'); + }) + .then(function(result){ + travels = result.data; + }); }); diff --git a/app/www/templates/menu.html b/app/www/templates/menu.html index 1972f03..0f32aab 100644 --- a/app/www/templates/menu.html +++ b/app/www/templates/menu.html @@ -22,18 +22,26 @@ Login + + Last publications + + + Travels + Transport material + Available cars Ask for a car + Users diff --git a/app/www/templates/newtravel.html b/app/www/templates/newtravel.html new file mode 100644 index 0000000..1b8dc2f --- /dev/null +++ b/app/www/templates/newtravel.html @@ -0,0 +1,54 @@ + + + +

+ + New Travel {{newtravel.title}} +

+
+ + + + + + + + + + + + + + +
+ +
+
diff --git a/app/www/templates/travel.html b/app/www/templates/travel.html index ced3a66..f222bdc 100644 --- a/app/www/templates/travel.html +++ b/app/www/templates/travel.html @@ -1,5 +1,23 @@ -

{{travel.title}}

+
+ +

{{travel.title}}

+

{{travel.owner}}

+
+
+
{{travel.date | date:"dd/MM HH:mm a"}}
+

{{travel.from}} - {{travel.to}}

+

nº car seats: {{trave.seats}}

+

{{travel.description}}

+
+

+ {{travel.phone}} +

+ +

+ Ask to join +

+
diff --git a/app/www/templates/travels.html b/app/www/templates/travels.html index edab8a2..73e97a3 100644 --- a/app/www/templates/travels.html +++ b/app/www/templates/travels.html @@ -1,11 +1,19 @@ + diff --git a/server/controllers/travelController.js b/server/controllers/travelController.js index 26f6223..5702625 100644 --- a/server/controllers/travelController.js +++ b/server/controllers/travelController.js @@ -59,7 +59,8 @@ exports.addTravel = function(req, res) { date: req.body.date, generateddate: req.body.generateddate, seats: req.body.seats, - icon: req.body.icon + icon: req.body.icon, + phone: req.body.phone }); travel.save(function(err, travel) { diff --git a/server/models/travelModel.js b/server/models/travelModel.js index b234dad..2058f48 100644 --- a/server/models/travelModel.js +++ b/server/models/travelModel.js @@ -11,6 +11,7 @@ var travelSchema = new Schema({ date: { type: Date }, generateddate: { type: Date }, seats: { type: Number }, - icon: { type: String } + icon: { type: String }, + phone: { type: Number } }) module.exports = mongoose.model('travelModel', travelSchema); diff --git a/server/server.js b/server/server.js index 2172541..a3aad9a 100755 --- a/server/server.js +++ b/server/server.js @@ -71,6 +71,7 @@ apiRoutes.route('/travels') apiRoutes.route('/travels/:id') .get(travelCtrl.findById) +/* OJU AQUÏ TREC la verificació de token temporalment, per fer les proves des de l'app // route middleware to verify a token apiRoutes.use(function(req, res, next) { @@ -101,7 +102,7 @@ apiRoutes.use(function(req, res, next) { }); } -}); +});*/ apiRoutes.route('/users/:id') .put(userCtrl.updateUser)