Skip to content

Commit

Permalink
Merge commit '0c9ad212fb26eb8bff9d89b3bc7e291d6e88b2ab'
Browse files Browse the repository at this point in the history
* commit '0c9ad212fb26eb8bff9d89b3bc7e291d6e88b2ab':
  Fixed registrations endpoint to point the new endpoint created
  Added geolocation plugin to generate the right permissions
  Final fix for #85 and #88
  Fix for post getting stuck loading refs #88
  Fix for #85 and #90
  • Loading branch information
cdparra committed Dec 6, 2017
2 parents e35a1d6 + 0c9ad21 commit 6adadb2
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 19 deletions.
9 changes: 9 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
<variable name="XWALK_MODE" value="embedded" />
<variable name="XWALK_MULTIPLEAPK" value="true" />
</plugin>
<plugin name="cordova-plugin-mauron85-background-geolocation" spec="^2.3.1">
<variable name="ICON" value="@mipmap/icon" />
<variable name="SMALL_ICON" value="@mipmap/icon" />
<variable name="ACCOUNT_NAME" value="@string/app_name" />
<variable name="ACCOUNT_LABEL" value="@string/app_name" />
<variable name="ACCOUNT_TYPE" value="$PACKAGE_NAME.account" />
<variable name="CONTENT_AUTHORITY" value="$PACKAGE_NAME" />
<variable name="ALWAYS_USAGE_DESCRIPTION" value="This app requires background location tracking" />
</plugin>
<plugin name="cordova-plugin-sqlite-2" spec="^1.0.4" />
<plugin name="cordova-plugin-sslcertificatechecker" spec="^5.1.0" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"cordova-plugin-crosswalk-certificate": "^2.0.1",
"cordova-plugin-crosswalk-webview": "^2.3.0",
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-mauron85-background-geolocation": "^2.3.1",
"cordova-plugin-sqlite-2": "^1.0.4",
"cordova-plugin-sslcertificatechecker": "^5.1.0",
"cordova-plugin-whitelist": "^1.3.2",
Expand Down Expand Up @@ -73,7 +74,16 @@
"cordova-plugin-sqlite-2": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-sslcertificatechecker": {},
"cordova-plugin-advanced-http": {}
"cordova-plugin-advanced-http": {},
"cordova-plugin-mauron85-background-geolocation": {
"ICON": "@mipmap/icon",
"SMALL_ICON": "@mipmap/icon",
"ACCOUNT_NAME": "@string/app_name",
"ACCOUNT_LABEL": "@string/app_name",
"ACCOUNT_TYPE": "$PACKAGE_NAME.account",
"CONTENT_AUTHORITY": "$PACKAGE_NAME",
"ALWAYS_USAGE_DESCRIPTION": "This app requires background location tracking"
}
}
}
}
3 changes: 2 additions & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ angular.module('starter', [
})


.run(function ($ionicPlatform, $rootScope, $ionicModal, User, $state, $ionicHistory,
.run(function ($ionicPlatform, $rootScope, $ionicModal, User, $state, $ionicHistory,
Pouch, Post, Location, Visit, Inspection, $ionicSideMenuDelegate) {
cordova.plugin.http.setDataSerializer('json');
Pouch.createLocationNeighborhoodView();
Expand Down Expand Up @@ -159,6 +159,7 @@ angular.module('starter', [
}, function (isOpen) {
if (isOpen == true) {
User.current().then(function (user) {
user.data = JSON.parse(user.data)
$rootScope.user = user.data.user;
return User.save(user.data.user)
}).catch(function () {
Expand Down
48 changes: 34 additions & 14 deletions www/js/controllers/postsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,43 @@ angular.module('starter.controllers')

$scope.createPost = function() {
$ionicLoading.show({template: "<ion-spinner></ion-spinner><br>Creando post...", hideOnStateChange: true})


$scope.post.created_at = new Date()
doc_id = Post.documentID($scope.post.user, $scope.post)
Post.save(doc_id, $scope.post, {remote: true, synced: false}).then(function(response) {
return Post.get(doc_id).then(function(doc) {
$scope.posts.unshift(doc)
$scope.post = {};
$ionicLoading.hide().then(function() {
$scope.closeModal()
if (!$scope.post.user || !$scope.post.user.id) {
User.get().then(function(user) {
$scope.post.user_id = user.id
$scope.post.user = user
$scope.post.neighborhood_id = user.neighborhood.id
doc_id = Post.documentID($scope.post.user, $scope.post)
Post.save(doc_id, $scope.post, {remote: true, synced: false}).then(function(response) {
return Post.get(doc_id).then(function(doc) {
$scope.posts.unshift(doc)
$scope.post = {};
$ionicLoading.hide().then(function() {
$scope.closeModal()
})
})
}).catch(function(res) {
$scope.$emit(denguechat.error, res)
}).finally(function() {
$ionicLoading.hide()
})
})
}).catch(function(res) {
$scope.$emit(denguechat.error, res)
}).finally(function() {
$ionicLoading.hide()
})
} else {
doc_id = Post.documentID($scope.post.user, $scope.post)
Post.save(doc_id, $scope.post, {remote: true, synced: false}).then(function(response) {
return Post.get(doc_id).then(function(doc) {
$scope.posts.unshift(doc)
$scope.post = {};
$ionicLoading.hide().then(function() {
$scope.closeModal()
})
})
}).catch(function(res) {
$scope.$emit(denguechat.error, res)
}).finally(function() {
$ionicLoading.hide()
})
}
}


Expand Down
2 changes: 2 additions & 0 deletions www/js/controllers/profileCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ angular.module('starter.controllers')
$ionicLoading.show({hideOnStateChange: true})

User.current().then(function(user) {
user.data = JSON.parse(user.data)
$scope.user = user.data.user;
return User.save(user.data.user)
}).catch(function(res) {
console.log("Error when getting current user: "+JSON.stringify(res))
$scope.$emit(denguechat.error, res)
}).finally(function() {
$ionicLoading.hide()
Expand Down
8 changes: 5 additions & 3 deletions www/js/services/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ angular.module('starter.services')
},

create: function (username, password) {
return cordovaHTTP.post(denguechat.env.baseURL + 'registrations', {
username: username,
password: password
return cordovaHTTP.post(denguechat.env.baseURL + 'sessions/registrations', {
user: {
username: username,
password: password
},
}, { 'content-type': 'application/json'});
},

Expand Down

0 comments on commit 6adadb2

Please sign in to comment.