From a4683c845058105ce67b94b84e1f1c3220f94313 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sun, 10 Apr 2022 22:24:56 +0200 Subject: [PATCH] ui: Add sent filter to offers page. --- basicswap/templates/offers.html | 8 +++++++- basicswap/ui/page_offers.py | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/basicswap/templates/offers.html b/basicswap/templates/offers.html index 1f26cdb..f8c18f3 100644 --- a/basicswap/templates/offers.html +++ b/basicswap/templates/offers.html @@ -1,6 +1,6 @@ {% include 'header.html' %} -

{{ page_type }} Offers

+

Network Offers

{% if refresh %}

Page Refresh: {{ refresh }} seconds

{% endif %} @@ -35,6 +35,12 @@ +Sent From Node + + Page: {{ filters.page_no }} diff --git a/basicswap/ui/page_offers.py b/basicswap/ui/page_offers.py index 8f4bb7c..cafdf97 100644 --- a/basicswap/ui/page_offers.py +++ b/basicswap/ui/page_offers.py @@ -32,6 +32,7 @@ def page_offers(self, url_split, post_string, sent=False): 'limit': PAGE_LIMIT, 'sort_by': 'created_at', 'sort_dir': 'desc', + 'sent_from': 'any' if sent is False else 'only', } messages = [] form_data = self.checkForm(post_string, 'offers', messages) @@ -47,6 +48,10 @@ def page_offers(self, url_split, post_string, sent=False): sort_dir = get_data_entry(form_data, 'sort_dir') ensure(sort_dir in ['asc', 'desc'], 'Invalid sort dir') filters['sort_dir'] = sort_dir + if have_data_entry(form_data, 'sent_from'): + sent_from = get_data_entry(form_data, 'sent_from') + ensure(sent_from in ['any', 'only'], 'Invalid sent filter') + filters['sent_from'] = sent_from if form_data and have_data_entry(form_data, 'pageback'): filters['page_no'] = int(form_data[b'pageno'][0]) - 1 @@ -58,6 +63,10 @@ def page_offers(self, url_split, post_string, sent=False): if filters['page_no'] > 1: filters['offset'] = (filters['page_no'] - 1) * PAGE_LIMIT + if filters['sent_from'] == 'only': + sent = True + else: + sent = False offers = swap_client.listOffers(sent, filters) formatted_offers = [] @@ -79,7 +88,6 @@ def page_offers(self, url_split, post_string, sent=False): return bytes(template.render( title=self.server.title, h2=self.server.title, - page_type='Sent' if sent else 'Received', coins=listAvailableCoins(swap_client), messages=messages, filters=filters,