refactor: update paginator settings and improve page change handling in groups component
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
parent
1d78965c92
commit
42b10c63c1
|
|
@ -358,12 +358,8 @@
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
<mat-paginator
|
<mat-paginator [length]="length" [pageSize]="itemsPerPage" [pageIndex]="page"
|
||||||
[length]="length"
|
[pageSizeOptions]="pageSizeOptions" (page)="onPageChange($event)">
|
||||||
[pageSize]="itemsPerPage"
|
|
||||||
[pageIndex]="page"
|
|
||||||
[pageSizeOptions]="pageSizeOptions"
|
|
||||||
(page)="onPageChange($event)">
|
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,6 @@ describe('GroupsComponent', () => {
|
||||||
spyOn(component['http'], 'get').and.callThrough();
|
spyOn(component['http'], 'get').and.callThrough();
|
||||||
component.fetchClientsForNode(node);
|
component.fetchClientsForNode(node);
|
||||||
expect(component.isLoadingClients).toBeTrue();
|
expect(component.isLoadingClients).toBeTrue();
|
||||||
expect(component['http'].get).toHaveBeenCalledWith(`${component.baseUrl}/clients?organizationalUnit.id=${node.id}`);
|
expect(component['http'].get).toHaveBeenCalledWith(`${component.baseUrl}/clients?organizationalUnit.id=${node.id}&page=1&itemsPerPage=20`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -42,9 +42,9 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
selectedUnidad: UnidadOrganizativa | null = null;
|
selectedUnidad: UnidadOrganizativa | null = null;
|
||||||
selectedDetail: UnidadOrganizativa | null = null;
|
selectedDetail: UnidadOrganizativa | null = null;
|
||||||
length: number = 0;
|
length: number = 0;
|
||||||
itemsPerPage: number = 10;
|
itemsPerPage: number = 20;
|
||||||
page: number = 0;
|
page: number = 0;
|
||||||
pageSizeOptions: number[] = [5, 10, 20, 40, 100];
|
pageSizeOptions: number[] = [5, 10, 20, 50, 100];
|
||||||
initialLoading: boolean = true;
|
initialLoading: boolean = true;
|
||||||
isLoadingClients: boolean = false;
|
isLoadingClients: boolean = false;
|
||||||
searchTerm = '';
|
searchTerm = '';
|
||||||
|
|
@ -69,7 +69,6 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
displayedColumns: string[] = ['select', 'status', 'ip', 'name', 'oglive', 'subnet', 'pxeTemplate', 'actions'];
|
displayedColumns: string[] = ['select', 'status', 'ip', 'name', 'oglive', 'subnet', 'pxeTemplate', 'actions'];
|
||||||
|
|
||||||
private _sort!: MatSort;
|
private _sort!: MatSort;
|
||||||
private _paginator!: MatPaginator;
|
|
||||||
|
|
||||||
@ViewChild(MatSort)
|
@ViewChild(MatSort)
|
||||||
set matSort(ms: MatSort) {
|
set matSort(ms: MatSort) {
|
||||||
|
|
@ -79,14 +78,6 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewChild(MatPaginator)
|
|
||||||
set matPaginator(mp: MatPaginator) {
|
|
||||||
this._paginator = mp;
|
|
||||||
if (this.selectedClients) {
|
|
||||||
this.selectedClients.paginator = this._paginator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private subscriptions: Subscription = new Subscription();
|
private subscriptions: Subscription = new Subscription();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
@ -363,6 +354,11 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageChange(event: PageEvent): void {
|
||||||
|
this.page = event.pageIndex;
|
||||||
|
this.itemsPerPage = event.pageSize;
|
||||||
|
this.fetchClientsForNode(this.selectedNode);
|
||||||
|
}
|
||||||
|
|
||||||
addOU(event: MouseEvent, parent: TreeNode | null = null): void {
|
addOU(event: MouseEvent, parent: TreeNode | null = null): void {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
@ -737,11 +733,4 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
inputElement.value = '';
|
inputElement.value = '';
|
||||||
this.filterClients('');
|
this.filterClients('');
|
||||||
}
|
}
|
||||||
|
|
||||||
onPageChange(event: PageEvent): void {
|
|
||||||
this.page = event.pageIndex;
|
|
||||||
this.itemsPerPage = event.pageSize;
|
|
||||||
this.length = event.length;
|
|
||||||
this.fetchClientsForNode(this.selectedNode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue