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 0000000..cfdf84b Binary files /dev/null and b/app/www/img/box.png differ diff --git a/app/www/img/community.png b/app/www/img/community.png new file mode 100644 index 0000000..44d6eba Binary files /dev/null and b/app/www/img/community.png differ diff --git a/app/www/img/from-to.png b/app/www/img/from-to.png new file mode 100644 index 0000000..92b2cac Binary files /dev/null and b/app/www/img/from-to.png differ diff --git a/app/www/img/road.png b/app/www/img/road.png new file mode 100644 index 0000000..70ddd48 Binary files /dev/null and b/app/www/img/road.png differ diff --git a/app/www/img/rss-symbol.png b/app/www/img/rss-symbol.png new file mode 100644 index 0000000..46d2ed6 Binary files /dev/null and b/app/www/img/rss-symbol.png differ diff --git a/app/www/img/smartphone.png b/app/www/img/smartphone.png new file mode 100644 index 0000000..35bacf1 Binary files /dev/null and b/app/www/img/smartphone.png differ 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)