From a6950029b0a62a438d26c6c88b982a604475aaa5 Mon Sep 17 00:00:00 2001
From: nau
Date: Sat, 27 Aug 2016 22:46:07 +0200
Subject: [PATCH] pull refreshing travels feed implemented
---
app/www/js/controllers.js | 60 ++++++++++++++++++++------
app/www/templates/newaskingtravel.html | 11 ++---
app/www/templates/travel.html | 15 ++++---
app/www/templates/travels.html | 10 ++++-
4 files changed, 70 insertions(+), 26 deletions(-)
diff --git a/app/www/js/controllers.js b/app/www/js/controllers.js
index 5b26447..c90aea1 100644
--- a/app/www/js/controllers.js
+++ b/app/www/js/controllers.js
@@ -44,20 +44,25 @@ angular.module('starter.controllers', [])
.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
- })
- .error(function(data, status, headers,config){
- console.log('data error');
- })
- .then(function(result){
- travels = result.data;
- });
+ $scope.doRefresh = function() {
+ $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
+ $scope.$broadcast('scroll.refreshComplete');//refresher stop
+ })
+ .error(function(data, status, headers,config){
+ console.log('data error');
+ $scope.$broadcast('scroll.refreshComplete');//refresher stop
+ })
+ .then(function(result){
+ travels = result.data;
+ });
+ };
+
$scope.newtravel={};
// Create the login modal that we will use later
@@ -123,6 +128,37 @@ angular.module('starter.controllers', [])
$scope.closeNewOfferingTravel();
}, 1000);
};
+
+ $scope.doNewAskingTravel = function() {
+ console.log('Doing new travel', $scope.newtravel);
+ $scope.newtravel.icon="lorry";
+ $scope.newtravel.generateddate=$scope.newtravel.date;
+ $scope.newtravel.owner="user";
+
+ $scope.newtravel.modality="asking";
+ 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.closeNewAskingTravel();
+ }, 1000);
+ };
})
.controller('TravelCtrl', function($scope, $stateParams, $http) {
diff --git a/app/www/templates/newaskingtravel.html b/app/www/templates/newaskingtravel.html
index f18f0dc..088e8b2 100644
--- a/app/www/templates/newaskingtravel.html
+++ b/app/www/templates/newaskingtravel.html
@@ -23,12 +23,12 @@
- Can carry package
+ Need to carry package
-
- Collectivized car
-
-
{{travel.description}}
@@ -26,7 +30,8 @@
- Ask to join
+ Ask to join
+ Offer car
diff --git a/app/www/templates/travels.html b/app/www/templates/travels.html
index edb1019..eb22e31 100644
--- a/app/www/templates/travels.html
+++ b/app/www/templates/travels.html
@@ -1,18 +1,24 @@
-
+
+