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