From fe83736ec715369385db1a5685fefc8e9362ee93 Mon Sep 17 00:00:00 2001 From: Gerlof van Ek Date: Mon, 14 Oct 2024 18:11:03 +0200 Subject: [PATCH] ui: Added custom order price tiles + Fixes --- basicswap/static/js/pricechart.js | 12 ++-- basicswap/templates/offers.html | 92 ++++++++++++++++++------------- 2 files changed, 61 insertions(+), 43 deletions(-) diff --git a/basicswap/static/js/pricechart.js b/basicswap/static/js/pricechart.js index 9e6b811..00a92c2 100644 --- a/basicswap/static/js/pricechart.js +++ b/basicswap/static/js/pricechart.js @@ -5,6 +5,7 @@ const config = { { symbol: 'BTC', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, { symbol: 'XMR', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, { symbol: 'PART', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, + { symbol: 'BCH', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, { symbol: 'PIVX', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, { symbol: 'FIRO', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, { symbol: 'DASH', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, @@ -13,8 +14,7 @@ const config = { { symbol: 'ETH', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, { symbol: 'DCR', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, { symbol: 'ZANO', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 }, - { symbol: 'WOW', usesCryptoCompare: false, usesCoinGecko: true, historicalDays: 30 }, - { symbol: 'BCH', usesCryptoCompare: true, usesCoinGecko: false, historicalDays: 30 } + { symbol: 'WOW', usesCryptoCompare: false, usesCoinGecko: true, historicalDays: 30 } ], apiEndpoints: { cryptoCompare: 'https://min-api.cryptocompare.com/data/pricemultifull', @@ -1172,7 +1172,7 @@ const app = { sortTable: (columnIndex) => { console.log(`Sorting column: ${columnIndex}`); - const sortableColumns = [1, 5, 6, 7]; // 1: Time, 5: Rate, 6: Market +/-, 7: Trade + const sortableColumns = [0, 5, 6, 7]; // 0: Time, 5: Rate, 6: Market +/-, 7: Trade if (!sortableColumns.includes(columnIndex)) { console.log(`Column ${columnIndex} is not sortable`); return; @@ -1200,7 +1200,7 @@ sortTable: (columnIndex) => { case 1: // Time column aValue = getSafeTextContent(a.querySelector('td:first-child .text-xs:first-child')); bValue = getSafeTextContent(b.querySelector('td:first-child .text-xs:first-child')); - // console.log(`Comparing times: "${aValue}" vs "${bValue}"`); + console.log(`Comparing times: "${aValue}" vs "${bValue}"`); const parseTime = (timeStr) => { const [value, unit] = timeStr.split(' '); @@ -1263,9 +1263,9 @@ sortTable: (columnIndex) => { if (tbody) { rows.forEach(row => tbody.appendChild(row)); } else { - // console.error("Table body not found."); + console.error("Table body not found."); } - // console.log('Sorting completed'); + console.log('Sorting completed'); }, initializeSelectImages: () => { diff --git a/basicswap/templates/offers.html b/basicswap/templates/offers.html index 3fc4a73..0d24aeb 100644 --- a/basicswap/templates/offers.html +++ b/basicswap/templates/offers.html @@ -35,7 +35,7 @@ function getAPIKeys() { -{% else %} + {% endif %} {% if sent_offers %} @@ -59,7 +59,6 @@ function getAPIKeys() { - {% include 'inc_messages.html' %} @@ -153,12 +152,13 @@ function getAPIKeys() {
-
- {% set coin_data = { +
+{% set coin_data = { 'BTC': {'name': 'Bitcoin', 'symbol': 'BTC', 'image': 'Bitcoin.png', 'show': true}, 'XMR': {'name': 'Monero', 'symbol': 'XMR', 'image': 'Monero.png', 'show': true}, 'PART': {'name': 'Particl', 'symbol': 'PART', 'image': 'Particl.png', 'show': true}, 'LTC': {'name': 'Litecoin', 'symbol': 'LTC', 'image': 'Litecoin.png', 'show': true}, + 'BCH': {'name': 'Bitcoin Cash', 'symbol': 'BCH', 'image': 'Bitcoin-Cash.png', 'show': true}, 'FIRO': {'name': 'Firo', 'symbol': 'FIRO', 'image': 'Firo.png', 'show': true}, 'PIVX': {'name': 'PIVX', 'symbol': 'PIVX', 'image': 'PIVX.png', 'show': true}, 'DASH': {'name': 'Dash', 'symbol': 'DASH', 'image': 'Dash.png', 'show': true}, @@ -166,47 +166,65 @@ function getAPIKeys() { 'DOGE': {'name': 'Dogecoin', 'symbol': 'DOGE', 'image': 'Doge.png', 'show': false}, 'DCR': {'name': 'Decred', 'symbol': 'DCR', 'image': 'Decred.png', 'show': true}, 'ZANO': {'name': 'Zano', 'symbol': 'ZANO', 'image': 'Zano.png', 'show': false}, - 'BCH': {'name': 'BCH', 'symbol': 'BCH', 'image': 'Bitcoin-cash.png', 'show': true}, 'WOW': {'name': 'Wownero', 'symbol': 'WOW', 'image': 'Wownero.png', 'show': true} } %} -{% for coin_symbol, coin in coin_data.items() if coin_symbol in enabled_chart_coins and coin.show %} -
-
-
- {{ coin.name }} -

- {{ coin.name }} {% if coin.symbol != coin.name %}({{ coin.symbol }}) - {% endif %} -

-
-
- -

-

-
-
-
-
-
- {% if coin_symbol != 'BTC' %} -
- BTC:
{% endif %}
- VOL: -
-
-
+ {% set custom_order = ['BTC', 'ETH', 'XMR', 'PART', 'LTC', 'BCH', 'FIRO', 'PIVX', 'DASH', 'DOGE', 'DCR', 'ZANO', 'WOW'] %} + + {% if enabled_chart_coins is string %} + {% if enabled_chart_coins == "" %} + {% set display_coins = coin_data.keys()|list %} + {% elif enabled_chart_coins == "all" %} + {% set display_coins = custom_order %} + {% else %} + {% set display_coins = enabled_chart_coins.split(',') %} + {% endif %} + {% else %} + {% set display_coins = enabled_chart_coins %} + {% endif %} + + {% for coin_symbol in custom_order %} + {% if coin_symbol in display_coins and coin_data[coin_symbol]['show'] %} +
+
+
+ {{ coin_data[coin_symbol]['name'] }} +

+ {{ coin_data[coin_symbol]['name'] }} {% if coin_data[coin_symbol]['symbol'] != coin_data[coin_symbol]['name'] %}({{ coin_data[coin_symbol]['symbol'] }}){% endif %} +

+
+
+ +

+

+
+
+
+
+
+ {% if coin_symbol != 'BTC' %} +
+ BTC: +
+ {% endif %} +
+ VOL: +
+
+
+
-
- {% endfor %} -
+ {% endif %} + {% endfor %} +
-{% endif %} +{% endif %} +