From 94de58a7bb69cbbe01d69a38aab53da3ba12c4cc Mon Sep 17 00:00:00 2001 From: cryptosharks131 Date: Tue, 15 Aug 2023 16:14:44 -0400 Subject: [PATCH] Load more for pay/send --- gui/serializers.py | 2 + gui/templates/base.html | 26 +++++++ gui/templates/channel.html | 142 ++++++++++++++++++++++++------------- gui/templates/home.html | 86 +++++++++++++--------- gui/views.py | 4 +- 5 files changed, 175 insertions(+), 85 deletions(-) diff --git a/gui/serializers.py b/gui/serializers.py index 89a6949..9cb936d 100644 --- a/gui/serializers.py +++ b/gui/serializers.py @@ -5,12 +5,14 @@ from .models import LocalSettings, Payments, PaymentHops, Invoices, Forwards, Ch ##FUTURE UPDATE 'exclude' TO 'fields' class PaymentSerializer(serializers.HyperlinkedModelSerializer): + id = serializers.IntegerField(source='index') payment_hash = serializers.ReadOnlyField() class Meta: model = Payments exclude = [] class InvoiceSerializer(serializers.HyperlinkedModelSerializer): + id = serializers.IntegerField(source='index') r_hash = serializers.ReadOnlyField() creation_date = serializers.ReadOnlyField() settle_date = serializers.ReadOnlyField() diff --git a/gui/templates/base.html b/gui/templates/base.html index b8f5546..af5df03 100644 --- a/gui/templates/base.html +++ b/gui/templates/base.html @@ -30,6 +30,32 @@ "fee": f => ({innerHTML: parseFloat(f.fee.toFixed(3)).toLocaleString()}), "ppm": f => ({innerHTML: parseInt(f.ppm.toFixed(0)).toLocaleString()}), } + let {fee, ppm} = routed_template + const payments_template = Object.assign({}, { + "creation_date": p => ({innerHTML: formatDate(p.creation_date), title: adjustTZ(p.creation_date) }), + "value": p => ({innerHTML: p.value.intcomma()}), + "fee": p => ({innerHTML: parseFloat(p.fee.toFixed(3)).toLocaleString()}) + }, {ppm}, { + "status": p => ({innerHTML: ['Unknown', 'In-Flight', 'Succeeded', 'Failed'][p.status]}), + "chan_out_alias": p => ({innerHTML: p.chan_out_alias||'---'}), + "chan_out": p => ({innerHTML: p.status == 2 && p.chan_out !== 'MPP' ? `${(BigInt(p.chan_out)>>40n)+'x'+(BigInt(p.chan_out)>>16n & BigInt('0xFFFFFF'))+'x'+(BigInt(p.chan_out) & BigInt('0xFFFF'))}` : p.chan_out || '---' }), + "payment_hash": p => ({innerHTML: `${p.payment_hash.substring(0,7)}`}), + "rebal_chan": p => ({innerHTML: (p.rebal_chan || '').length > 0 ? 'Yes' : 'No'}), + "keysend_preimage": p => ({innerHTML: p.keysend_preimage ? 'Yes' : 'No'}) + } + ) + let {creation_date, value, keysend_preimage} = payments_template + const invoices_template = Object.assign({}, {creation_date}, { + "settle_date": i => ({innerHTML: formatDate(i.settle_date), title: adjustTZ(i.settle_date)}) + }, {value}, { + "amt_paid": i => ({innerHTML: i.amt_paid.intcomma()}), + "state": i => ({innerHTML: ['Open', 'Settled', 'Cancelled', 'Accepted'][i.state]}), + "chan_in_alias": i => ({innerHTML: i.chan_in_alias||'---'}), + "chan_in": i => ({innerHTML: i.chan_in? `${(BigInt(i.chan_in)>>40n)+'x'+(BigInt(i.chan_in)>>16n & BigInt('0xFFFFFF'))+'x'+(BigInt(i.chan_in) & BigInt('0xFFFF'))}` : '---'}), + "r_hash": i => ({innerHTML: `${i.r_hash.substring(0,7)}`}), + "keysend_preimage": i => ({innerHTML: keysend_preimage(i).innerHTML, title: i.message }), + } + ) const wire_failures = "0|1|2|3|4|5|6|Expiry Too Soon|8|9|10|Amount Below Minimum|Fee Insufficient|13|14|Temporary Channel Failure|16|17|Unknown Next Peer|19|20|21|Expiry Too Far".split('|') const failure_details = "0|---|2|3|4|HTLC Exceeds Max|Insufficient Balance|7|8|9|10|11|12|Invoice Not Open|14|15|16|17|18|19|Invalid Keysend|21|Circular Route".split('|') const failedHTLCs_template = { diff --git a/gui/templates/channel.html b/gui/templates/channel.html index d3c4b66..830742c 100644 --- a/gui/templates/channel.html +++ b/gui/templates/channel.html @@ -336,7 +336,7 @@ - + Load More @@ -346,43 +346,33 @@
{% include 'rebalances_table.html' with count=5 last_hop_pubkey=channel.remote_pubkey load_count=5 title='Rebalance Requests' %}
-{% if payments %} -
+

