Improve custom logo logic
This commit is contained in:
parent
7340baea15
commit
f91a376cb9
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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():
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 86 KiB |
Binary file not shown.
Before Width: | Height: | Size: 120 KiB |
|
@ -1,5 +1,13 @@
|
|||
{% 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>
|
||||
{% 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 %}
|
||||
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo.png')}}"/></a></div>
|
||||
{% 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>
|
||||
{% else %}
|
||||
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename='images/logo.png')}}"/></a></div>
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user