Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { PaginationSettings } from './pagination-settings';
@Component({
selector: 'app-pagination',
templateUrl: './pagination.component.html',
styleUrls: ['./pagination.component.scss']
})
export class PaginationComponent implements OnInit {
@Input()
tabIdx = '0'; // internal to table.component, start migrating from lengthy, typo-prone, 'tabbable'
@Input()
paginationSettings: PaginationSettings;
@Input()
pages;
@Input()
dropdownValue = [10, 15, 25];
@Output()
notify = new EventEmitter();
// get tabIdx() {
// return this.tabIt ? '0' : '-1';
// }
constructor() {}
ngOnInit() {}
setPage(pageNumber: number) {
if (this.paginationSettings.currentPage === pageNumber) {
return;
} // nothing to do
this.paginationSettings.currentPage = pageNumber;
this.notify.emit();
}
prevPage() {
this.setPage(Math.max(1, this.paginationSettings.currentPage - 1));
}
nextPage() {
this.setPage(
Math.min(
this.paginationSettings.totalPages,
this.paginationSettings.currentPage + 1
)
);
}
setPageSize(pageSize: number) {
if (this.paginationSettings.pageSize === pageSize) {
return;
}
this.paginationSettings.pageSize = pageSize;
this.paginationSettings.currentPage = 1;
this.notify.emit();
}
pageRange() {
// Return a range of pages around the current page
const width = 3;
const minPage = Math.max(1, this.paginationSettings.currentPage - width);
const maxPage = Math.min(
this.paginationSettings.totalPages,
this.paginationSettings.currentPage + width
);
const pages = [];
for (let page = minPage; page <= maxPage; ++page) {
pages.push(page);
}
return pages;
}
}