implemented infinite scroll on travels, user avatar show image, added username on travels list
|
Before Width: | Height: | Size: 15 KiB |
BIN
www/img/avatars/chameleon.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/img/avatars/clown-fish.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
www/img/avatars/duck.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
www/img/avatars/owl.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/img/avatars/penguin.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
www/img/avatars/siberian-husky.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
www/img/avatars/sloth.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
www/img/avatars/tiger.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
www/img/avatars/toucan.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 754 B |
|
Before Width: | Height: | Size: 1.0 KiB |
BIN
www/img/fav.png
|
Before Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 764 KiB |
|
Before Width: | Height: | Size: 767 KiB |
BIN
www/img/help.png
|
Before Width: | Height: | Size: 701 B |
|
Before Width: | Height: | Size: 4.6 KiB |
BIN
www/img/join.png
|
Before Width: | Height: | Size: 291 B |
|
Before Width: | Height: | Size: 891 B |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 797 B |
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 555 B |
BIN
www/img/road.png
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 893 B |
|
Before Width: | Height: | Size: 1013 B |
|
Before Width: | Height: | Size: 793 B |
|
Before Width: | Height: | Size: 922 B |
391
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
|
||||
};
|
||||
$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
|
||||
$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 });
|
||||
}, 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(){
|
||||
$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()));
|
||||
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');
|
||||
}
|
||||
});
|
||||
},
|
||||
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];
|
||||
// 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){
|
||||
if (response.data.success == false) {
|
||||
|
||||
$ionicLoading.show({ template: 'failed to generate new asking package', noBackdrop: true, duration: 2000 });
|
||||
}
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
});
|
||||
$scope.closeNewComment();
|
||||
$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;
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
245
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
www/templates/imgView.html
Normal file
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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}}:
|
||||
|
||||