From a6356e1457cdda31f0f7c3579d33b3db0d0d25d1 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Fri, 28 Feb 2025 10:58:33 +0100 Subject: [PATCH] Updated groups paginator --- .../components/groups/groups.component.html | 10 ++++++++-- .../app/components/groups/groups.component.ts | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ogWebconsole/src/app/components/groups/groups.component.html b/ogWebconsole/src/app/components/groups/groups.component.html index dd16324..e9a6172 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.html +++ b/ogWebconsole/src/app/components/groups/groups.component.html @@ -356,7 +356,13 @@ - + + @@ -371,4 +377,4 @@ - \ No newline at end of file + diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index ff484ad..ebb0b58 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -19,7 +19,7 @@ import { DeleteModalComponent } from '../../shared/delete_modal/delete-modal/del import { ClassroomViewDialogComponent } from './shared/classroom-view/classroom-view-modal'; import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; -import { MatPaginator } from '@angular/material/paginator'; +import {MatPaginator, PageEvent} from '@angular/material/paginator'; import { CreateMultipleClientComponent } from "./shared/clients/create-multiple-client/create-multiple-client.component"; import { SelectionModel } from "@angular/cdk/collections"; @@ -41,6 +41,10 @@ export class GroupsComponent implements OnInit, OnDestroy { organizationalUnits: UnidadOrganizativa[] = []; selectedUnidad: UnidadOrganizativa | null = null; selectedDetail: UnidadOrganizativa | null = null; + length: number = 0; + itemsPerPage: number = 10; + page: number = 0; + pageSizeOptions: number[] = [5, 10, 20, 40, 100]; initialLoading: boolean = true; isLoadingClients: boolean = false; searchTerm = ''; @@ -334,11 +338,12 @@ export class GroupsComponent implements OnInit, OnDestroy { } - public fetchClientsForNode(node: TreeNode, selectedClientsBeforeEdit: string[] = []): void { + public fetchClientsForNode(node: any, selectedClientsBeforeEdit: string[] = []): void { this.isLoadingClients = true; - this.http.get(`${this.baseUrl}/clients?organizationalUnit.id=${node.id}`).subscribe({ + this.http.get(`${this.baseUrl}/clients?organizationalUnit.id=${node.id}&page=${this.page + 1}&itemsPerPage=${this.itemsPerPage}`).subscribe({ next: (response) => { this.selectedClients.data = response['hydra:member']; + this.length = response['hydra:totalItems']; this.arrayClients = this.selectedClients.data; this.hasClients = node.hasClients ?? false; this.isLoadingClients = false; @@ -732,4 +737,11 @@ export class GroupsComponent implements OnInit, OnDestroy { inputElement.value = ''; this.filterClients(''); } + + onPageChange(event: PageEvent): void { + this.page = event.pageIndex; + this.itemsPerPage = event.pageSize; + this.length = event.length; + this.fetchClientsForNode(this.selectedNode); + } }