File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 var localStorageOrderByKey = 'osem.dashboard.orderBy' ;
1414
1515 vm . boxes = [ ] ;
16+ vm . boxes_count = 0 ;
1617 vm . listStyle = 'tiles' ;
1718 vm . orderByProperty = 'createdAt' ;
19+ vm . page = 0 ;
1820 vm . claimToken = '' ;
1921 vm . claimPattern = / ^ [ a - z 0 - 9 ] * $ / ;
2022 vm . errorMessage = '' ;
2123
2224 vm . claimDevice = claimDevice ;
2325 vm . closeAlert = closeAlert ;
26+ vm . nextPage = nextPage ;
27+ vm . previousPage = previousPage ;
2428
2529 activate ( ) ;
2630
4751 function getUsersBoxes ( ) {
4852 vm . boxes = [ ] ;
4953
50- return AccountService . getUsersBoxes ( )
51- . then ( function ( boxes ) {
52- vm . boxes = boxes ;
54+ return AccountService . getUsersBoxes ( vm . page )
55+ . then ( function ( response ) {
56+ vm . boxes = response . data . boxes ;
57+ vm . boxes_count = response . data . boxes_count ;
5358 } ) ;
5459 }
5560
8186 vm . errorMessage = '' ;
8287 }
8388
89+ function nextPage ( ) {
90+ vm . page = vm . page + 1 ;
91+ }
92+
93+ function previousPage ( ) {
94+ vm . page = vm . page - 1 ;
95+ }
96+
8497 $scope . $watch ( 'dashboard.listStyle' , function ( value ) {
8598 LocalStorageService . setValue ( localStorageKey , value ) ;
8699 } ) ;
87100
88101 $scope . $watch ( 'dashboard.orderByProperty' , function ( value ) {
89102 LocalStorageService . setValue ( localStorageOrderByKey , value ) ;
90103 } ) ;
104+
105+ $scope . $watch ( 'dashboard.page' , function ( ) {
106+ return getUsersBoxes ( ) ;
107+ } ) ;
91108 }
92109} ) ( ) ;
Original file line number Diff line number Diff line change 134134 }
135135 }
136136
137- function getUsersBoxes ( ) {
138- return $http . get ( app . API_URL + '/users/me/boxes' , { auth : true } )
137+ function getUsersBoxes ( page ) {
138+
139+ page = ( page === undefined ) ? 0 : page ;
140+
141+ return $http . get ( app . API_URL + '/users/me/boxes' + '?page=' + page , { auth : true } )
139142 . then ( getUsersBoxesComplete )
140143 . catch ( getUsersBoxesFailed ) ;
141144
142145 function getUsersBoxesComplete ( response ) {
143- return response . data . data . boxes . map ( function ( b ) {
146+ // Map response to Box model and replace it in response
147+ const boxes = response . data . data . boxes . map ( function ( b ) {
144148 return new Box ( b ) ;
145149 } ) ;
150+ response . data . data . boxes = boxes ;
151+
152+ return response . data ;
146153 }
147154
148155 function getUsersBoxesFailed ( error ) {
Original file line number Diff line number Diff line change 44 < div class ="col-lg-6 col-sm-12 col-md-12 " style ="margin-bottom: 30px; ">
55 < div class ="thumbnail " style ="height: 100%; ">
66 < div class ="caption ">
7- < h3 translate ="REGISTERED_BOXES " translate-values ="{count: dashboard.boxes.length } "> </ h3 >
7+ < h3 translate ="REGISTERED_BOXES " translate-values ="{count: dashboard.boxes_count } "> </ h3 >
88 < p > {{'REGISTERED_BOXES_INFO' | translate}}</ p >
99 < p >
1010 < a ui-sref ="account.register " class ="btn btn-primary "
@@ -66,6 +66,18 @@ <h3>{{'CLAIM_HEADER' | translate}}</h3>
6666 < i class ="fa fa-sort-numeric-asc " aria-hidden ="true "> </ i >
6767 </ button >
6868 </ div >
69+
70+ < div class ="btn-group pull-right " style ="margin-right: 15px; ">
71+ < button class ="btn btn-default " ng-click ="dashboard.previousPage() " ng-disabled ="dashboard.page <= 0 " title ="Previous page ">
72+ < i class ="fa fa-angle-left " aria-hidden ="true "> </ i >
73+ </ button >
74+ < button class ="btn btn-default " ng-click ="dashboard.nextPage() " ng-disabled ="dashboard.boxes_count === 25 || (dashboard.boxes_count >= 25 && dashboard.boxes.length < 25) " title ="Next page ">
75+ < i class ="fa fa-angle-right " aria-hidden ="true "> </ i >
76+ </ button >
77+ </ div >
78+ < div class ="pull-right " style ="margin-right: 15px; height: 34px; ">
79+ < span class ="label label-default " style ="line-height: 34px; vertical-align: middle; "> Devices per page: 25</ span >
80+ </ div >
6981 </ div >
7082 </ div >
7183
You can’t perform that action at this time.
0 commit comments