From e144a012b5aa96cca93a572eb34cbafe9e16ec41 Mon Sep 17 00:00:00 2001 From: _Bastler <_Bastler@bstly.de> Date: Fri, 7 May 2021 11:25:01 +0200 Subject: [PATCH] pagination for invites --- src/app/pages/invites/invites.component.html | 66 +++++++++++--------- src/app/pages/invites/invites.component.ts | 17 ++++- src/app/services/invites.service.ts | 5 +- 3 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/app/pages/invites/invites.component.html b/src/app/pages/invites/invites.component.html index bd183cf..ae8c7ed 100644 --- a/src/app/pages/invites/invites.component.html +++ b/src/app/pages/invites/invites.component.html @@ -1,40 +1,46 @@

{{'invites' | i18n}}

- +
+ + + +
- - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - -
{{'invite.starts' | i18n}} {{ invite.starts | date:datetimeformat}} {{'invite.starts' | i18n}} {{ invite.starts | date:datetimeformat}} {{'invite.expires' | i18n}} {{ invite.expires | date:datetimeformat}} {{'invite.expires' | i18n}} {{ invite.expires | date:datetimeformat}} {{'invite.link' | i18n}} - {{ - invite.code}} {{'invite.link' | i18n}} + {{ + invite.code}} {{'invite.note' | i18n}} {{ invite.note}} {{'invite.note' | i18n}} {{ invite.note}} {{'invite.redeemed' | i18n}} - how_to_reg - {{'invite.redeemed' | i18n}} + how_to_reg +
+ + + + + @@ -55,13 +61,13 @@

{{'invites.others' | i18n}}

- + - + diff --git a/src/app/pages/invites/invites.component.ts b/src/app/pages/invites/invites.component.ts index 6a0f73d..8f724ed 100644 --- a/src/app/pages/invites/invites.component.ts +++ b/src/app/pages/invites/invites.component.ts @@ -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) => {}) } diff --git a/src/app/services/invites.service.ts b/src/app/services/invites.service.ts index 2355c2c..fd6499c 100644 --- a/src/app/services/invites.service.ts +++ b/src/app/services/invites.service.ts @@ -15,12 +15,15 @@ export class InviteService { return this.http.get(environment.apiUrl + "/invites" + (quota ? "?quota=" + quota : "")); } + getPages(quota: string, page: number, size: number, search: string) { + return this.http.get(environment.apiUrl + "/invites" + (quota ? "?quota=" + quota + "&" : "?") + "page=" + page + "&size=" + size + "&search=" + search); + } getOthers(quota: string) { return this.http.get(environment.apiUrl + "/invites/" + quota + "/others"); } - getOthersPages(quota: string, page : number, size : number, search : string) { + getOthersPages(quota: string, page: number, size: number, search: string) { return this.http.get(environment.apiUrl + "/invites/" + quota + "/others?page=" + page + "&size=" + size + "&search=" + search); }
{{'invite.note' | i18n}} {{ invite.note}} {{ invite.note}} {{ 'invite.noNote' | i18n}}