diff --git a/rootfs/standard/var/www/mynode/bitcoind.py b/rootfs/standard/var/www/mynode/bitcoind.py index 2922c978..1acd75f8 100644 --- a/rootfs/standard/var/www/mynode/bitcoind.py +++ b/rootfs/standard/var/www/mynode/bitcoind.py @@ -5,7 +5,7 @@ from bitcoin_info import * from device_info import * #from bitcoin.wallet import * from subprocess import check_output, check_call -from electrum_functions import * +from electrum_info import * from settings import read_ui_settings from user_management import check_logged_in import socket diff --git a/rootfs/standard/var/www/mynode/electrum_functions.py b/rootfs/standard/var/www/mynode/electrum_functions.py deleted file mode 100644 index da7be1a1..00000000 --- a/rootfs/standard/var/www/mynode/electrum_functions.py +++ /dev/null @@ -1,9 +0,0 @@ -import socket -import json - - -def get_from_electrum(method, params=[]): - params = [params] if type(params) is not list else params - s = socket.create_connection(('127.0.0.1', 50001)) - s.send(json.dumps({"id": 0, "method": method, "params": params}).encode() + b'\n') - return json.loads(s.recv(99999)[:-1].decode()) \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/electrum_info.py b/rootfs/standard/var/www/mynode/electrum_info.py new file mode 100644 index 00000000..de196396 --- /dev/null +++ b/rootfs/standard/var/www/mynode/electrum_info.py @@ -0,0 +1,69 @@ +from bitcoin_info import get_bitcoin_block_height +import socket +import json + + +electrum_server_current_block = None +electrs_active = False + +def get_electrum_server_current_block(): + global electrum_server_current_block + return electrum_server_current_block + +def update_electrs_info(): + global electrum_server_current_block + + try: + raw_data = requests.get("http://localhost:4224") + prom_data = text_string_to_metric_families(raw_data.text) + for family in prom_data: + for sample in family.samples: + if sample.name == "electrs_index_height": + electrum_server_current_block = int(sample.value) + except: + pass + +def is_electrs_active(): + global electrs_active + return electrs_active + +def get_electrs_status(): + global electrum_server_current_block + global electrs_active + bitcoin_block_height = get_bitcoin_block_height() + log = "" + try: + log += subprocess.check_output("journalctl --unit=electrs --no-pager | tail -n 100", shell=True) + except: + log += "" + lines = log.splitlines() + lines.reverse() + for line in lines: + if "left to index)" in line: + break + elif "Checking if Bitcoin is synced..." in line or "NetworkInfo {" in line or "BlockchainInfo {" in line: + return "Starting..." + elif "downloading 100000 block headers" in line: + return "Downloading headers..." + elif "starting full compaction" in line: + return "Compressing data..." + elif "enabling auto-compactions" in line: + break + elif "RPC server running on" in line: + break + + if electrum_server_current_block != None and bitcoin_block_height != None: + if electrum_server_current_block < bitcoin_block_height - 10: + percent = 100.0 * (float(electrum_server_current_block) / bitcoin_block_height) + return "Syncing... {:.2f}%".format(abs(percent)) + else: + electrs_active = True + return "Running" + return "" + + +def get_from_electrum(method, params=[]): + params = [params] if type(params) is not list else params + s = socket.create_connection(('127.0.0.1', 50001)) + s.send(json.dumps({"id": 0, "method": method, "params": params}).encode() + b'\n') + return json.loads(s.recv(99999)[:-1].decode()) diff --git a/rootfs/standard/var/www/mynode/electrum_server.py b/rootfs/standard/var/www/mynode/electrum_server.py index b48a9e9a..19fa907a 100644 --- a/rootfs/standard/var/www/mynode/electrum_server.py +++ b/rootfs/standard/var/www/mynode/electrum_server.py @@ -5,6 +5,8 @@ from prometheus_client.parser import text_string_to_metric_families from bitcoin_info import * from device_info import get_local_ip, skipped_product_key from user_management import check_logged_in +from settings import read_ui_settings +from electrum_info import * import requests import json import time @@ -12,65 +14,6 @@ import subprocess mynode_electrum_server = Blueprint('mynode_electrum_server',__name__) -electrum_server_current_block = None -eelctrs_active = False - - -def update_electrs_info(): - global electrum_server_current_block - - try: - raw_data = requests.get("http://localhost:4224") - prom_data = text_string_to_metric_families(raw_data.text) - for family in prom_data: - for sample in family.samples: - if sample.name == "electrs_index_height": - electrum_server_current_block = int(sample.value) - except: - pass - -def is_electrs_active(): - global eelctrs_active - return eelctrs_active - -def get_electrs_status(): - global electrum_server_current_block - global eelctrs_active - bitcoin_block_height = get_bitcoin_block_height() - log = "" - try: - log += subprocess.check_output("journalctl --unit=electrs --no-pager | tail -n 100", shell=True) - except: - log += "" - lines = log.splitlines() - lines.reverse() - for line in lines: - if "left to index)" in line: - break - elif "Checking if Bitcoin is synced..." in line or "NetworkInfo {" in line or "BlockchainInfo {" in line: - return "Starting..." - elif "downloading 100000 block headers" in line: - return "Downloading headers..." - elif "starting full compaction" in line: - return "Compressing data..." - elif "enabling auto-compactions" in line: - break - elif "RPC server running on" in line: - break - - if electrum_server_current_block != None and bitcoin_block_height != None: - if electrum_server_current_block < bitcoin_block_height - 10: - percent = 100.0 * (float(electrum_server_current_block) / bitcoin_block_height) - return "Syncing... {:.2f}%".format(abs(percent)) - else: - eelctrs_active = True - return "Running" - return "" - - -def get_electrum_server_current_block(): - global electrum_server_current_block - return electrum_server_current_block ### Page functions @mynode_electrum_server.route("/electrum-server") @@ -124,6 +67,6 @@ def electrum_server_page(): "electrs_onion_hostname": electrs_onion_hostname, "electrs_onion_password": electrs_onion_password, "electrs_onion_command": electrs_onion_command, - "ui_settings": {'darkmode': False} + "ui_settings": read_ui_settings() } return render_template('electrum_server.html', **templateData) diff --git a/rootfs/standard/var/www/mynode/static/css/mynode.css b/rootfs/standard/var/www/mynode/static/css/mynode.css index ac31ebd6..2fc0267b 100644 --- a/rootfs/standard/var/www/mynode/static/css/mynode.css +++ b/rootfs/standard/var/www/mynode/static/css/mynode.css @@ -494,4 +494,8 @@ a:active { height: 400px; font-size: 14px; font-family: "Courier New", Courier, monospace; +} + +.loading_image { + width: 128px; } \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/static/images/lndconnect.png b/rootfs/standard/var/www/mynode/static/images/lndconnect.png index bdde6cc1..32523f9c 100644 Binary files a/rootfs/standard/var/www/mynode/static/images/lndconnect.png and b/rootfs/standard/var/www/mynode/static/images/lndconnect.png differ diff --git a/rootfs/standard/var/www/mynode/static/images/loading.gif b/rootfs/standard/var/www/mynode/static/images/loading.gif index 0424aa4f..9e150a9c 100644 Binary files a/rootfs/standard/var/www/mynode/static/images/loading.gif and b/rootfs/standard/var/www/mynode/static/images/loading.gif differ diff --git a/rootfs/standard/var/www/mynode/templates/reboot.html b/rootfs/standard/var/www/mynode/templates/reboot.html index 63b534b7..8744d284 100644 --- a/rootfs/standard/var/www/mynode/templates/reboot.html +++ b/rootfs/standard/var/www/mynode/templates/reboot.html @@ -44,7 +44,7 @@ {{ subheader_text }}

- + diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index 378d0fc2..e37c88d3 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -349,14 +349,6 @@
-
User Interface
- {% if ui_settings['darkmode'] %} - Disable Dark Mode - {% else %} - Enable Dark Mode - {% endif %} -
-
Change Log
@@ -407,6 +399,20 @@ +
+
User Interface
+ +
Dark Mode
+ This will enable or disable dark mode in the user interface. +
+ {% if ui_settings['darkmode'] %} + Disable + {% else %} + Enable + {% endif %} + +
+
Device
diff --git a/rootfs/standard/var/www/mynode/thread_functions.py b/rootfs/standard/var/www/mynode/thread_functions.py index 18a82fa0..bfa6d838 100644 --- a/rootfs/standard/var/www/mynode/thread_functions.py +++ b/rootfs/standard/var/www/mynode/thread_functions.py @@ -7,7 +7,7 @@ from bitcoin_info import * from lightning_info import * from device_info import * from enable_disable_functions import * -from electrum_server import update_electrs_info +from electrum_info import update_electrs_info from requests import get # Info to get from the update threads