Browse Source

implemented infinite scroll on travels, user avatar show image, added username on travels list

master
arnaucode 7 years ago
parent
commit
72111df0d3
43 changed files with 464 additions and 351 deletions
  1. BIN
      www/img/asking.png
  2. BIN
      www/img/avatars/chameleon.png
  3. BIN
      www/img/avatars/clown-fish.png
  4. BIN
      www/img/avatars/duck.png
  5. BIN
      www/img/avatars/owl.png
  6. BIN
      www/img/avatars/penguin.png
  7. BIN
      www/img/avatars/siberian-husky.png
  8. BIN
      www/img/avatars/sloth.png
  9. BIN
      www/img/avatars/tiger.png
  10. BIN
      www/img/avatars/toucan.png
  11. BIN
      www/img/collectivized.png
  12. BIN
      www/img/comment.png
  13. BIN
      www/img/community.png
  14. BIN
      www/img/fav.png
  15. BIN
      www/img/foucault.jpg
  16. BIN
      www/img/from-to.png
  17. BIN
      www/img/header.png
  18. BIN
      www/img/header_background.png
  19. BIN
      www/img/help.png
  20. BIN
      www/img/ionic.png
  21. BIN
      www/img/join.png
  22. BIN
      www/img/localization.png
  23. BIN
      www/img/newasking.png
  24. BIN
      www/img/newoffering.png
  25. BIN
      www/img/newpackage.png
  26. BIN
      www/img/notification.png
  27. BIN
      www/img/offering.png
  28. BIN
      www/img/package.png
  29. BIN
      www/img/road.png
  30. BIN
      www/img/rss-symbol.png
  31. BIN
      www/img/settings.png
  32. BIN
      www/img/smartphone.png
  33. BIN
      www/img/telegram.png
  34. BIN
      www/img/unlike.png
  35. BIN
      www/img/users.png
  36. +222
    -181
      www/js/travel.js
  37. +31
    -17
      www/js/travels.js
  38. +143
    -102
      www/js/user.js
  39. +9
    -0
      www/templates/imgView.html
  40. +17
    -19
      www/templates/notifications.html
  41. +10
    -9
      www/templates/travel.html
  42. +10
    -2
      www/templates/travels.html
  43. +22
    -21
      www/templates/user.html

BIN
www/img/asking.png

Before After
Width: 512  |  Height: 512  |  Size: 15 KiB

BIN
www/img/avatars/chameleon.png

Before After
Width: 512  |  Height: 512  |  Size: 15 KiB

BIN
www/img/avatars/clown-fish.png

Before After
Width: 512  |  Height: 512  |  Size: 21 KiB

BIN
www/img/avatars/duck.png

Before After
Width: 512  |  Height: 512  |  Size: 9.6 KiB

BIN
www/img/avatars/owl.png

Before After
Width: 512  |  Height: 512  |  Size: 15 KiB

BIN
www/img/avatars/penguin.png

Before After
Width: 512  |  Height: 512  |  Size: 14 KiB

BIN
www/img/avatars/siberian-husky.png

Before After
Width: 512  |  Height: 512  |  Size: 19 KiB

BIN
www/img/avatars/sloth.png

Before After
Width: 512  |  Height: 512  |  Size: 15 KiB

BIN
www/img/avatars/tiger.png

Before After
Width: 512  |  Height: 512  |  Size: 22 KiB

BIN
www/img/avatars/toucan.png

Before After
Width: 512  |  Height: 512  |  Size: 11 KiB

BIN
www/img/collectivized.png

Before After
Width: 32  |  Height: 32  |  Size: 1.7 KiB

BIN
www/img/comment.png

Before After
Width: 32  |  Height: 32  |  Size: 754 B

BIN
www/img/community.png

Before After
Width: 32  |  Height: 32  |  Size: 1.0 KiB

BIN
www/img/fav.png

Before After
Width: 32  |  Height: 32  |  Size: 722 B

BIN
www/img/foucault.jpg

Before After
Width: 223  |  Height: 226  |  Size: 6.5 KiB

BIN
www/img/from-to.png

Before After
Width: 32  |  Height: 32  |  Size: 1.2 KiB

BIN
www/img/header.png

Before After
Width: 1300  |  Height: 975  |  Size: 764 KiB

BIN
www/img/header_background.png

Before After
Width: 1300  |  Height: 975  |  Size: 767 KiB

