From fbebfdae043d523c0d8463318fa48b4459482c0d Mon Sep 17 00:00:00 2001
From: nymkappa <1612910616@pm.me>
Date: Mon, 26 Feb 2024 15:54:10 +0100
Subject: [PATCH] [accelerator] add pagination support in acceleration list
---
.../accelerations-list.component.html | 9 +++
.../accelerations-list.component.ts | 64 +++++++++++--------
.../accelerator-dashboard.component.html | 2 +-
.../src/app/interfaces/node-api.interface.ts | 11 ++--
.../src/app/services/services-api.service.ts | 4 ++
5 files changed, 59 insertions(+), 31 deletions(-)
diff --git a/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html b/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html
index 9a919ca54..5481bed53 100644
--- a/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html
+++ b/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.html
@@ -17,6 +17,7 @@
Bid Boost |
Block |
Status |
+ Date |
@@ -52,6 +53,9 @@
Mined
Canceled
+
+
+ |
@@ -75,6 +79,11 @@
+
+
diff --git a/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.ts b/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.ts
index c1ab011ea..ae601fc62 100644
--- a/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.ts
+++ b/frontend/src/app/components/acceleration/accelerations-list/accelerations-list.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit, ChangeDetectionStrategy, Input, ChangeDetectorRef } from '@angular/core';
-import { Observable, catchError, of, switchMap, tap } from 'rxjs';
+import { combineLatest, BehaviorSubject, Observable, catchError, of, switchMap, tap } from 'rxjs';
import { Acceleration, BlockExtended } from '../../../interfaces/node-api.interface';
import { StateService } from '../../../services/state.service';
import { WebsocketService } from '../../../services/websocket.service';
@@ -21,9 +21,10 @@ export class AccelerationsListComponent implements OnInit {
isLoading = true;
paginationMaxSize: number;
page = 1;
- lastPage = 1;
+ accelerationCount: number;
maxSize = window.innerWidth <= 767.98 ? 3 : 5;
skeletonLines: number[] = [];
+ pageSubject: BehaviorSubject = new BehaviorSubject(this.page);
constructor(
private servicesApiService: ServicesApiServices,
@@ -40,34 +41,45 @@ export class AccelerationsListComponent implements OnInit {
this.skeletonLines = this.widget === true ? [...Array(6).keys()] : [...Array(15).keys()];
this.paginationMaxSize = window.matchMedia('(max-width: 670px)').matches ? 3 : 5;
-
- const accelerationObservable$ = this.accelerations$ || (this.pending ? this.servicesApiService.getAccelerations$() : this.servicesApiService.getAccelerationHistory$({ timeframe: '1m' }));
- this.accelerationList$ = accelerationObservable$.pipe(
- switchMap(accelerations => {
- if (this.pending) {
- for (const acceleration of accelerations) {
- acceleration.status = acceleration.status || 'accelerating';
- }
- }
- for (const acc of accelerations) {
- acc.boost = acc.feePaid - acc.baseFee - acc.vsizeFee;
- }
- if (this.widget) {
- return of(accelerations.slice(-6).reverse());
- } else {
- return of(accelerations.reverse());
- }
- }),
- catchError((err) => {
- this.isLoading = false;
- return of([]);
- }),
- tap(() => {
- this.isLoading = false;
+
+ this.accelerationList$ = this.pageSubject.pipe(
+ switchMap((page) => {
+ const accelerationObservable$ = this.accelerations$ || (this.pending ? this.servicesApiService.getAccelerations$() : this.servicesApiService.getAccelerationHistoryObserveResponse$({ timeframe: '1m', page: page }));
+ return accelerationObservable$.pipe(
+ switchMap(response => {
+ const accelerations = response.body;
+ this.accelerationCount = parseInt(response.headers.get('x-total-count'), 10);
+ console.log(this.accelerationCount);
+ if (this.pending) {
+ for (const acceleration of accelerations) {
+ acceleration.status = acceleration.status || 'accelerating';
+ }
+ }
+ for (const acc of accelerations) {
+ acc.boost = acc.feePaid - acc.baseFee - acc.vsizeFee;
+ }
+ if (this.widget) {
+ return of(accelerations.slice(0, 6));
+ } else {
+ return of(accelerations);
+ }
+ }),
+ catchError((err) => {
+ this.isLoading = false;
+ return of([]);
+ }),
+ tap(() => {
+ this.isLoading = false;
+ })
+ );
})
);
}
+ pageChange(page: number): void {
+ this.pageSubject.next(page);
+ }
+
trackByBlock(index: number, block: BlockExtended): number {
return block.height;
}
diff --git a/frontend/src/app/components/acceleration/accelerator-dashboard/accelerator-dashboard.component.html b/frontend/src/app/components/acceleration/accelerator-dashboard/accelerator-dashboard.component.html
index 6d9e49265..0fd70269c 100644
--- a/frontend/src/app/components/acceleration/accelerator-dashboard/accelerator-dashboard.component.html
+++ b/frontend/src/app/components/acceleration/accelerator-dashboard/accelerator-dashboard.component.html
@@ -84,7 +84,7 @@
Active Accelerations
-
+
diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts
index 6ef650e32..e5764e785 100644
--- a/frontend/src/app/interfaces/node-api.interface.ts
+++ b/frontend/src/app/interfaces/node-api.interface.ts
@@ -393,8 +393,11 @@ export interface Acceleration {
}
export interface AccelerationHistoryParams {
- timeframe?: string,
- status?: string,
- pool?: string,
- blockHash?: string,
+ status?: string;
+ timeframe?: string;
+ poolUniqueId?: number;
+ blockHash?: string;
+ blockHeight?: number;
+ page?: number;
+ pageLength?: number;
}
\ No newline at end of file
diff --git a/frontend/src/app/services/services-api.service.ts b/frontend/src/app/services/services-api.service.ts
index f11b3460c..a1f023b9b 100644
--- a/frontend/src/app/services/services-api.service.ts
+++ b/frontend/src/app/services/services-api.service.ts
@@ -147,4 +147,8 @@ export class ServicesApiServices {
getAccelerationHistory$(params: AccelerationHistoryParams): Observable {
return this.httpClient.get(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params } });
}
+
+ getAccelerationHistoryObserveResponse$(params: AccelerationHistoryParams): Observable {
+ return this.httpClient.get(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params }, observe: 'response'});
+ }
}