Skip to content

Commit de296ec

Browse files
ECL: On-chain Transactions, Invoice and Payments pagination
Done most of the UI changes to accommodate pagination on transactions, payments and invoices tables but true pagination cannot be implemented till total number of records are missing from the API response. Once the issue ACINQ/eclair#2855 is fixed, I will uncomment pagination changes in the frontend.
1 parent c31a123 commit de296ec

19 files changed

+150
-63
lines changed

backend/controllers/eclair/fees.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ export const getPayments = (req, res, next) => {
130130
options.url = req.session.selectedNode.settings.lnServerUrl + '/audit';
131131
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
132132
options.form = { from: 0, to: tillToday };
133+
if (req.query.count) {
134+
options.form.count = req.query.count;
135+
}
136+
if (req.query.skip) {
137+
options.form.skip = req.query.skip;
138+
}
133139
if (common.read_dummy_data) {
134140
common.getDummyData('Payments', req.session.selectedNode.lnImplementation).then((data) => { res.status(200).json(arrangePayments(req.session.selectedNode, data)); });
135141
}

backend/controllers/eclair/invoices.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ export const getInvoice = (req, res, next) => {
5353
return res.status(err.statusCode).json({ message: err.message, error: err.error });
5454
});
5555
};
56-
export const listPendingInvoicesRequestCall = (selectedNode) => {
56+
export const listPendingInvoicesRequestCall = (selectedNode, count, skip) => {
5757
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'List Pending Invoices..' });
5858
options = selectedNode.authentication.options;
5959
options.url = selectedNode.settings.lnServerUrl + '/listpendinginvoices';
6060
options.form = { from: 0, to: (Math.round(new Date(Date.now()).getTime() / 1000)).toString() };
61+
// Limit the number of invoices till provided count
62+
if (count) {
63+
options.form.count = count;
64+
}
65+
if (skip) {
66+
options.form.skip = skip;
67+
}
6168
return new Promise((resolve, reject) => {
6269
request.post(options).then((pendingInvoicesResponse) => {
6370
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Pending Invoices List ', data: pendingInvoicesResponse });
@@ -74,27 +81,31 @@ export const listInvoices = (req, res, next) => {
7481
return res.status(options.statusCode).json({ message: options.message, error: options.error });
7582
}
7683
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
77-
options.form = { from: 0, to: tillToday };
7884
const options1 = JSON.parse(JSON.stringify(options));
7985
options1.url = req.session.selectedNode.settings.lnServerUrl + '/listinvoices';
8086
options1.form = { from: 0, to: tillToday };
87+
if (req.query.count) {
88+
options1.form.count = req.query.count;
89+
}
90+
if (req.query.skip) {
91+
options1.form.skip = req.query.skip;
92+
}
8193
const options2 = JSON.parse(JSON.stringify(options));
8294
options2.url = req.session.selectedNode.settings.lnServerUrl + '/listpendinginvoices';
8395
options2.form = { from: 0, to: tillToday };
8496
if (common.read_dummy_data) {
85-
return common.getDummyData('Invoices', req.session.selectedNode.lnImplementation).then((body) => {
86-
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
87-
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
97+
return common.getDummyData('Invoices', req.session.selectedNode.lnImplementation).then(([invoices, pendingInvoicesRes]) => {
98+
pendingInvoices = pendingInvoicesRes;
8899
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
89100
then((values) => res.status(200).json(invoices));
90101
});
91102
}
92103
else {
93104
return Promise.all([request(options1), request(options2)]).
94-
then((body) => {
95-
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body });
96-
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
97-
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
105+
then(([invoices, pendingInvoicesRes]) => {
106+
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: invoices });
107+
// pendingInvoices will be used to get the status (paid/unpaid) of the invoice via getReceivedPaymentInfo
108+
pendingInvoices = pendingInvoicesRes;
98109
if (invoices && invoices.length > 0) {
99110
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
100111
then((values) => {

frontend/456.52fd629b36893386.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/456.b73706bd7985d63a.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

frontend/main.10c032ab368eb3c8.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/main.d750cc46804fb3a1.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/runtime.80dbd7a4768bbe74.js renamed to frontend/runtime.07f90b3998cf8be8.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/controllers/eclair/fees.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export const getPayments = (req, res, next) => {
113113
options.url = req.session.selectedNode.settings.lnServerUrl + '/audit';
114114
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
115115
options.form = { from: 0, to: tillToday };
116+
if (req.query.count) { options.form.count = req.query.count; }
117+
if (req.query.skip) { options.form.skip = req.query.skip; }
116118
if (common.read_dummy_data) {
117119
common.getDummyData('Payments', req.session.selectedNode.lnImplementation).then((data) => { res.status(200).json(arrangePayments(req.session.selectedNode, data)); });
118120
} else {

server/controllers/eclair/invoices.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ export const getInvoice = (req, res, next) => {
5252
});
5353
};
5454

55-
export const listPendingInvoicesRequestCall = (selectedNode: SelectedNode) => {
55+
export const listPendingInvoicesRequestCall = (selectedNode: SelectedNode, count?: number, skip?: number) => {
5656
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'List Pending Invoices..' });
5757
options = selectedNode.authentication.options;
5858
options.url = selectedNode.settings.lnServerUrl + '/listpendinginvoices';
5959
options.form = { from: 0, to: (Math.round(new Date(Date.now()).getTime() / 1000)).toString() };
60+
// Limit the number of invoices till provided count
61+
if (count) { options.form.count = count; }
62+
if (skip) { options.form.skip = skip; }
6063
return new Promise((resolve, reject) => {
6164
request.post(options).then((pendingInvoicesResponse) => {
6265
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Pending Invoices List ', data: pendingInvoicesResponse });
@@ -72,26 +75,26 @@ export const listInvoices = (req, res, next) => {
7275
options = common.getOptions(req);
7376
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
7477
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
75-
options.form = { from: 0, to: tillToday };
7678
const options1 = JSON.parse(JSON.stringify(options));
7779
options1.url = req.session.selectedNode.settings.lnServerUrl + '/listinvoices';
7880
options1.form = { from: 0, to: tillToday };
81+
if (req.query.count) { options1.form.count = req.query.count; }
82+
if (req.query.skip) { options1.form.skip = req.query.skip; }
7983
const options2 = JSON.parse(JSON.stringify(options));
8084
options2.url = req.session.selectedNode.settings.lnServerUrl + '/listpendinginvoices';
8185
options2.form = { from: 0, to: tillToday };
8286
if (common.read_dummy_data) {
83-
return common.getDummyData('Invoices', req.session.selectedNode.lnImplementation).then((body) => {
84-
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
85-
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
87+
return common.getDummyData('Invoices', req.session.selectedNode.lnImplementation).then(([invoices, pendingInvoicesRes]: any[]) => {
88+
pendingInvoices = pendingInvoicesRes;
8689
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
8790
then((values) => res.status(200).json(invoices));
8891
});
8992
} else {
9093
return Promise.all([request(options1), request(options2)]).
91-
then((body) => {
92-
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body });
93-
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
94-
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
94+
then(([invoices, pendingInvoicesRes]) => {
95+
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: invoices });
96+
// pendingInvoices will be used to get the status (paid/unpaid) of the invoice via getReceivedPaymentInfo
97+
pendingInvoices = pendingInvoicesRes;
9598
if (invoices && invoices.length > 0) {
9699
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
97100
then((values) => {

src/app/eclair/on-chain/on-chain-transaction-history/on-chain-transaction-history.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@
8989
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
9090
<tr *matRowDef="let row; columns: displayedColumns;" mat-row></tr>
9191
</table>
92+
<!-- Remove below one line after paginator api is fixed -->
9293
<mat-paginator class="mb-1" [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions" [showFirstLastButtons]="screenSize === screenSizeEnum.XS ? false : true" />
94+
<!-- Uncomment after paginator api is fixed -->
95+
<!-- <mat-paginator class="mb-1" [length]="totalRecords" [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions" [showFirstLastButtons]="screenSize === screenSizeEnum.XS ? false : true" (page)="onPageChange($event)" /> -->
9396
</div>
9497
</div>
9598
</div>

0 commit comments

Comments
 (0)