diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index dd246846..3ac28c8f 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -59,17 +59,11 @@ if [ ! -f /var/lib/mynode/.expanded_rootfs ]; then fi # Customize logo for resellers -if [ -f /opt/mynode/custom/reseller ]; then - if [ -f /opt/mynode/custom/logo_custom.png ]; then - cp -f /opt/mynode/custom/logo_custom.png /var/www/mynode/static/images/logo.png - else - cp -f /var/www/mynode/static/images/logo_original.png /var/www/mynode/static/images/logo.png - fi - if [ -f /opt/mynode/custom/logo_dark_custom.png ]; then - cp -f /opt/mynode/custom/logo_dark_custom.png /var/www/mynode/static/images/logo_dark.png - else - cp -f /var/www/mynode/static/images/logo_dark_original.png /var/www/mynode/static/images/logo_dark.png - fi +if [ -f /opt/mynode/custom/logo_custom.png ]; then + cp -f /opt/mynode/custom/logo_custom.png /var/www/mynode/static/images/logo_custom.png +fi +if [ -f /opt/mynode/custom/logo_dark_custom.png ]; then + cp -f /opt/mynode/custom/logo_dark_custom.png /var/www/mynode/static/images/logo_dark_custom.png fi diff --git a/rootfs/standard/var/www/mynode/bitcoind.py b/rootfs/standard/var/www/mynode/bitcoind.py index 4732734d..aca6ef36 100644 --- a/rootfs/standard/var/www/mynode/bitcoind.py +++ b/rootfs/standard/var/www/mynode/bitcoind.py @@ -6,7 +6,6 @@ from device_info import * #from bitcoin.wallet import * from subprocess import check_output, check_call from electrum_info import * -from settings import read_ui_settings from user_management import check_logged_in import socket import hashlib diff --git a/rootfs/standard/var/www/mynode/caravan.py b/rootfs/standard/var/www/mynode/caravan.py index 69f0e0f7..92e92393 100644 --- a/rootfs/standard/var/www/mynode/caravan.py +++ b/rootfs/standard/var/www/mynode/caravan.py @@ -1,6 +1,5 @@ from flask import Blueprint, render_template, redirect -from settings import read_ui_settings from user_management import check_logged_in from device_info import * import subprocess diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index 2a783eca..bbd79d5f 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -3,6 +3,7 @@ from threading import Timer from werkzeug.routing import RequestRedirect from flask import flash import time +import json import os import subprocess @@ -334,6 +335,57 @@ def get_journalctl_log(service_name): log = "ERROR" return log +#================================== +# UI Functions +#================================== + +def read_ui_settings(): + ui_hdd_file = '/mnt/hdd/mynode/settings/ui.json' + ui_mynode_file = '/home/bitcoin/.mynode/ui.json' + + # read ui.json from HDD + if os.path.isfile(ui_hdd_file): + with open(ui_hdd_file, 'r') as fp: + ui_settings = json.load(fp) + # read ui.json from mynode + elif os.path.isfile(ui_mynode_file): + with open(ui_mynode_file, 'r') as fp: + ui_settings = json.load(fp) + # if ui.json is not found anywhere, use default settings + else: + ui_settings = {'darkmode': False} + + # Set reseller + ui_settings["reseller"] = is_device_from_reseller() + + return ui_settings + +def write_ui_settings(ui_settings): + ui_hdd_file = '/mnt/hdd/mynode/settings/ui.json' + ui_mynode_file = '/home/bitcoin/.mynode/ui.json' + + try: + with open(ui_hdd_file, 'w') as fp: + json.dump(ui_settings, fp) + except: + pass + + with open(ui_mynode_file, 'w') as fp: + json.dump(ui_settings, fp) + +def is_darkmode_enabled(): + ui_settings = read_ui_settings() + return ui_settings['darkmode'] + +def disable_darkmode(): + ui_settings = read_ui_settings() + ui_settings['darkmode'] = False + write_ui_settings(ui_settings) + +def enable_darkmode(): + ui_settings = read_ui_settings() + ui_settings['darkmode'] = True + write_ui_settings(ui_settings) #================================== # Uploader Functions diff --git a/rootfs/standard/var/www/mynode/dojo.py b/rootfs/standard/var/www/mynode/dojo.py index ed9efd9e..049a862c 100644 --- a/rootfs/standard/var/www/mynode/dojo.py +++ b/rootfs/standard/var/www/mynode/dojo.py @@ -1,6 +1,6 @@ from flask import Blueprint, render_template, redirect -from settings import read_ui_settings +from device_info import read_ui_settings from user_management import check_logged_in from enable_disable_functions import is_dojo_enabled, enable_dojo, disable_dojo, is_dojo_installed from bitcoin_info import get_mynode_block_height diff --git a/rootfs/standard/var/www/mynode/electrum_server.py b/rootfs/standard/var/www/mynode/electrum_server.py index de2ac159..539bf1b9 100644 --- a/rootfs/standard/var/www/mynode/electrum_server.py +++ b/rootfs/standard/var/www/mynode/electrum_server.py @@ -2,9 +2,8 @@ from flask import Blueprint, render_template, session, abort, Markup, request, r from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from pprint import pprint, pformat from bitcoin_info import * -from device_info import get_local_ip, skipped_product_key, get_onion_url_electrs +from device_info import get_local_ip, skipped_product_key, get_onion_url_electrs, read_ui_settings from user_management import check_logged_in -from settings import read_ui_settings from electrum_info import * import json import time diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 910dcd03..fc5caf71 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -11,58 +11,12 @@ from user_management import check_logged_in from lightning_info import * from thread_functions import * import pam -import json import time import os import subprocess mynode_settings = Blueprint('mynode_settings',__name__) -def read_ui_settings(): - ui_hdd_file = '/mnt/hdd/mynode/settings/ui.json' - ui_mynode_file = '/home/bitcoin/.mynode/ui.json' - - # read ui.json from HDD - if os.path.isfile(ui_hdd_file): - with open(ui_hdd_file, 'r') as fp: - ui_settings = json.load(fp) - # read ui.json from mynode - elif os.path.isfile(ui_mynode_file): - with open(ui_mynode_file, 'r') as fp: - ui_settings = json.load(fp) - # if ui.json is not found anywhere, use default settings - else: - ui_settings = {'darkmode': False} - - return ui_settings - -def write_ui_settings(ui_settings): - ui_hdd_file = '/mnt/hdd/mynode/settings/ui.json' - ui_mynode_file = '/home/bitcoin/.mynode/ui.json' - - try: - with open(ui_hdd_file, 'w') as fp: - json.dump(ui_settings, fp) - except: - pass - - with open(ui_mynode_file, 'w') as fp: - json.dump(ui_settings, fp) - -def is_darkmode_enabled(): - ui_settings = read_ui_settings() - return ui_settings['darkmode'] - -def disable_darkmode(): - ui_settings = read_ui_settings() - ui_settings['darkmode'] = False - write_ui_settings(ui_settings) - -def enable_darkmode(): - ui_settings = read_ui_settings() - ui_settings['darkmode'] = True - write_ui_settings(ui_settings) - # Flask Pages @mynode_settings.route("/settings") def page_settings(): diff --git a/rootfs/standard/var/www/mynode/static/images/logo_dark_original.png b/rootfs/standard/var/www/mynode/static/images/logo_dark_original.png deleted file mode 100644 index 895e3720..00000000 Binary files a/rootfs/standard/var/www/mynode/static/images/logo_dark_original.png and /dev/null differ diff --git a/rootfs/standard/var/www/mynode/static/images/logo_original.png b/rootfs/standard/var/www/mynode/static/images/logo_original.png deleted file mode 100644 index b2079f7d..00000000 Binary files a/rootfs/standard/var/www/mynode/static/images/logo_original.png and /dev/null differ diff --git a/rootfs/standard/var/www/mynode/templates/includes/logo_header.html b/rootfs/standard/var/www/mynode/templates/includes/logo_header.html index d33282af..d2b50681 100644 --- a/rootfs/standard/var/www/mynode/templates/includes/logo_header.html +++ b/rootfs/standard/var/www/mynode/templates/includes/logo_header.html @@ -1,5 +1,13 @@ -{% if ui_settings['darkmode'] %} -
+{% if ui_settings['reseller'] %} + {% if ui_settings['darkmode'] %} + + {% else %} + + {% endif %} {% else %} - + {% if ui_settings['darkmode'] %} + + {% else %} + + {% endif %} {% endif %} \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/tor.py b/rootfs/standard/var/www/mynode/tor.py index 040916cc..a966c600 100644 --- a/rootfs/standard/var/www/mynode/tor.py +++ b/rootfs/standard/var/www/mynode/tor.py @@ -1,7 +1,6 @@ from flask import Blueprint, render_template, session, abort, Markup, request, redirect from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from pprint import pprint, pformat -from settings import read_ui_settings from device_info import * from user_management import check_logged_in import os diff --git a/rootfs/standard/var/www/mynode/vpn.py b/rootfs/standard/var/www/mynode/vpn.py index 0a1dec70..7d2e659a 100644 --- a/rootfs/standard/var/www/mynode/vpn.py +++ b/rootfs/standard/var/www/mynode/vpn.py @@ -1,7 +1,6 @@ from flask import Blueprint, render_template, session, abort, Markup, request, redirect, send_from_directory, url_for, flash from thread_functions import get_public_ip, check_in, find_public_ip -from device_info import is_community_edition -from settings import read_ui_settings +from device_info import is_community_edition, read_ui_settings from user_management import check_logged_in import subprocess import pam diff --git a/rootfs/standard/var/www/mynode/whirlpool.py b/rootfs/standard/var/www/mynode/whirlpool.py index 5347fddc..a5677d78 100644 --- a/rootfs/standard/var/www/mynode/whirlpool.py +++ b/rootfs/standard/var/www/mynode/whirlpool.py @@ -1,8 +1,7 @@ from flask import Blueprint, render_template, redirect -from settings import read_ui_settings from user_management import check_logged_in from enable_disable_functions import is_whirlpool_enabled, enable_whirlpool, disable_whirlpool -from device_info import get_service_status_code +from device_info import get_service_status_code, read_ui_settings import subprocess import os