Last 5 Payments Sent

- +
- - - - - - - - - + + + + + + + + + - {% for payment in payments %} - - - - - - - - - - - - - {% endfor %} + + + + +
TimestampHashValueFee PaidPPM PaidStatusChan Out AliasChan Out IDRouteKeysendValueFee PaidPPM PaidStatusChan Out AliasChan Out IDHashRebalanceKeysend
{{ payment.creation_date|naturaltime }}{{ payment.payment_hash }}{{ payment.value|add:"0"|intcomma }}{{ payment.fee|intcomma }}{{ payment.ppm|intcomma }}{% if payment.status == 1 %}In-Flight{% elif payment.status == 2 %}Succeeded{% elif payment.status == 3 %}Failed{% else %}{{ payment.status }}{% endif %}{% if payment.status == 2 %}{% if payment.chan_out_alias == '' %}---{% else %}{{ payment.chan_out_alias }}{% endif %}{% else %}---{% endif %}{% if payment.status == 2 %}{{ payment.chan_out }}{% else %}---{% endif %}{% if payment.status == 2 %}Open{% else %}---{% endif %}{% if payment.keysend_preimage != None %}Yes{% else %}No{% endif %}
+ Load More +
-{% endif %} -{% if invoices %} -
+

Last 5 Payments Received

- +
@@ -394,22 +384,15 @@ - {% for invoice in invoices %} - - - - - - - - - - - - {% endfor %} + + + + +
Created SettledChannel In Keysend
{{ invoice.creation_date|naturaltime }}{% if invoice.state == 1 %}{{ invoice.settle_date|naturaltime }}{% else %}---{% endif %}{{ invoice.r_hash }}{{ invoice.value|add:"0"|intcomma }}{% if invoice.state == 1 %}{{ invoice.amt_paid|intcomma }}{% else %}---{% endif %}{% if invoice.state == 0 %}Open{% elif invoice.state == 1 %}Settled{% elif invoice.state == 2 %}Canceled{% else %}{{ invoice.state }}{% endif %}{% if invoice.state == 1 %}{% if invoice.chan_in_alias == '' %}---{% else %}{{ invoice.chan_in_alias }}{% endif %}{% else %}---{% endif %}{% if invoice.state == 1 and invoice.chan_in != None %}{{ invoice.chan_in }}{% else %}---{% endif %}{% if invoice.keysend_preimage != None %}Yes{% else %}No{% endif %}
+ Load More +
-{% endif %}

Last Failed HTLCs

@@ -427,7 +410,7 @@ - @@ -455,7 +438,7 @@ - @@ -475,14 +458,20 @@
+ Load More
+ Load More