Dark mode tweaks

This commit is contained in:
Taylor Helsper 2019-11-09 13:01:21 -06:00
parent d2a9e33559
commit 3573b0bdcd
10 changed files with 93 additions and 80 deletions

View File

@ -5,7 +5,7 @@ from bitcoin_info import *
from device_info import * from device_info import *
#from bitcoin.wallet import * #from bitcoin.wallet import *
from subprocess import check_output, check_call from subprocess import check_output, check_call
from electrum_functions import * from electrum_info import *
from settings import read_ui_settings from settings import read_ui_settings
from user_management import check_logged_in from user_management import check_logged_in
import socket import socket

View File

@ -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())

View File

@ -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())

View File

@ -5,6 +5,8 @@ from prometheus_client.parser import text_string_to_metric_families
from bitcoin_info import * from bitcoin_info import *
from device_info import get_local_ip, skipped_product_key from device_info import get_local_ip, skipped_product_key
from user_management import check_logged_in from user_management import check_logged_in
from settings import read_ui_settings
from electrum_info import *
import requests import requests
import json import json
import time import time
@ -12,65 +14,6 @@ import subprocess
mynode_electrum_server = Blueprint('mynode_electrum_server',__name__) 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 ### Page functions
@mynode_electrum_server.route("/electrum-server") @mynode_electrum_server.route("/electrum-server")
@ -124,6 +67,6 @@ def electrum_server_page():
"electrs_onion_hostname": electrs_onion_hostname, "electrs_onion_hostname": electrs_onion_hostname,
"electrs_onion_password": electrs_onion_password, "electrs_onion_password": electrs_onion_password,
"electrs_onion_command": electrs_onion_command, "electrs_onion_command": electrs_onion_command,
"ui_settings": {'darkmode': False} "ui_settings": read_ui_settings()
} }
return render_template('electrum_server.html', **templateData) return render_template('electrum_server.html', **templateData)

View File

@ -495,3 +495,7 @@ a:active {
font-size: 14px; font-size: 14px;
font-family: "Courier New", Courier, monospace; font-family: "Courier New", Courier, monospace;
} }
.loading_image {
width: 128px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -44,7 +44,7 @@
{{ subheader_text }} {{ subheader_text }}
<br/><br/> <br/><br/>
<img src="{{ url_for('static', filename="images/loading.gif")}}"/> <img class="loading_image" src="{{ url_for('static', filename="images/loading.gif")}}"/>
</div> </div>
</body> </body>

View File

@ -349,14 +349,6 @@
</table> </table>
<div class="divider"></div> <div class="divider"></div>
<div class="settings_block_subheader">User Interface</div>
{% if ui_settings['darkmode'] %}
<a href="/settings/toggle-darkmode" class="ui-button ui-widget ui-corner-all settings_button">Disable Dark Mode</a>
{% else %}
<a href="/settings/toggle-darkmode" class="ui-button ui-widget ui-corner-all settings_button">Enable Dark Mode</a>
{% endif %}
<div class="divider"></div>
<div class="settings_block_subheader">Change Log</div> <div class="settings_block_subheader">Change Log</div>
<button id="show_mynode_changelog" class="ui-button ui-widget ui-corner-all settings_button">View Change Log</button> <button id="show_mynode_changelog" class="ui-button ui-widget ui-corner-all settings_button">View Change Log</button>
<div id="mynode_changelog" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{changelog}}</pre></div> <div id="mynode_changelog" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{changelog}}</pre></div>
@ -407,6 +399,20 @@
<div id="electrs_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{electrs_status}}</pre></div> <div id="electrs_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{electrs_status}}</pre></div>
</div> </div>
<div class="settings_block">
<div class="settings_block_header">User Interface</div>
<div class="settings_block_subheader">Dark Mode</div>
This will enable or disable dark mode in the user interface.
<br/>
{% if ui_settings['darkmode'] %}
<a href="/settings/toggle-darkmode" class="ui-button ui-widget ui-corner-all settings_button">Disable</a>
{% else %}
<a href="/settings/toggle-darkmode" class="ui-button ui-widget ui-corner-all settings_button">Enable</a>
{% endif %}
</div>
<div class="settings_block"> <div class="settings_block">
<div class="settings_block_header">Device</div> <div class="settings_block_header">Device</div>

View File

@ -7,7 +7,7 @@ from bitcoin_info import *
from lightning_info import * from lightning_info import *
from device_info import * from device_info import *
from enable_disable_functions import * from enable_disable_functions import *
from electrum_server import update_electrs_info from electrum_info import update_electrs_info
from requests import get from requests import get
# Info to get from the update threads # Info to get from the update threads