Skip to content

Commit 60b2377

Browse files
Dan WahlinDan Wahlin
Dan Wahlin
authored and
Dan Wahlin
committed
Fixed paging issue
1 parent f8af13c commit 60b2377

File tree

3,623 files changed

+13
-236353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,623 files changed

+13
-236353
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ npm-debug.log
99
# Build Generated Files
1010
public/app/**/*.js
1111
public/app/**/*.js.map
12+
public/lib
1213

1314

1415

controllers/api/customers/customers.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class CustomersController {
3333
console.log('*** getCustomersPage');
3434
const topVal = req.params.top,
3535
skipVal = req.params.skip,
36-
top = (isNaN(topVal)) ? 10 : +req.params.top,
37-
skip = (isNaN(skipVal)) ? 0 : +req.params.skip;
36+
top = (isNaN(topVal)) ? 10 : +topVal,
37+
skip = (isNaN(skipVal)) ? 0 : +skipVal;
3838

3939
customersRepo.getPagedCustomers(skip, top, (err, data) => {
4040
res.setHeader('X-InlineCount', data.count);

lib/customersRepository.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ class CustomersRepository {
2626
}
2727

2828
getPagedCustomers(skip, top, callback) {
29-
console.log('*** CustomersRepository.getCustomers');
29+
console.log('*** CustomersRepository.getPagedCustomers');
3030
Customer.count((err, custsCount) => {
3131
var count = custsCount;
32+
console.log(`Skip: ${skip} Top: ${top}`);
3233
console.log(`Customers count: ${count}`);
3334

3435
Customer.find({})
36+
.sort({lastName: 1})
3537
.skip(skip)
3638
.limit(top)
3739
.exec((err, customers) => {

public/app/customers/customers.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class CustomersComponent implements OnInit {
2525

2626
ngOnInit() {
2727
this.title = 'Customers';
28-
this.getCustomersSummary(1);
28+
this.getCustomersPage(1);
2929

3030
// this.dataService.getCustomers()
3131
// .subscribe((customers: ICustomer[]) => {
@@ -44,16 +44,16 @@ export class CustomersComponent implements OnInit {
4444
}
4545
}
4646

47-
getCustomersSummary(page: number) {
48-
this.dataService.getCustomersPage(page - 1, this.pageSize)
47+
pageChanged(page: number) {
48+
this.getCustomersPage(page);
49+
}
50+
51+
getCustomersPage(page: number) {
52+
this.dataService.getCustomersPage((page - 1) * this.pageSize, this.pageSize)
4953
.subscribe((response: IPagedResults<ICustomer[]>) => {
5054
this.customers = this.filteredCustomers = response.results;
5155
this.totalRecords = response.totalRecords;
5256
});
5357
}
5458

55-
pageChanged(page: number) {
56-
this.getCustomersSummary(page);
57-
}
58-
5959
}

public/lib/@angular/common/README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

public/lib/@angular/common/bundles/common-testing.umd.js

Lines changed: 0 additions & 198 deletions
This file was deleted.

0 commit comments

Comments
 (0)