BIN
www/img/help.png

Before After
Width: 32  |  Height: 32  |  Size: 701 B

BIN
www/img/ionic.png

Before After
Width: 128  |  Height: 128  |  Size: 4.6 KiB

BIN
www/img/join.png

Before After
Width: 32  |  Height: 32  |  Size: 291 B

BIN
www/img/localization.png

Before After
Width: 32  |  Height: 32  |  Size: 891 B

BIN
www/img/newasking.png

Before After
Width: 512  |  Height: 512  |  Size: 46 KiB

BIN
www/img/newoffering.png

Before After
Width: 512  |  Height: 512  |  Size: 41 KiB

BIN
www/img/newpackage.png

Before After
Width: 512  |  Height: 512  |  Size: 66 KiB

BIN
www/img/notification.png

Before After
Width: 32  |  Height: 32  |  Size: 797 B

BIN
www/img/offering.png

Before After
Width: 512  |  Height: 512  |  Size: 9.8 KiB

BIN
www/img/package.png

Before After
Width: 32  |  Height: 32  |  Size: 555 B

BIN
www/img/road.png

Before After
Width: 32  |  Height: 32  |  Size: 1.1 KiB

BIN
www/img/rss-symbol.png

Before After
Width: 32  |  Height: 32  |  Size: 1.2 KiB

BIN
www/img/settings.png

Before After
Width: 32  |  Height: 32  |  Size: 1.3 KiB

BIN
www/img/smartphone.png

Before After
Width: 32  |  Height: 32  |  Size: 893 B

BIN
www/img/telegram.png

Before After
Width: 32  |  Height: 32  |  Size: 1013 B

BIN
www/img/unlike.png

Before After
Width: 32  |  Height: 32  |  Size: 793 B

BIN
www/img/users.png

Before After
Width: 32  |  Height: 32  |  Size: 922 B

+ 222
- 181
www/js/travel.js

