Improve custom logo logic

This commit is contained in:
Taylor Helsper 2020-07-18 22:16:51 -05:00
parent 7340baea15
commit f91a376cb9
13 changed files with 72 additions and 70 deletions

View File

@ -59,17 +59,11 @@ if [ ! -f /var/lib/mynode/.expanded_rootfs ]; then
fi fi
# Customize logo for resellers # Customize logo for resellers
if [ -f /opt/mynode/custom/reseller ]; then
if [ -f /opt/mynode/custom/logo_custom.png ]; 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 cp -f /opt/mynode/custom/logo_custom.png /var/www/mynode/static/images/logo_custom.png
else
cp -f /var/www/mynode/static/images/logo_original.png /var/www/mynode/static/images/logo.png
fi fi
if [ -f /opt/mynode/custom/logo_dark_custom.png ]; then 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 cp -f /opt/mynode/custom/logo_dark_custom.png /var/www/mynode/static/images/logo_dark_custom.png
else
cp -f /var/www/mynode/static/images/logo_dark_original.png /var/www/mynode/static/images/logo_dark.png
fi
fi fi

View File

@ -6,7 +6,6 @@ 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_info import * from electrum_info import *
from settings import read_ui_settings
from user_management import check_logged_in from user_management import check_logged_in
import socket import socket
import hashlib import hashlib

View File

@ -1,6 +1,5 @@
from flask import Blueprint, render_template, redirect from flask import Blueprint, render_template, redirect
from settings import read_ui_settings
from user_management import check_logged_in from user_management import check_logged_in
from device_info import * from device_info import *
import subprocess import subprocess

View File

@ -3,6 +3,7 @@ from threading import Timer
from werkzeug.routing import RequestRedirect from werkzeug.routing import RequestRedirect
from flask import flash from flask import flash
import time import time
import json
import os import os
import subprocess import subprocess
@ -334,6 +335,57 @@ def get_journalctl_log(service_name):
log = "ERROR" log = "ERROR"
return log 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 # Uploader Functions

View File

@ -1,6 +1,6 @@
from flask import Blueprint, render_template, redirect 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 user_management import check_logged_in
from enable_disable_functions import is_dojo_enabled, enable_dojo, disable_dojo, is_dojo_installed from enable_disable_functions import is_dojo_enabled, enable_dojo, disable_dojo, is_dojo_installed
from bitcoin_info import get_mynode_block_height from bitcoin_info import get_mynode_block_height

View File

@ -2,9 +2,8 @@ from flask import Blueprint, render_template, session, abort, Markup, request, r
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from pprint import pprint, pformat from pprint import pprint, pformat
from bitcoin_info import * 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 user_management import check_logged_in
from settings import read_ui_settings
from electrum_info import * from electrum_info import *
import json import json
import time import time

View File

@ -11,58 +11,12 @@ from user_management import check_logged_in
from lightning_info import * from lightning_info import *
from thread_functions import * from thread_functions import *
import pam import pam
import json
import time import time
import os import os
import subprocess import subprocess
mynode_settings = Blueprint('mynode_settings',__name__) 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 # Flask Pages
@mynode_settings.route("/settings") @mynode_settings.route("/settings")
def page_settings(): def page_settings():

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

View File

@ -1,5 +1,13 @@
{% if ui_settings['reseller'] %}
{% if ui_settings['darkmode'] %}
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo_dark_custom.png')}}"/></a></div>
{% else %}
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo_custom.png')}}"/></a></div>
{% endif %}
{% else %}
{% if ui_settings['darkmode'] %} {% if ui_settings['darkmode'] %}
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo_dark.png')}}"/></a></div> <div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo_dark.png')}}"/></a></div>
{% else %} {% else %}
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo.png')}}"/></a></div> <div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo.png')}}"/></a></div>
{% endif %} {% endif %}
{% endif %}

View File

@ -1,7 +1,6 @@
from flask import Blueprint, render_template, session, abort, Markup, request, redirect from flask import Blueprint, render_template, session, abort, Markup, request, redirect
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from pprint import pprint, pformat from pprint import pprint, pformat
from settings import read_ui_settings
from device_info import * from device_info import *
from user_management import check_logged_in from user_management import check_logged_in
import os import os

View File

@ -1,7 +1,6 @@
from flask import Blueprint, render_template, session, abort, Markup, request, redirect, send_from_directory, url_for, flash 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 thread_functions import get_public_ip, check_in, find_public_ip
from device_info import is_community_edition from device_info import is_community_edition, read_ui_settings
from settings import read_ui_settings
from user_management import check_logged_in from user_management import check_logged_in
import subprocess import subprocess
import pam import pam

View File

@ -1,8 +1,7 @@
from flask import Blueprint, render_template, redirect from flask import Blueprint, render_template, redirect
from settings import read_ui_settings
from user_management import check_logged_in from user_management import check_logged_in
from enable_disable_functions import is_whirlpool_enabled, enable_whirlpool, disable_whirlpool 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 subprocess
import os import os