html: template for active swaps.

2024-05-20_merge
tecnovert 5 years ago
parent 8623d291f1
commit 41ad7201e9
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 30
      basicswap/http_server.py
  2. 16
      templates/active.html

@ -91,20 +91,15 @@ class HttpHandler(BaseHTTPRequestHandler):
def page_active(self, url_split, post_string): def page_active(self, url_split, post_string):
swap_client = self.server.swap_client swap_client = self.server.swap_client
content = html_content_start(self.server.title, self.server.title) \
+ '<h3>Active Swaps</h3>'
active_swaps = swap_client.listSwapsInProgress() active_swaps = swap_client.listSwapsInProgress()
content += '<table>' template = env.get_template('active.html')
content += '<tr><th>Bid ID</th><th>Offer ID</th><th>Bid Status</th></tr>' return bytes(template.render(
for s in active_swaps: title=self.server.title,
content += '<tr><td><a href=/bid/{0}>{0}</a></td><td><a href=/offer/{1}>{1}</a></td><td>{2}</td></tr>'.format(s[0].hex(), s[1], getBidState(s[2])) refresh=30,
content += '</table>' h2=self.server.title,
active_swaps=[(s[0].hex(), s[1], getBidState(s[2])) for s in active_swaps],
content += '<p><a href="/">home</a></p></body></html>' ), 'UTF-8')
return bytes(content, 'UTF-8')
def page_wallets(self, url_split, post_string): def page_wallets(self, url_split, post_string):
swap_client = self.server.swap_client swap_client = self.server.swap_client
@ -469,19 +464,14 @@ class HttpHandler(BaseHTTPRequestHandler):
def page_watched(self, url_split, post_string): def page_watched(self, url_split, post_string):
swap_client = self.server.swap_client swap_client = self.server.swap_client
watched_outputs, last_scanned = swap_client.listWatchedOutputs() watched_outputs, last_scanned = swap_client.listWatchedOutputs()
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') template = env.get_template('watched.html')
return bytes(template.render( return bytes(template.render(
title=self.server.title, title=self.server.title,
refresh=30, refresh=30,
h2=self.server.title, h2=self.server.title,
last_scanned=last_scanned, last_scanned=[(getCoinName(ls[0]), ls[1]) for ls in last_scanned],
watched_outputs=wo_formatted, watched_outputs=[(wo[1].hex(), getCoinName(wo[0]), wo[2], wo[3], int(wo[4])) for wo in watched_outputs],
), 'UTF-8') ), 'UTF-8')
def page_index(self, url_split): def page_index(self, url_split):

@ -0,0 +1,16 @@
{% include 'header.html' %}
<h3>Active Swaps</h3>
{% if refresh %}
<p>Page Refresh: {{ refresh }} seconds</p>
{% endif %}
<table>
<tr><th>Bid ID</th><th>Offer ID</th><th>Bid Status</th></tr>
{% for s in active_swaps %}
<tr><td><a href=/bid/{{ s[0] }}>{{ s[0] }}</a></td><td><a href=/offer/{{ s[1] }}>{{ s[1] }}</a></td><td>{{ s[2] }}</td></tr>
{% endfor %}
</table>
<p><a href="/">home</a></p>
</body></html>
Loading…
Cancel
Save