From 69b195e317657af80b587f0234fe1cb8c785c06b Mon Sep 17 00:00:00 2001 From: gerlofvanek Date: Thu, 29 Feb 2024 10:28:37 +0100 Subject: [PATCH 1/2] ui: Styling / Bug fixes --- basicswap/templates/header.html | 7 +- basicswap/templates/offers.html | 168 +++++++++++++++++--------------- basicswap/ui/page_offers.py | 31 ++++-- 3 files changed, 115 insertions(+), 91 deletions(-) diff --git a/basicswap/templates/header.html b/basicswap/templates/header.html index 9e50ea9..a99af43 100644 --- a/basicswap/templates/header.html +++ b/basicswap/templates/header.html @@ -528,16 +528,15 @@ let json = JSON.parse(event.data); let event_message = 'Unknown event'; if (json['event'] == 'new_offer') { - event_message = '
'; + event_message = '
'; } else if (json['event'] == 'new_bid') { - event_message = '
'; + event_message = '
'; } else if (json['event'] == 'bid_accepted') { - event_message = '
'; + event_message = '
'; } let messages = document.getElementById('ul_updates'), message = document.createElement('li'); diff --git a/basicswap/templates/offers.html b/basicswap/templates/offers.html index 3a683eb..fc7076c 100644 --- a/basicswap/templates/offers.html +++ b/basicswap/templates/offers.html @@ -757,34 +757,34 @@ const chart = new Chart(ctx, {
- +
- + @@ -798,74 +798,85 @@ const chart = new Chart(ctx, { {% for o in offers %} - + - - + + - + {% if o[9] == true %} - + - + {% else %} {% endif %} + - - - + {% if o[9] == true %} - + - + {% else %} {% endif %} - + - - - - - - - + {% endfor %}
-
+
Date/Time at
-
+
Recipient
-
+
You get
-
+
You Send
-
- Rate +
+ Details
- - - - - - -
-
Posted: {{ o[0] }} ago
-
Expires in: {{ o[13] }}
-
+
+
+ + + + + + +
+
Posted: {{ o[0] }} ago
+
Expires in: {{ o[13] }}
+
+
- {{ o[8] }} + + {{ o[8]|truncate(20, true, '...', 0) }} -
- {{ o[3] }} +
+ {{ o[3] }}
{{ o[5]|truncate(8, true, '', 0) }} {{ o[3] }}
-
{{ o[3] }}/{{ o[2] }}
+
+ +
{{ o[17] }}/{{ o[16] }}
-
- {{ o[2] }} -
-
- {{ o[4]|truncate(8, true, '', 0) }} {{ o[2] }} -
- -
-
{{ o[2] }}/{{ o[3] }}
+
+ + {{ o[2] }} + +
+
+ {{ o[2] }} +
+
+ {{ o[4]|truncate(8, true, '', 0) }} {{ o[16] }}/{{ o[17] }} +
+
+
+
-
@@ -875,58 +886,60 @@ const chart = new Chart(ctx, { {{ o[4]|truncate(8,true,'',0) }} {{ o[2] }}
+
{{ o[2] }}/{{ o[3] }}
-
- {{ o[3] }} -
-
- {{ o[5]|truncate(8, true, '', 0) }} {{ o[3] }} -
-
-
{{ o[3] }}/{{ o[2] }}
+
+ + {{ o[3] }} + +
+
+ {{ o[3] }} +
+
+ {{ o[5]|truncate(8, true, '', 0) }} {{ o[17] }}/{{ o[16] }} +
+
+
+
-
- - - -
+
+ +
Rate: {{ o[6]|truncate(8,true,'',0) }} + + +
Profit/Loss: +
Swap Type: {{ o[14] }}
+
Amount Variable: {{ o[15] }}
+
Network: {{ o[7] }}
- {% if o[9]==true %} Edit {% else %} Swap {% endif %} + +
@@ -969,9 +982,9 @@ const chart = new Chart(ctx, {
-{% include 'footer.html' %} + +{% include 'footer.html' %} diff --git a/basicswap/ui/page_offers.py b/basicswap/ui/page_offers.py index d6521c0..76dc1e2 100644 --- a/basicswap/ui/page_offers.py +++ b/basicswap/ui/page_offers.py @@ -661,25 +661,31 @@ def page_offer(self, url_split, post_string): 'summary': summary, }) -def format_timestamp(timestamp): +def format_timestamp(timestamp, is_expired=False): current_time = int(time.time()) - time_diff = current_time - timestamp - if time_diff <= 172800: # Within the last 48 hours + if is_expired: + time_diff = timestamp - current_time + if time_diff <= 0: + return "Expired" + else: + time_diff = current_time - timestamp + + if time_diff <= 172800: hours_ago = time_diff // 3600 minutes_ago = (time_diff % 3600) // 60 - if hours_ago == 0: # Less than an hour ago + if hours_ago == 0: if minutes_ago == 1: return "1 min" else: return f"{minutes_ago} mins" - elif hours_ago == 1: # Within the last hour + elif hours_ago == 1: if minutes_ago == 0: return "1h ago" else: return f"1h {minutes_ago}min" - else: # More than 1 hour ago + else: if minutes_ago == 0: return f"{int(hours_ago)}h" else: @@ -687,7 +693,6 @@ def format_timestamp(timestamp): else: return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)) - def page_offers(self, url_split, post_string, sent=False): server = self.server swap_client = server.swap_client @@ -755,7 +760,9 @@ def page_offers(self, url_split, post_string, sent=False): is_expired = o.expire_at <= now amount_negotiable = "Yes" if o.amount_negotiable else "No" formatted_created_at = format_timestamp(o.created_at) - formatted_expired_at = format_timestamp(o.expire_at) + formatted_expired_at = format_timestamp(o.expire_at, is_expired=True) + tla_from = ci_from.ticker() + tla_to = ci_to.ticker() formatted_offers.append(( formatted_created_at, o.offer_id.hex(), @@ -772,7 +779,9 @@ def page_offers(self, url_split, post_string, sent=False): o.active_ind, formatted_expired_at, strSwapDesc(o.swap_type), - amount_negotiable)) + amount_negotiable, + tla_from, + tla_to)) coins_from, coins_to = listAvailableCoins(swap_client, split_from=True) @@ -786,7 +795,7 @@ def page_offers(self, url_split, post_string, sent=False): template = server.env.get_template('offers.html') return self.render_template(template, { 'page_type': 'Your Offers' if sent else 'Network Order Book', - 'page_button': 'hidden' if sent or offers_count <= 30 else '', # Conditionally hide the button + 'page_button': 'hidden' if sent or offers_count <= 30 else '', 'page_type_description': 'Your entire offer history.' if sent else 'Consult available offers in the order book and initiate a coin swap.', 'messages': messages, 'show_chart': False if sent else swap_client.settings.get('show_chart', True), @@ -799,4 +808,6 @@ def page_offers(self, url_split, post_string, sent=False): 'summary': summary, 'sent_offers': sent, 'offers_count': offers_count, + 'tla_from': tla_from, + 'tla_to': tla_to, }) From e464599cf7da81cdb1b7773b2b9f0a4cad596787 Mon Sep 17 00:00:00 2001 From: gerlofvanek Date: Thu, 29 Feb 2024 13:32:13 +0100 Subject: [PATCH 2/2] ui: Bug fixes --- basicswap/templates/offers.html | 54 ++++++++++++++++++--------------- basicswap/ui/page_offers.py | 28 ++++++++++------- basicswap/ui/util.py | 2 +- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/basicswap/templates/offers.html b/basicswap/templates/offers.html index fc7076c..2fc90f1 100644 --- a/basicswap/templates/offers.html +++ b/basicswap/templates/offers.html @@ -810,7 +810,7 @@ const chart = new Chart(ctx, {
-
Posted: {{ o[0] }} ago
+
Posted: {{ o[0] }}
Expires in: {{ o[13] }}
@@ -839,18 +839,21 @@ const chart = new Chart(ctx, { {% if o[9] == true %} -
- {{ o[3] }} -
-
- {{ o[5]|truncate(8, true, '', 0) }} {{ o[3] }} -
-
-
- -
{{ o[17] }}/{{ o[16] }}
+
+ + {{ o[3] }} + +
+
+ {{ o[3] }} +
+
+ {{ o[5]|truncate(8, true, '', 0) }} {{ o[17] }}/{{ o[16] }} +
+
+
+
-
@@ -879,17 +882,21 @@ const chart = new Chart(ctx, { {% if o[9] == true %} -
- {{ o[2] }} -
-
- {{ o[4]|truncate(8,true,'',0) }} {{ o[2] }} -
-
-
-
{{ o[2] }}/{{ o[3] }}
+
+ + {{ o[2] }} + +
+
+ {{ o[2] }} +
+
+ {{ o[4]|truncate(8, true, '', 0) }} {{ o[16] }}/{{ o[17] }} +
+
+
+
-
@@ -917,7 +924,6 @@ const chart = new Chart(ctx, { -
Rate: {{ o[6]|truncate(8,true,'',0) }} @@ -963,7 +969,7 @@ const chart = new Chart(ctx, {

Page: {{ filters.page_no }}

- {% if offers_count > 10 %} + {% if offers_count > 15 %}