Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #1

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- '8'
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: grunt build
15 changes: 15 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@
}(document, 'script', 'facebook-jssdk'));
</script>

<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/4.6.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyCLzfwq2Yh4Ete40CveLYO8yEUE-m8bNug",
authDomain: "hortalivre-1309.firebaseapp.com",
databaseURL: "https://hortalivre-1309.firebaseio.com",
projectId: "hortalivre-1309",
storageBucket: "",
messagingSenderId: "784880436032"
};
firebase.initializeApp(config);
</script>

<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
Expand Down
43 changes: 27 additions & 16 deletions app/scripts/controllers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ angular.module('hortalivreApp')
var user_fb_data = {};

UserApi.authFacebook(function(result) {
user_fb_data.email = result.user_fb_data.email;
user_fb_data.accessToken = result.access_token;
user_fb_data.fbID = result.user_fb_data.id;
user_fb_data.displayName = result.displayName;
user_fb_data.email = result.email;
user_fb_data.fbID = result.uid;
user_fb_data.photo = result.photoURL;
user_fb_data.last_access = new Date().getTime();

$scope.user_fb_data = user_fb_data;

Expand All @@ -79,22 +81,31 @@ angular.module('hortalivreApp')

params = $scope.user_fb_data;

UserApi.loginFb(params, function(result) {
if (result.status === 200) {
LocalStorage.SaveUser(result.data);
LocalStorage.SaveUser(params);

$rootScope.user_logged = true; // altera o header
$scope.$emit('user_created');
$scope.progressbar.complete();
$rootScope.user_logged = true; // altera o header
$scope.$emit('user_created');
$scope.progressbar.complete();

$location.path('/mapa');
} else {
$scope.error.status = result.status;
$scope.error.type = 'create-user';
$location.path('/mapa');

$scope.progressbar.complete();
}
})

// UserApi.loginFb(params, function(result) {
// if (result.status === 200) {
// LocalStorage.SaveUser(result.data);

// $rootScope.user_logged = true; // altera o header
// $scope.$emit('user_created');
// $scope.progressbar.complete();

// $location.path('/mapa');
// } else {
// $scope.error.status = result.status;
// $scope.error.type = 'create-user';

// $scope.progressbar.complete();
// }
// })
});
// ====

Expand Down
81 changes: 48 additions & 33 deletions app/scripts/controllers/mapa.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,49 +347,64 @@ angular.module('hortalivreApp')
};

GardenApi.All(function(response) {
// console.warn('tudo -< ', response);

var gardens, markets;

if (response.status === 200) {
gardens = response.data.gardens;
markets = response.data.markets;
gardens = response.data;
// markets = response.data.markets;

// console.warn('ds', );

Object.keys(gardens).map((i) => {
console.warn(gardens[i]);

if (gardens[i] && gardens[i].veggie.location) {

if (gardens.length > 0){
angular.forEach(gardens, function(i) {
arr_gardens.push({
id: i._id,
lat: i.geolocation[1],
lng: i.geolocation[0],
garden: i.garden,
id: gardens[i].id,
lat: gardens[i].veggie.location[0],
lng: gardens[i].veggie.location[1],
garden: gardens[i].garden,
type: 'garden',
email: i.email,
fullName: i.fullName
address: gardens[i].address,
fullName: gardens[i].veggie.name
});
});
} else {
// console.warn('nenhuma horta');
}

if (markets.length > 0){
angular.forEach(markets, function(i) {
arr_markets.push({
id: i._id,
title: i.title,
lat: i.geolocation[1],
lng: i.geolocation[0],
rating_value: i.rating_value,
type: i.type,
link: i.link
});
});
} else {
// console.warn('nenhuma feira');
}
}

all_arr = arr_gardens.concat(arr_markets);
})

// if (gardens){
// angular.forEach(Object.keys(gardens), function(i) {
// console.warn(i);

// });
// } else {
// // console.warn('nenhuma horta');
// }

// if (markets.length > 0){
// angular.forEach(markets, function(i) {
// arr_markets.push({
// id: i._id,
// title: i.title,
// lat: i.geolocation[1],
// lng: i.geolocation[0],
// rating_value: i.rating_value,
// type: i.type,
// link: i.link
// });
// });
// } else {
// // console.warn('nenhuma feira');
// }

// all_arr = arr_gardens.concat(arr_markets);

$scope.arr_gardens = arr_gardens;
$scope.arr_markets = arr_markets;
$scope.all_arr = all_arr;
$scope.arr_markets = arr_gardens;
$scope.all_arr = arr_gardens;

// console.warn('todos os arrays:', all_arr);

Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/gardenapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ angular.module('hortalivreApp')
var apiUrl = ApiConfig.API_URL;

obj.All = function(callback) {
$http.get(apiUrl + '/api/v1/markets/', { headers: { 'Content-Type': 'application/json' }}).then(function (data) {
callback(data);
$http.get('https://form-location-jsday-recife.firebaseio.com/veggies.json').then(function (result) {
callback(result);
}, function (error) {
callback(error);
});
Expand Down
29 changes: 18 additions & 11 deletions app/scripts/services/userapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,26 @@ angular.module('hortalivreApp')

obj.authFacebook = function(callback) {
var params = {};
var fb_provider = new firebase.auth.FacebookAuthProvider();

$facebook.login().then(function(data) {
params.access_token = data.authResponse.accessToken;

if (data.status === 'connected') {
$facebook.api('me', { fields: 'name,email,gender,ids_for_business,picture' }).then(function(response) {
params.user_fb_data = response;
callback(params);
});
} else {
console.warn('Não conseguimos nos conecta ao facebook, tente novamente em alguns instantes!');
}
firebase.auth().signInWithPopup(fb_provider).then((result) => {
callback(result.user);
}).catch((err) => {
console.error(err);
});

// $facebook.login().then(function(data) {
// params.access_token = data.authResponse.accessToken;

// if (data.status === 'connected') {
// $facebook.api('me', { fields: 'name,email,gender,ids_for_business,picture' }).then(function(response) {
// params.user_fb_data = response;
// callback(params);
// });
// } else {
// console.warn('Não conseguimos nos conecta ao facebook, tente novamente em alguns instantes!');
// }
// });
};

obj.createFb = function(data, callback) {
Expand Down
Loading