From 8623d291f16a0c94456b62bb098dc55d7dcb3019 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 25 Jul 2019 23:15:35 +0200 Subject: [PATCH] html: Template for watched outputs page. --- basicswap/basicswap.py | 3 ++- basicswap/http_server.py | 31 +++++++++++++++---------------- templates/index.html | 4 +++- templates/watched.html | 25 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 templates/watched.html diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index d6c42c6..fe1cce2 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -2413,7 +2413,8 @@ class BasicSwap(): rv = [] rv_heights = [] for c, v in self.coin_clients.items(): - rv_heights.append((c, v['last_height_checked'])) + if self.coin_clients[c]['connection_type'] == 'rpc': + rv_heights.append((c, v['last_height_checked'])) for o in v['watched_outputs']: rv.append((c, o[0], o[1], o[2], o[3])) return (rv, rv_heights) diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 214ec84..e9d605f 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -469,21 +469,20 @@ class HttpHandler(BaseHTTPRequestHandler): def page_watched(self, url_split, post_string): swap_client = self.server.swap_client watched_outputs, last_scanned = swap_client.listWatchedOutputs() - - content = html_content_start(self.server.title, self.server.title) \ - + '

Watched Outputs

' - - for c in last_scanned: - content += '

' + getCoinName(c[0]) + ' Scanned Height: ' + str(c[1]) + '

' - - content += '' - content += '' - for o in watched_outputs: - content += ''.format(o[1].hex(), getCoinName(o[0]), o[2], o[3], int(o[4])) - content += '
Bid IDChainTxidIndexType
{0}{1}{2}{3}{4}
' - - content += '

home

' - return bytes(content, 'UTF-8') + ls_formatted = [] + for ls in last_scanned: + ls_formatted.append((getCoinName(ls[0]), ls[1])) + wo_formatted = [] + for wo in watched_outputs: + wo_formatted.append((wo[1].hex(), getCoinName(wo[0]), wo[2], wo[3], int(wo[4]))) + template = env.get_template('watched.html') + return bytes(template.render( + title=self.server.title, + refresh=30, + h2=self.server.title, + last_scanned=last_scanned, + watched_outputs=wo_formatted, + ), 'UTF-8') def page_index(self, url_split): swap_client = self.server.swap_client @@ -491,7 +490,7 @@ class HttpHandler(BaseHTTPRequestHandler): template = env.get_template('index.html') return bytes(template.render( - titil=self.server.title, + title=self.server.title, refresh=30, h2=self.server.title, summary=summary diff --git a/templates/index.html b/templates/index.html index 40e87b8..eb38f84 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,7 +3,9 @@

View Wallets

-Page Refresh: 30 seconds
+{% if refresh %} +Page Refresh: {{ refresh }} seconds
+{% endif %} Swaps in progress: {{ summary.num_swapping }}
Network Offers: {{ summary.num_network_offers }}
Sent Offers: {{ summary.num_sent_offers }}
diff --git a/templates/watched.html b/templates/watched.html new file mode 100644 index 0000000..cbead84 --- /dev/null +++ b/templates/watched.html @@ -0,0 +1,25 @@ +{% include 'header.html' %} + +

Watched Outputs

+{% if refresh %} +

Page Refresh: {{ refresh }} seconds

+{% endif %} + +

Last Scanned

+ + +{% for ls in last_scanned %} + +{% endfor %} +
Coinheight
{{ ls[0] }}{{ ls[1] }}
+
+ + + +{% for wo in watched_outputs %} + +{% endfor %} +
Bid IDChainTxidIndexType
{{ wo[0] }}{{ wo[1] }}{{ wo[2] }}{{ wo[3] }}{{ wo[4] }}
+ +

home

+