ui: Add websocket notifications.

This commit is contained in:
tecnovert
2022-07-31 19:33:01 +02:00
parent 6cc54d9c61
commit 1601a57aed
21 changed files with 830 additions and 215 deletions

View File

@@ -4,8 +4,6 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
import os
from .util import (
PAGE_LIMIT,
get_data_entry,
@@ -51,14 +49,11 @@ def page_automation_strategies(self, url_split, post_string):
formatted_strategies.append((s[0], s[1], strConcepts(s[2])))
template = server.env.get_template('automation_strategies.html')
return bytes(template.render(
title=server.title,
h2=server.title,
messages=messages,
filters=filters,
strategies=formatted_strategies,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
'filters': filters,
'strategies': formatted_strategies,
})
def page_automation_strategy_new(self, url_split, post_string):
@@ -69,12 +64,9 @@ def page_automation_strategy_new(self, url_split, post_string):
form_data = self.checkForm(post_string, 'automationstrategynew', messages)
template = server.env.get_template('automation_strategy_new.html')
return bytes(template.render(
title=server.title,
h2=server.title,
messages=messages,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
})
def page_automation_strategy(self, url_split, post_string):
@@ -101,10 +93,7 @@ def page_automation_strategy(self, url_split, post_string):
}
template = server.env.get_template('automation_strategy.html')
return bytes(template.render(
title=server.title,
h2=server.title,
messages=messages,
strategy=formatted_strategy,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
'strategy': formatted_strategy,
})

View File

@@ -4,7 +4,6 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
import os
import traceback
from .util import (
@@ -308,18 +307,15 @@ def page_newoffer(self, url_split, post_string):
automation_filters['type_ind'] = Concepts.OFFER
automation_strategies = swap_client.listAutomationStrategies(automation_filters)
return bytes(template.render(
title=server.title,
h2=server.title,
messages=messages,
coins_from=coins_from,
coins=coins_to,
addrs=swap_client.listSmsgAddresses('offer_send_from'),
addrs_to=swap_client.listSmsgAddresses('offer_send_to'),
data=page_data,
automation_strategies=automation_strategies,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
'coins_from': coins_from,
'coins': coins_to,
'addrs': swap_client.listSmsgAddresses('offer_send_from'),
'addrs_to': swap_client.listSmsgAddresses('offer_send_to'),
'data': page_data,
'automation_strategies': automation_strategies,
})
def page_offer(self, url_split, post_string):
@@ -469,17 +465,14 @@ def page_offer(self, url_split, post_string):
data['amt_swapped'] = ci_from.format_amount(amt_swapped)
template = server.env.get_template('offer.html')
return bytes(template.render(
title=server.title,
h2=server.title,
offer_id=offer_id.hex(),
sent_bid_id=sent_bid_id,
messages=messages,
data=data,
bids=formatted_bids,
addrs=None if show_bid_form is None else swap_client.listSmsgAddresses('bid'),
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'offer_id': offer_id.hex(),
'sent_bid_id': sent_bid_id,
'messages': messages,
'data': data,
'bids': formatted_bids,
'addrs': None if show_bid_form is None else swap_client.listSmsgAddresses('bid'),
})
def page_offers(self, url_split, post_string, sent=False):
@@ -540,12 +533,10 @@ def page_offers(self, url_split, post_string, sent=False):
ci_from.format_amount(completed_amount)))
template = server.env.get_template('offers.html')
return bytes(template.render(
title=server.title,
h2=server.title,
coins=listAvailableCoins(swap_client),
messages=messages,
filters=filters,
offers=formatted_offers,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
'coins': listAvailableCoins(swap_client),
'messages': messages,
'filters': filters,
'offers': formatted_offers,
})

View File

@@ -4,9 +4,6 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
import os
def extract_data(bytes_in):
str_in = bytes_in.decode('utf-8')
start = str_in.find('=')
@@ -37,10 +34,7 @@ def page_tor(self, url_split, post_string):
messages = []
template = self.server.env.get_template('tor.html')
return bytes(template.render(
title=self.server.title,
h2=self.server.title,
messages=messages,
data=page_data,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
'data': page_data,
})

View File

@@ -4,7 +4,6 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
import os
import traceback
from .util import (
@@ -151,13 +150,10 @@ def page_wallets(self, url_split, post_string):
wallets_formatted.append(wf)
template = server.env.get_template('wallets.html')
return bytes(template.render(
title=server.title,
h2=server.title,
messages=messages,
wallets=wallets_formatted,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
'wallets': wallets_formatted,
})
def page_wallet(self, url_split, post_string):
@@ -304,10 +300,7 @@ def page_wallet(self, url_split, post_string):
wallet_data['utxo_groups'] = utxo_groups
template = server.env.get_template('wallet.html')
return bytes(template.render(
title=server.title,
h2=server.title,
messages=messages,
w=wallet_data,
form_id=os.urandom(8).hex(),
), 'UTF-8')
return self.render_template(template, {
'messages': messages,
'w': wallet_data,
})