@ -1,246 +1,287 @@
angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet'])
.controller('TravelCtrl', function($scope, $stateParams, $http,
$ionicModal, $ionicLoading, $ionicPopup, $filter,
leafletData, leafletBoundsHelpers) {
.controller('TravelCtrl', function($scope, $stateParams, $http,
$ionicModal, $ionicLoading, $ionicPopup, $filter,
leafletData, leafletBoundsHelpers) {
$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
$scope.center= {
/*lat: 0,
lng: 0,
zoom: 1*/
$scope.center = {
/*lat: 0,
lng: 0,
zoom: 1*/
};
$scope.bounds={};
$scope.markers=[];
$scope.tiles= {
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
options: {
attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}
$scope.bounds = {};
$scope.markers = [];
$scope.tiles = {
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
options: {
attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}
};
$scope.travel={};
$scope.travel = {};
$scope.doRefresh = function() {
/* travels refresh: */
$http.get(urlapi + 'travels/id/' + $stateParams.travelid)
.then(function(data){
console.log('data success travels');
console.log(data); // for browser console
$scope.travel = data.data; // for UI
$scope.markers=[];
$scope.markers.push({
lat: Number($scope.travel.from.lat),
lng: Number($scope.travel.from.long),
message: $scope.travel.from.name
});
$scope.markers.push({
lat: Number($scope.travel.to.lat),
lng: Number($scope.travel.to.long),
message: $scope.travel.to.name
});
$scope.center= {
lat: (Number($scope.travel.from.lat)+Number($scope.travel.to.lat))/2,
lng: (Number($scope.travel.from.long)+Number($scope.travel.to.long))/2,
zoom: 4
};
$scope.$broadcast('scroll.refreshComplete');//refresher stop
}, function(data){
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
$http.get(urlapi + 'travels/id/' + $stateParams.travelid)
.then(function(data) {
console.log('data success travels');
console.log(data); // for browser console
$scope.travel = data.data; // for UI
$scope.markers = [];
$scope.markers.push({
lat: Number($scope.travel.from.lat),
lng: Number($scope.travel.from.long),
message: $scope.travel.from.name
});
$scope.markers.push({
lat: Number($scope.travel.to.lat),
lng: Number($scope.travel.to.long),
message: $scope.travel.to.name
});
$scope.center = {
lat: (Number($scope.travel.from.lat) + Number($scope.travel.to.lat)) / 2,
lng: (Number($scope.travel.from.long) + Number($scope.travel.to.long)) / 2,
zoom: 4
};
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
}, function(data) {
console.log('data error');
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
$ionicLoading.show({
template: 'Error connecting server',
noBackdrop: true,
duration: 2000
});
});
};
$scope.doRefresh();
$scope.deleteTravel = function(){
var confirmPopup = $ionicPopup.confirm({
title: 'Deleting publication',
template: 'Are you sure you want to delete <b>'+ $scope.travel.title+'</b>?'
});
confirmPopup.then(function(res) {
if(res) {
console.log('You are sure');
console.log("delete travel: " + $stateParams.travelid);
$http({
url: urlapi + '/travels/id/modify/' + $stateParams.travelid,
method: "DELETE"
})
.then(function(response) {
console.log(response);
$scope.travels=response.data;
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));
},
function(response) { // optional
// failed
});
} else {
console.log('You are not sure');
}
});
$scope.deleteTravel = function() {
var confirmPopup = $ionicPopup.confirm({
title: 'Deleting publication',
template: 'Are you sure you want to delete <b>' + $scope.travel.title + '</b>?'
});
confirmPopup.then(function(res) {
if (res) {
console.log('You are sure');
console.log("delete travel: " + $stateParams.travelid);
$http({
url: urlapi + '/travels/id/modify/' + $stateParams.travelid,
method: "DELETE"
})
.then(function(response) {
console.log(response);
$scope.travels = response.data;
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));
},
function(response) { // optional
// failed
});
} else {
console.log('You are not sure');
}
});
};
$scope.joinTravel = function(){
$http({
url: urlapi + 'travels/join/'+ $stateParams.travelid,
method: "POST",
data: {}
$scope.joinTravel = function() {
$http({
url: urlapi + 'travels/join/' + $stateParams.travelid,
method: "POST",
data: {}
})
.then(function(data) {
console.log("data: ");
console.log(data);
if(data.data.success==false){
$ionicLoading.show({template: 'Error on unjoin', noBackdrop: true, duration: 2000});
}else{
$scope.travel=data.data;
if (data.data.success == false) {
$ionicLoading.show({
template: 'Error on unjoin',
noBackdrop: true,
duration: 2000
});
} else {
$scope.travel = data.data;
}
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$scope.unjoinTravel = function(){
$http({
url: urlapi + 'travels/unjoin/'+ $stateParams.travelid,
method: "POST",
data: {}
$scope.unjoinTravel = function() {
$http({
url: urlapi + 'travels/unjoin/' + $stateParams.travelid,
method: "POST",
data: {}
})
.then(function(data) {
console.log("data: ");
console.log(data);
if(data.data.success==false){
$ionicLoading.show({template: 'Error on unjoin', noBackdrop: true, duration: 2000});
}else{
$scope.travel=data.data;
if (data.data.success == false) {
$ionicLoading.show({
template: 'Error on unjoin',
noBackdrop: true,
duration: 2000
});
} else {
$scope.travel = data.data;
}
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$scope.declineJoin = function(joinPetition){
$http({
url: urlapi + 'travels/declineJoin/'+ $stateParams.travelid,
method: "POST",
data: {userid: joinPetition._id}
$scope.declineJoin = function(joinPetition) {
$http({
url: urlapi + 'travels/declineJoin/' + $stateParams.travelid,
method: "POST",
data: {
userid: joinPetition._id
}
})
.then(function(data) {
console.log("data: ");
console.log(data);
if(data.data.success==false){
$ionicLoading.show({template: 'Error on declining', noBackdrop: true, duration: 2000});
}else{
$scope.travel=data.data;
console.log("success");
if (data.data.success == false) {
$ionicLoading.show({
template: 'Error on declining',
noBackdrop: true,
duration: 2000
});
} else {
$scope.travel = data.data;
console.log("success");
}
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$scope.acceptJoin = function(joinPetition){
$http({
url: urlapi + 'travels/acceptJoin/'+ $stateParams.travelid,
method: "POST",
data: {userid: joinPetition._id}
$scope.acceptJoin = function(joinPetition) {
$http({
url: urlapi + 'travels/acceptJoin/' + $stateParams.travelid,
method: "POST",
data: {
userid: joinPetition._id
}
})
.then(function(data) {
console.log("data: ");
console.log(data);
if(data.data.success==false){
$ionicLoading.show({template: 'Error on accepting', noBackdrop: true, duration: 2000});
}else{
$scope.travel=data.data;
console.log("success");
if (data.data.success == false) {
$ionicLoading.show({
template: 'Error on accepting',
noBackdrop: true,
duration: 2000
});
} else {
$scope.travel = data.data;
console.log("success");
}
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$scope.leaveTravel = function(){
$http({
url: urlapi + 'travels/leave/'+ $stateParams.travelid,
method: "POST",
data: {}
})
.then(function(data) {
console.log("data: ");
console.log(data);
if(data.data.success==false){
$ionicLoading.show({template: 'Error on unjoin', noBackdrop: true, duration: 2000});
}else{
$scope.travel=data.data;
}
},
function(response) { // optional
$scope.leaveTravel = function() {
var confirmPopup = $ionicPopup.confirm({
title: 'Leaving travel',
template: 'Are you sure you want to leave <b>' + $scope.travel.title + '</b>?'
});
confirmPopup.then(function(res) {
if (res) {
$http({
url: urlapi + 'travels/leave/' + $stateParams.travelid,
method: "POST",
data: {}
})
.then(function(data) {
console.log("data: ");
console.log(data);
if (data.data.success == false) {
$ionicLoading.show({
template: 'Error on unjoin',
noBackdrop: true,
duration: 2000
});
} else {
$scope.travel = data.data;
}
},
function(response) { // optional
// failed
});
});
} else {
console.log('You are not sure');
}
});
};
/* adding comment */
$scope.doingNewComment=false;
$scope.newComment={};
$scope.doingNewComment = false;
$scope.newComment = {};
$scope.showNewComment = function() {
$scope.doingNewComment=true;
$scope.doingNewComment = true;
};
$scope.closeNewComment = function() {
$scope.doingNewComment=false;
$scope.doingNewComment = false;
};
$scope.doNewComment = function() {
/*$scope.newComment.commentUserId=localStorage.getItem("c_userid");
$scope.newComment.commentUsername=localStorage.getItem("c_username");
$scope.newComment.commentAvatar=localStorage.getItem("c_avatar");*/
console.log($scope.newComment);
$http({
url: urlapi + 'travels/'+ $stateParams.travelId+'/comment',
/*$scope.newComment.commentUserId=localStorage.getItem("c_userid");
$scope.newComment.commentUsername=localStorage.getItem("c_username");
$scope.newComment.commentAvatar=localStorage.getItem("c_avatar");*/
console.log($scope.newComment);
$http({
url: urlapi + 'travels/' + $stateParams.travelId + '/comment',
method: "POST",
data: $scope.newComment
})
.then(function(response) {
// success
console.log("newComment added to server: " + response);
console.log(response);
$scope.travels=response.data;
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));
$scope.travel = $filter('filter')($scope.travels, $stateParams.travelId, true)[0];
if(response.data.success==false){
$ionicLoading.show({ template: 'failed to generate new asking package', noBackdrop: true, duration: 2000 });
}
},
function(response) { // optional
// failed
});
$scope.closeNewComment();
// success
console.log("newComment added to server: " + response);
console.log(response);
$scope.travels = response.data;
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));
$scope.travel = $filter('filter')($scope.travels, $stateParams.travelId, true)[0];
if (response.data.success == false) {
$ionicLoading.show({
template: 'failed to generate new asking package',
noBackdrop: true,
duration: 2000
});
}
},
function(response) { // optional
// failed
});
$scope.closeNewComment();
};
$scope.userHasJoined = function(myArray, searchTerm) {
//console.log(myArray+", "+searchTerm);
if(myArray)
{
for(var i = 0, len = myArray.length; i < len; i++) {
//console.log(myArray[i] + " - " + searchTerm);
if (myArray[i]._id === searchTerm){
//console.log("i: " + i);
return i;
}
}
if (myArray) {
for (var i = 0, len = myArray.length; i < len; i++) {
//console.log(myArray[i] + " - " + searchTerm);
if (myArray[i]._id === searchTerm) {
//console.log("i: " + i);
return i;
}
}
//console.log("i: -1");
return -1;
}
//console.log("i: -1");
return -1;
};
});
});

+ 31
- 17
www/js/travels.js

@ -1,32 +1,46 @@
angular.module('app.travels', ['pascalprecht.translate'])
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
$scope.loadMorePagination = true;
$scope.travels=[];
$scope.page=0;
$scope.travels = [];
$scope.page = 0;
$scope.doRefresh = function() {
/* travels refresh: */
$http.get(urlapi + 'travels?page=' + $scope.page)
.then(function(data){
console.log('data success travels');
console.log(data); // for browser console
//$scope.travels = data.data; // for UI
$scope.travels=$scope.travels.concat(data.data);
$scope.$broadcast('scroll.refreshComplete');//refresher stop
$http.get(urlapi + 'travels?page=' + $scope.page)
.then(function(data) {
console.log('data success travels');
console.log(data); // for browser console
//$scope.travels = data.data; // for UI
$scope.travels = $scope.travels.concat(data.data);
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
$scope.$broadcast('scroll.infiniteScrollComplete');
if (data.data.length < 1) {
console.log("setting loadMorePagination to false");
$scope.loadMorePagination = false;
}
}, function(data){
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
}, function(data) {
console.log('data error');
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
$ionicLoading.show({
template: 'Error connecting server',
noBackdrop: true,
duration: 2000
});
});
};
$scope.doRefresh();
$scope.paginationNext = function(){
$scope.paginationNext = function() {
if ($scope.loadMorePagination == true) {
$scope.page++;
console.log($scope.page);
$scope.doRefresh();
}else{
console.log("limit pagination reached");
$scope.$broadcast('scroll.infiniteScrollComplete');
}
};
});
});

+ 143
- 102
www/js/user.js

@ -1,124 +1,135 @@
angular.module('app.user', ['pascalprecht.translate'])
.controller('UserCtrl', function($scope, $stateParams, $http,
$ionicLoading, $filter, $ionicModal) {
.controller('UserCtrl', function($scope, $stateParams, $http,
$ionicLoading, $filter, $ionicModal) {
$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
$scope.user={};
$scope.doRefresh = function(){
$http.get(urlapi + 'users/id/'+$stateParams.userid)
.then(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
$scope.user = data.data; // for UI
if($scope.storageuser._id==$scope.user._id)
{
localStorage.setItem("cim_app_userdata", JSON.stringify(data.data));
}
$scope.$broadcast('scroll.refreshComplete');//refresher stop
},function(data, status, headers,config){
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
$scope.user = {};
$scope.doRefresh = function() {
$http.get(urlapi + 'users/id/' + $stateParams.userid)
.then(function(data, status, headers, config) {
console.log('data success');
console.log(data); // for browser console
$scope.user = data.data; // for UI
if ($scope.storageuser._id == $scope.user._id) {
localStorage.setItem("cim_app_userdata", JSON.stringify(data.data));
}
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
}, function(data, status, headers, config) {
console.log('data error');
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
});
};
$scope.doRefresh();
$scope.likeUser = function(){
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/id/like/'+ $scope.user._id,
method: "POST",
data: {}
$scope.likeUser = function() {
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/id/like/' + $scope.user._id,
method: "POST",
data: {}
})
.then(function(data) {
// success
if(data.data.success==false){
console.log("failed");
$ionicLoading.show({template: 'Error on like', noBackdrop: true, duration: 2000});
}else{
$scope.user = data.data; // for UI
if (data.data.success == false) {
console.log("failed");
$ionicLoading.show({
template: 'Error on like',
noBackdrop: true,
duration: 2000
});
} else {
$scope.user = data.data; // for UI
}
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$scope.unlikeUser = function(){
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/id/unlike/'+ $scope.user._id,
method: "POST",
data: {}
$scope.unlikeUser = function() {
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/id/unlike/' + $scope.user._id,
method: "POST",
data: {}
})
.then(function(data) {
// success
if(data.data.success==false){
console.log("failed");
$ionicLoading.show({template: 'Error on unlike', noBackdrop: true, duration: 2000});
}else{
$scope.user = data.data; // for UI
if (data.data.success == false) {
console.log("failed");
$ionicLoading.show({
template: 'Error on unlike',
noBackdrop: true,
duration: 2000
});
} else {
$scope.user = data.data; // for UI
}
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$scope.favUser = function(){
$scope.newfav={
//travelId: $stateParams.travelId,
/*userId: localStorage.getItem("c_userid"),
username: localStorage.getItem("c_username"),
avatar: localStorage.getItem("c_avatar")*/
};
$scope.user.favs.push($scope.newfav);//al unfav no cal fer aquest simulacre pq ja no existeix a l'array i no el resta dos cops en cas de que cliquin dos cops
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/'+ $scope.user._id+'/fav',
method: "POST",
data: $scope.newfav
$scope.favUser = function() {
$scope.newfav = {
//travelId: $stateParams.travelId,
/*userId: localStorage.getItem("c_userid"),
username: localStorage.getItem("c_username"),
avatar: localStorage.getItem("c_avatar")*/
};
$scope.user.favs.push($scope.newfav); //al unfav no cal fer aquest simulacre pq ja no existeix a l'array i no el resta dos cops en cas de que cliquin dos cops
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/' + $scope.user._id + '/fav',
method: "POST",
data: $scope.newfav
})
.then(function(response) {
// success
console.log("response: ");
console.log(response);
// success
console.log("response: ");
console.log(response);
$scope.users=response.data;
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.user = $filter('filter')($scope.users, {username: $stateParams.username}, true)[0];
$scope.users = response.data;
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.user = $filter('filter')($scope.users, {
username: $stateParams.username
}, true)[0];
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$scope.unfavUser = function(){
console.log("unfav");
$scope.unfav={
/*userId: localStorage.getItem("c_userid"),
username: localStorage.getItem("c_username"),
avatar: localStorage.getItem("c_avatar")*/
};
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/'+ $scope.user._id+'/unfav',
method: "POST",
data: $scope.unfav
$scope.unfavUser = function() {
console.log("unfav");
$scope.unfav = {
/*userId: localStorage.getItem("c_userid"),
username: localStorage.getItem("c_username"),
avatar: localStorage.getItem("c_avatar")*/
};
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/' + $scope.user._id + '/unfav',
method: "POST",
data: $scope.unfav
})
.then(function(response) {
// success
console.log("response: ");
console.log(response);
// success
console.log("response: ");
console.log(response);
$scope.users=response.data;
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.user = $filter('filter')($scope.users, {username: $stateParams.username}, true)[0];
$scope.users = response.data;
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.user = $filter('filter')($scope.users, {
username: $stateParams.username
}, true)[0];
},
function(response) { // optional
// failed
});
},
function(response) { // optional
// failed
});
};
$ionicModal.fromTemplateUrl('templates/favsList.html', {
@ -129,21 +140,51 @@ angular.module('app.user', ['pascalprecht.translate'])
$scope.closeModalFavsList = function() {
$scope.modalFavsList.hide();
};
$scope.showFavsList = function(){
$scope.showFavsList = function() {
$scope.modalFavsList.show();
};
$scope.closeModalAndGoUser = function(){
$scope.closeModalAndGoUser = function() {
$scope.modalFavsList.hide();
};
$scope.arrayObjectIndexOf = function(myArray, searchTerm) {
if(myArray){
for(var i = 0, len = myArray.length; i < len; i++) {
if (myArray[i] === searchTerm){
return i;
}
}
if (myArray) {
for (var i = 0, len = myArray.length; i < len; i++) {
if (myArray[i] === searchTerm) {
return i;
}
}
return -1;
}
return -1;
};
//show image
$ionicModal.fromTemplateUrl('templates/imgView.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
// Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
$scope.showImg = function() {
console.log("show image");
$scope.openModal();
};
});
});

+ 9
- 0
www/templates/imgView.html

@ -0,0 +1,9 @@
<ion-view view-title="{{'Users' | translate}}">
<ion-content>
<ion-header-bar class="bar bar-header">
<a class="button" ng-click="modal.hide()">Back</a>
<h1 class="title">{{user.username}} profile image</h1>
</ion-header-bar>
<img ng-click="modal.hide()" ng-src="{{user.avatar}}" style="width:100%;" />
</ion-content>
</ion-view>

+ 17
- 19
www/templates/notifications.html

@ -3,25 +3,23 @@
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()">
</ion-refresher>
<div ng-show="!notifications[0]" class="item">
No notifications yet
No notifications yet
</div>
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='pendent'"
class="item item-icon-left c_deepPurple100" href="#/app/{{notification.link}}">
<i ng-show="notification.state=='pendent'" class="icon ion-android-notifications-none o_text_purple600"></i>
<h2>{{notification.message}}</h2>
<div class="item-note text-right">
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
<div class="o_text_purple600">{{notification.date | date:"HH:mm:ss"}}</div>
</div>
</a>
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='viewed'"
class="item item-icon-left" href="#/app/{{notification.link}}">
<i ng-show="notification.state=='viewed'" class="icon ion-android-notifications-none"></i>
<h2>{{notification.message}}</h2>
<div class="item-note text-right">
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
<div class="o_text_purple600">{{notification.date | date:"HH:mm:ss"}}</div>
</div>
</a>
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='pendent'" class="item item-icon-left item-text-wrap c_deepPurple100" href="#/app/{{notification.link}}">
<div class="item-note text-right">
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
<div class="o_text_purple600">{{notification.date | date:"HH:mm:ss"}}</div>
</div>
<i ng-show="notification.state=='pendent'" class="icon ion-android-notifications-none o_text_purple600"></i>
<h2>{{notification.message}}</h2>
</a>
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='viewed'" class="item item-icon-left item-text-wrap" href="#/app/{{notification.link}}">
<div class="item-note text-right">
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
<div class="o_text_purple600">{{notification.date | date:"HH:mm:ss"}}</div>
</div>
<i ng-show="notification.state=='viewed'" class="icon ion-android-notifications-none"></i>
<h2>{{notification.message}}</h2>
</a>
</ion-content>
</ion-view>

+ 10
- 9
www/templates/travel.html

@ -51,22 +51,23 @@
<p class='text-right'>
<div ng-show="userHasJoined(travel.joinPetitions, storageuser._id)==-1">
<div ng-show="userHasJoined(travel.joins, storageuser._id)==-1">
<a ng-show="travel.type=='offering'" ng-click="joinTravel()" class="button o_purple300">{{'Ask_to_join' | translate}}</a>
<a ng-show="travel.type=='asking'" ng-click="joinTravel()" class="button o_purple300">{{'Offer_car' | translate}}</a>
<a ng-show="travel.type=='package'" ng-click="joinTravel()" class="button o_purple300">{{'Offer_car' | translate}}</a>
<a ng-show="travel.type=='offering'" ng-click="joinTravel()" class="button button-small o_purple300">{{'Ask_to_join' | translate}}</a>
<a ng-show="travel.type=='asking'" ng-click="joinTravel()" class="button button-small o_purple300">{{'Offer_car' | translate}}</a>
<a ng-show="travel.type=='package'" ng-click="joinTravel()" class="button button-small o_purple300">{{'Offer_car' | translate}}</a>
</div>
</div>
<div ng-show="userHasJoined(travel.joinPetitions, storageuser._id)>-1">
<a ng-show="travel.type=='offering'" ng-click="unjoinTravel()" class="button o_purple100">{{'Unjoin' | translate}}</a>
<a ng-show="travel.type=='asking'" ng-click="unjoinTravel()" class="button o_purple100">{{'Unoffer_car' | translate}}</a>
<a ng-show="travel.type=='package'" ng-click="unjoinTravel()" class="button o_purple100">{{'Unoffer_car' | translate}}</a>
<a ng-show="travel.type=='offering'" ng-click="unjoinTravel()" class="button button-small o_purple100">{{'Unjoin' | translate}}</a>
<a ng-show="travel.type=='asking'" ng-click="unjoinTravel()" class="button button-small o_purple100">{{'Unoffer_car' | translate}}</a>
<a ng-show="travel.type=='package'" ng-click="unjoinTravel()" class="button button-small o_purple100">{{'Unoffer_car' | translate}}</a>
</div>
<div ng-show="userHasJoined(travel.joins, storageuser._id)>-1">
<a ng-show="travel.type=='offering'" ng-click="leaveTravel()" class="button o_bRed">{{'Leave' | translate}}</a>
<a ng-show="travel.type=='asking'" ng-click="" class="button o_purple100">{{'Leave' | translate}}</a>
<a ng-show="travel.type=='package'" ng-click="" class="button o_purple100">{{'Leave' | translate}}</a>
You have been accepted!
<a ng-show="travel.type=='offering'" ng-click="leaveTravel()" class="button button-small o_bRed">{{'Leave' | translate}}</a>
<a ng-show="travel.type=='asking'" ng-click="" class="button button-small o_purple100">{{'Leave' | translate}}</a>
<a ng-show="travel.type=='package'" ng-click="" class="button button-small o_purple100">{{'Leave' | translate}}</a>
</div>
</p>
</div>

+ 10
- 2
www/templates/travels.html

@ -20,6 +20,9 @@
</div>
<a ng-repeat="travel in travels | orderBy: 'date' | filter: search"
class="item item-icon-left" href="#/app/travels/{{travel._id}}">
<div class="item-note text-right">
{{travel.user.username}}
</div>
<i class="icon ion-android-car o_text_grey700"></i>
<h2 class="o_text_grey800">{{travel.title}}</h2>
<div class="item-note text-right">
@ -34,8 +37,13 @@
</p>
</a>
</div>
<div class="button" ng-click="paginationNext()">
<!--<div class="button" ng-click="paginationNext()">
{{'load_more' | translate}}
</div>
</div>-->
<ion-infinite-scroll
ng-if="loadMorePagination"
on-infinite="paginationNext()"
distance="1%">
</ion-infinite-scroll>
</ion-content>
</ion-view>

+ 22
- 21
www/templates/user.html

@ -1,49 +1,50 @@
<ion-view view-title="{{'User' | translate}} {{user.username}}">
<ion-content class="has-footer">
<ion-refresher
pulling-text="{{'Pull_to_refresh' | translate}}..."
on-refresh="doRefresh()">
</ion-refresher>
<ion-content>
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()">
</ion-refresher>
<div class="o_userProfileBackground">
<img ng-src="{{user.avatar}}" class="o_userImgCircular" />
<h3 class="o_text_white">{{user.username}}</h3>
<p>{{user.description}}</p>
<p>{{user.email}}</p>
<img ng-click="showImg()" ng-src="{{user.avatar}}" class="o_userImgCircular" />
<!--
show image disabled, here the code prepared to enable show image:
<img ng-click="showImg()" ng-src="{{user.avatar}}" class="o_userImgCircular" />
-->
<h3 class="o_text_white">{{user.username}}</h3>
<p>{{user.description}}</p>
<p>{{user.email}}</p>
<p><a class="button button-small" ng-href="#/app/users/userLikes/{{user._id}}">
<p><a class="button button-small" ng-href="#/app/users/userLikes/{{user._id}}">
{{'view_likes' | translate}}
</a></p>
<p ng-show="storageuser._id==user._id">
<a class="button button-small o_grey500" ng-href="#/app/editUser">{{'Edit_profile' | translate}}</a>
</p>
<p ng-show="storageuser._id==user._id">
<a class="button button-small o_grey500" ng-href="#/app/editUser">{{'Edit_profile' | translate}}</a>
</p>
</div>
<div class="">
<div class="row">
<a class="tab-item" ng-show="user.telegram"
ng-href="http://telegram.me/{{user.telegram}}">
<div class="row">
<a class="tab-item" ng-show="user.telegram" ng-href="http://telegram.me/{{user.telegram}}">
<i class="icon ion-paper-airplane"></i>
@{{user.telegram}}
</a>
<a class="tab-item" ng-href="#/app/users/userTravels/{{user._id}}">
<a class="tab-item" ng-href="#/app/users/userTravels/{{user._id}}">
<i class="icon ion-android-car"></i>
{{user.travels.length}} {{'Travels' | translate}}
</a>
<a class="tab-item" ng-show="arrayObjectIndexOf(user.likes, storageuser._id)==-1">
<a class="tab-item" ng-show="arrayObjectIndexOf(user.likes, storageuser._id)==-1">
<i class="icon ion-heart" ng-click="likeUser()"></i>
<i ng-href="#/app/users/userLikes/{{user._id}}">
{{user.likes.length}} {{'likes' | translate}}
</i>
</a>
<a class="tab-item" ng-show="arrayObjectIndexOf(user.likes, storageuser._id)>-1">
<a class="tab-item" ng-show="arrayObjectIndexOf(user.likes, storageuser._id)>-1">
<i class="icon ion-heart ctext_red600" ng-click="unlikeUser()"></i>
<i ng-href="#/app/users/userLikes/{{user._id}}">
{{user.likes.length}} {{'likes' | translate}}
</i>
</a>
</div>
</div>
</div>
<div class="item">
<img src="{{user.faircoin}}" style="width: 100%;" />
<img src="{{user.faircoin}}" style="width: 100%;" />
</div>
<!--<div class="item item-body">
{{'current_publications_of' | translate}} {{user.username}}:

Loading…
Cancel
Save