mirror of
https://github.com/arnaucube/commonroutesApp.git
synced 2026-02-06 19:16:45 +01:00
users pagination implemented in infinite scroll
This commit is contained in:
11
README.md
11
README.md
@@ -2,13 +2,4 @@
|
|||||||
|
|
||||||
server code: https://github.com/arnaucode/carsincommonServer
|
server code: https://github.com/arnaucode/carsincommonServer
|
||||||
|
|
||||||
|

|
||||||
**ToDos:**
|
|
||||||
```
|
|
||||||
-page for user to view joins that has done
|
|
||||||
-allow travel crator to accept join petitions and reject people
|
|
||||||
-add to travel the date of destination
|
|
||||||
-user comments and system to profile, to valorate users
|
|
||||||
-notifications system syncronized
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|||||||
BIN
carsincommon.png
Normal file
BIN
carsincommon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 512 KiB |
@@ -33,7 +33,7 @@ angular.module('app.offerCar', ['pascalprecht.translate', 'ui-leaflet'])
|
|||||||
})
|
})
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
window.location="#app/travels"
|
window.location="#app/travels";
|
||||||
},
|
},
|
||||||
function(data) { // optional
|
function(data) { // optional
|
||||||
// failed
|
// failed
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ var translations = {
|
|||||||
"Signup": "Signup",
|
"Signup": "Signup",
|
||||||
"Login": "Login",
|
"Login": "Login",
|
||||||
"Travels": "Travels",
|
"Travels": "Travels",
|
||||||
|
"travels": "travels",
|
||||||
|
"likes": "likes",
|
||||||
"Travels_feed": "Travels feed",
|
"Travels_feed": "Travels feed",
|
||||||
"Users": "Users",
|
"Users": "Users",
|
||||||
"Notifications": "Notifications",
|
"Notifications": "Notifications",
|
||||||
@@ -76,7 +78,7 @@ var translations = {
|
|||||||
"load_more": "load more",
|
"load_more": "load more",
|
||||||
"view_likes": "view likes",
|
"view_likes": "view likes",
|
||||||
"Edit_profile": "Edit profile",
|
"Edit_profile": "Edit profile",
|
||||||
"Travels_offering": "Travels offering",
|
"Travels_publicated": "Travels publicated",
|
||||||
"Travels_joining": "Travels joining"
|
"Travels_joining": "Travels joining"
|
||||||
},
|
},
|
||||||
"catalan": {
|
"catalan": {
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet'])
|
|||||||
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
|
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
|
||||||
localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));
|
localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));
|
||||||
|
|
||||||
|
window.location="#app/users/userTravels/" + $scope.storageuser._id;
|
||||||
},
|
},
|
||||||
function(response) { // optional
|
function(response) { // optional
|
||||||
// failed
|
// failed
|
||||||
|
|||||||
@@ -1,34 +1,60 @@
|
|||||||
angular.module('app.users', ['pascalprecht.translate'])
|
angular.module('app.users', ['pascalprecht.translate'])
|
||||||
|
|
||||||
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
|
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
|
||||||
$scope.users="";
|
$scope.users = [];
|
||||||
|
$scope.loadMorePagination = true;
|
||||||
|
$scope.page = 0;
|
||||||
|
|
||||||
$scope.users=JSON.parse(localStorage.getItem('c_users'));
|
//$scope.users = JSON.parse(localStorage.getItem('c_users'));
|
||||||
|
|
||||||
$scope.doRefresh = function() {
|
$scope.doRefresh = function() {
|
||||||
|
|
||||||
/* users refresh: */
|
/* users refresh: */
|
||||||
$http.get(urlapi + 'users')
|
$http.get(urlapi + 'users?page=' + $scope.page)
|
||||||
.success(function(data, status, headers, config){
|
.then(function(data) {
|
||||||
console.log('data success');
|
console.log('data success');
|
||||||
console.log(data); // for browser console
|
console.log(data);
|
||||||
$scope.users = data; // for UI
|
|
||||||
localStorage.setItem('c_users', JSON.stringify($scope.users));
|
|
||||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
|
||||||
|
|
||||||
//set userdata
|
$scope.users = $scope.users.concat(data.data);
|
||||||
$scope.userdata = $filter('filter')($scope.users, {username: $scope.storageusername}, true)[0];
|
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||||
console.log("userdata");
|
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||||
console.log($scope.userdata);
|
if (data.data.length < 1) {
|
||||||
localStorage.setItem("c_userdata", JSON.stringify($scope.userdata));
|
console.log("setting loadMorePagination to false");
|
||||||
})
|
$scope.loadMorePagination = false;
|
||||||
.error(function(data, status, headers,config){
|
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||||
console.log('data error');
|
}
|
||||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
|
||||||
})
|
|
||||||
.then(function(result){
|
/*localStorage.setItem('c_users', JSON.stringify($scope.users));
|
||||||
users = result.data;
|
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||||
|
|
||||||
|
//set userdata
|
||||||
|
$scope.userdata = $filter('filter')($scope.users, {
|
||||||
|
username: $scope.storageusername
|
||||||
|
}, true)[0];
|
||||||
|
console.log("userdata");
|
||||||
|
console.log($scope.userdata);
|
||||||
|
localStorage.setItem("c_userdata", JSON.stringify($scope.userdata));*/
|
||||||
|
}, 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.doRefresh();
|
||||||
});
|
|
||||||
|
$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');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
<ion-view view-title="Main">
|
<ion-view view-title="Main">
|
||||||
<ion-content class="has-footer">
|
<ion-content class="has-footer">
|
||||||
<a ng-href="#/app/users/{{storageuser._id}}" class="item item-icon-left o_purpleG300to500">
|
<a ng-href="#/app/users/{{storageuser._id}}" class="item item-avatar o_purpleG300to500">
|
||||||
<i class="icon ion-person"></i>
|
<!--<i class="icon ion-person"></i>-->
|
||||||
|
<img ng-src="{{storageuser.avatar}}">
|
||||||
{{storageuser.username}} {{'profile' | translate}}
|
{{storageuser.username}} {{'profile' | translate}}
|
||||||
|
<p style="color:#ffffff;">
|
||||||
|
{{storageuser.travels.length}} {{'travels' | translate }},
|
||||||
|
{{storageuser.likes.length}} {{'likes' | translate }}
|
||||||
|
</p>
|
||||||
</a>
|
</a>
|
||||||
<a ng-href="#/app/newTravel" class="item item-icon-left o_purpleG300to500">
|
<a ng-href="#/app/newTravel" class="item item-icon-left o_purpleG300to500">
|
||||||
<i class="icon ion-map"></i>
|
<i class="icon ion-map"></i>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="item item-divider o_purple300" ng-show="travels[0]">
|
<div class="item item-divider o_purple300" ng-show="travels[0]">
|
||||||
{{'Travels_offering' | translate}}
|
{{'Travels_publicated' | translate}}
|
||||||
</div>
|
</div>
|
||||||
<a ng-repeat="travel in travels | orderBy: 'date'"
|
<a ng-repeat="travel in travels | orderBy: 'date'"
|
||||||
class="item item-icon-left" href="#/app/travels/{{travel._id}}">
|
class="item item-icon-left" href="#/app/travels/{{travel._id}}">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<ion-view view-title="{{'Users' | translate}}">
|
<ion-view view-title="{{'Users' | translate}}">
|
||||||
<ion-content class="has-footer">
|
<ion-content>
|
||||||
<ion-refresher
|
<ion-refresher
|
||||||
pulling-text="{{'Pull_to_refresh' | translate}}..."
|
pulling-text="{{'Pull_to_refresh' | translate}}..."
|
||||||
on-refresh="doRefresh()">
|
on-refresh="doRefresh()">
|
||||||
@@ -20,5 +20,10 @@
|
|||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<ion-infinite-scroll
|
||||||
|
ng-if="loadMorePagination"
|
||||||
|
on-infinite="paginationNext()"
|
||||||
|
distance="1%">
|
||||||
|
</ion-infinite-scroll>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|||||||
Reference in New Issue
Block a user