pagination for invites

This commit is contained in:
_Bastler
2021-05-07 11:25:01 +02:00
parent 7b0364ae8e
commit e144a012b5
3 changed files with 54 additions and 34 deletions
+14 -3
View File
@@ -18,7 +18,7 @@ import {debounceTime} from 'rxjs/operators';
export class InvitesComponent implements OnInit {
quota: string;
invites: any[];
invites: any;
others: any;
inviteQuota: number = 0;
success: boolean;
@@ -26,6 +26,7 @@ export class InvitesComponent implements OnInit {
datetimeformat: string;
pageSizeOptions: number[] = [5, 10, 25, 50];
searchFormControl = new FormControl();
searchOthersFormControl = new FormControl();
inviteColumns = ["starts", "expires", "link", "note", "redeemed"];
otherColumns = ["note"];
@@ -43,7 +44,11 @@ export class InvitesComponent implements OnInit {
this.datetimeformat = this.i18n.get('format.datetime', []);
this.quota = this.route.snapshot.paramMap.get('quota');
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
this.inviteService.getPages(this.quota, 0, this.invites.size, value).subscribe((data: any) => {
this.invites = data;
}, (error) => {})
})
this.searchOthersFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
this.inviteService.getOthersPages(this.quota, 0, this.others.size, value).subscribe((data: any) => {
this.others = data;
}, (error) => {})
@@ -72,6 +77,12 @@ export class InvitesComponent implements OnInit {
}, (error) => {})
}
updatePages(event: PageEvent) {
this.inviteService.getPages(this.quota, event.pageIndex, event.pageSize, this.searchFormControl.value ? this.searchFormControl.value : "").subscribe((data: any) => {
this.invites = data;
}, (error) => {})
}
create(): void {
this.working = true;
@@ -92,7 +103,7 @@ export class InvitesComponent implements OnInit {
}
updateOthers(event: PageEvent) {
this.inviteService.getOthersPages(this.quota, event.pageIndex, event.pageSize, "").subscribe((data: any) => {
this.inviteService.getOthersPages(this.quota, event.pageIndex, event.pageSize, this.searchOthersFormControl.value ? this.searchOthersFormControl.value : "").subscribe((data: any) => {
this.others = data;
}, (error) => {})
}