ui: New offer, when 'Lock Rate' is set rate must update if it's empty.
Remove invalid coins from coin from list.
This commit is contained in:
parent
001e9976aa
commit
81e9924654
@ -63,6 +63,8 @@ from .ui import (
|
|||||||
env = Environment(loader=PackageLoader('basicswap', 'templates'))
|
env = Environment(loader=PackageLoader('basicswap', 'templates'))
|
||||||
env.filters['formatts'] = format_timestamp
|
env.filters['formatts'] = format_timestamp
|
||||||
|
|
||||||
|
invalid_coins_from = (Coins.XMR, Coins.PART_ANON)
|
||||||
|
|
||||||
|
|
||||||
def value_or_none(v):
|
def value_or_none(v):
|
||||||
if v == -1 or v == '-1':
|
if v == -1 or v == '-1':
|
||||||
@ -78,16 +80,23 @@ def getCoinName(c):
|
|||||||
return chainparams[c]['name'].capitalize()
|
return chainparams[c]['name'].capitalize()
|
||||||
|
|
||||||
|
|
||||||
def listAvailableCoins(swap_client, with_variants=True):
|
def listAvailableCoins(swap_client, with_variants=True, split_from=False):
|
||||||
|
coins_from = []
|
||||||
coins = []
|
coins = []
|
||||||
for k, v in swap_client.coin_clients.items():
|
for k, v in swap_client.coin_clients.items():
|
||||||
if k not in chainparams:
|
if k not in chainparams:
|
||||||
continue
|
continue
|
||||||
if v['connection_type'] == 'rpc':
|
if v['connection_type'] == 'rpc':
|
||||||
coins.append((int(k), getCoinName(k)))
|
coins.append((int(k), getCoinName(k)))
|
||||||
|
if split_from and k not in invalid_coins_from:
|
||||||
|
coins_from.append(coins[-1])
|
||||||
if with_variants and k == Coins.PART:
|
if with_variants and k == Coins.PART:
|
||||||
coins.append((int(Coins.PART_ANON), getCoinName(Coins.PART_ANON)))
|
for v in (Coins.PART_ANON, Coins.PART_BLIND):
|
||||||
coins.append((int(Coins.PART_BLIND), getCoinName(Coins.PART_BLIND)))
|
coins.append((int(v), getCoinName(v)))
|
||||||
|
if split_from and v not in invalid_coins_from:
|
||||||
|
coins_from.append(coins[-1])
|
||||||
|
if split_from:
|
||||||
|
return coins_from, coins
|
||||||
return coins
|
return coins
|
||||||
|
|
||||||
|
|
||||||
@ -731,11 +740,13 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||||||
else:
|
else:
|
||||||
template = env.get_template('offer_new_1.html')
|
template = env.get_template('offer_new_1.html')
|
||||||
|
|
||||||
|
coins_from, coins_to = listAvailableCoins(swap_client, split_from=True)
|
||||||
return bytes(template.render(
|
return bytes(template.render(
|
||||||
title=self.server.title,
|
title=self.server.title,
|
||||||
h2=self.server.title,
|
h2=self.server.title,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
coins=listAvailableCoins(swap_client),
|
coins_from=coins_from,
|
||||||
|
coins=coins_to,
|
||||||
addrs=swap_client.listSmsgAddresses('offer_send_from'),
|
addrs=swap_client.listSmsgAddresses('offer_send_from'),
|
||||||
addrs_to=swap_client.listSmsgAddresses('offer_send_to'),
|
addrs_to=swap_client.listSmsgAddresses('offer_send_to'),
|
||||||
data=page_data,
|
data=page_data,
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<tr class="padded_row"><td class="bold">Coin From</td><td>
|
<tr class="padded_row"><td class="bold">Coin From</td><td>
|
||||||
<select name="coin_from_" disabled><option value="-1">-- Select Coin --</option>
|
<select name="coin_from_" disabled><option value="-1">-- Select Coin --</option>
|
||||||
{% for c in coins %}
|
{% for c in coins_from %}
|
||||||
<option{% if data.coin_from==c[0] %} selected{% endif %} value="{{ c[0] }}">{{ c[1] }}</option>
|
<option{% if data.coin_from==c[0] %} selected{% endif %} value="{{ c[0] }}">{{ c[1] }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<tr><td>Coin From</td><td>
|
<tr><td>Coin From</td><td>
|
||||||
<select id="coin_from" name="coin_from" onchange="set_rate('coin_from');"><option value="-1">-- Select Coin --</option>
|
<select id="coin_from" name="coin_from" onchange="set_rate('coin_from');"><option value="-1">-- Select Coin --</option>
|
||||||
{% for c in coins %}
|
{% for c in coins_from %}
|
||||||
<option{% if data.coin_from==c[0] %} selected{% endif %} value="{{ c[0] }}">{{ c[1] }}</option>
|
<option{% if data.coin_from==c[0] %} selected{% endif %} value="{{ c[0] }}">{{ c[1] }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
@ -102,7 +102,7 @@ function set_rate(value_changed) {
|
|||||||
const amt_from = document.getElementById('amt_from').value;
|
const amt_from = document.getElementById('amt_from').value;
|
||||||
const amt_to = document.getElementById('amt_to').value;
|
const amt_to = document.getElementById('amt_to').value;
|
||||||
const rate = document.getElementById('rate').value;
|
const rate = document.getElementById('rate').value;
|
||||||
const lock_rate = document.getElementById('rate_lock').checked;
|
const lock_rate = rate == '' ? false : document.getElementById('rate_lock').checked;
|
||||||
|
|
||||||
if (coin_from == '-1' || coin_to == '-1') {
|
if (coin_from == '-1' || coin_to == '-1') {
|
||||||
return;
|
return;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<tr class="padded_row"><td class="bold">Coin From</td><td>
|
<tr class="padded_row"><td class="bold">Coin From</td><td>
|
||||||
<select name="coin_from_" disabled><option value="-1">-- Select Coin --</option>
|
<select name="coin_from_" disabled><option value="-1">-- Select Coin --</option>
|
||||||
{% for c in coins %}
|
{% for c in coins_from %}
|
||||||
<option{% if data.coin_from==c[0] %} selected{% endif %} value="{{ c[0] }}">{{ c[1] }}</option>
|
<option{% if data.coin_from==c[0] %} selected{% endif %} value="{{ c[0] }}">{{ c[1] }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr><td>Coin From</td><td>
|
<tr><td>Coin From</td><td>
|
||||||
<select name="coin_from"><option value="-1"{% if filters.coin_from==-1 %} selected{% endif %}>-- Any Coin --</option>
|
<select name="coin_from"><option value="-1"{% if filters.coin_from==-1 %} selected{% endif %}>-- Any Coin --</option>
|
||||||
{% for c in coins %}
|
{% for c in coins_from %}
|
||||||
<option value="{{ c[0] }}"{% if filters.coin_from==c[0] %} selected{% endif %}>{{ c[1] }}</option>
|
<option value="{{ c[0] }}"{% if filters.coin_from==c[0] %} selected{% endif %}>{{ c[1] }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user