diff --git a/rootfs/standard/var/www/mynode/api.py b/rootfs/standard/var/www/mynode/api.py index 5ed7ac30..58fe3257 100644 --- a/rootfs/standard/var/www/mynode/api.py +++ b/rootfs/standard/var/www/mynode/api.py @@ -6,8 +6,6 @@ from bitcoin_info import * from lightning_info import * from electrum_info import * from device_info import * -from dojo import get_dojo_status -from whirlpool import get_whirlpool_status from thread_functions import * from systemctl_info import * from application_info import * @@ -68,61 +66,14 @@ def api_get_service_status(): data = {} data["status"] = "gray" data["color"] = "" - data["ready"] = None + data["sso_token"] = "" service = request.args.get('service') - if service == "electrs": - data["status"], data["color"] = get_electrs_status_and_color() - elif service == "bitcoin": - data["status"], data["color"] = get_bitcoin_status_and_color() - elif service == "lnd": - data["status"], data["color"] = get_lnd_status_and_color() - elif service == "loop": - data["status"], data["color"] = get_loop_status_and_color() - elif service == "pool": - data["status"], data["color"] = get_pool_status_and_color() - elif service == "lit": - data["status"], data["color"] = get_lit_status_and_color() - elif service == "dojo": - data["status"], data["color"], dojo_initialized = get_dojo_status() - elif service == "rtl": - data["status"], data["color"] = get_rtl_status_and_color() - elif service == "mempool": - data["status"], data["color"] = get_mempool_status_and_color() - elif service == "whirlpool": - data["status"], data["color"], whirlpool_initialized = get_whirlpool_status() - elif service == "btcpayserver": - data["status"], data["color"] = get_btcpayserver_status_and_color() - elif service == "lndhub": - data["status"], data["color"] = get_lndhub_status_and_color() - elif service == "lndconnect": - data["status"], data["color"] = get_lndconnect_status_and_color() - elif service == "btcrpcexplorer": - data["status"], data["color"], data["ready"] = get_btcrpcexplorer_status_and_color_and_ready() - data["sso_token"] = get_btcrpcexplorer_sso_token() - elif service == "caravan": - data["status"], data["color"] = get_caravan_status_and_color() - elif service == "specter": - data["status"], data["color"] = get_specter_status_and_color() - elif service == "lnbits": - data["status"], data["color"] = get_lnbits_status_and_color() - elif service == "thunderhub": - data["status"], data["color"] = get_thunderhub_status_and_color() - data["sso_token"] = get_thunderhub_sso_token() - elif service == "ckbunker": - data["status"], data["color"] = get_ckbunker_status_and_color() - elif service == "sphinxrelay": - data["status"], data["color"] = get_sphinxrelay_status_and_color() - elif service == "tor": - data["status"] = "Private Connections" - data["color"] = get_service_status_color("tor@default") - elif service == "vpn": - data["status"], data["color"] = get_vpn_status_and_color() - elif service == "webssh2": - data["status"], data["color"] = get_webssh2_status_and_color() - else: - data["status"] = "unknown service" + # Try standard status API + data["status"] = get_application_status(service) + data["color"] = get_application_status_color(service) + data["sso_token"] = get_application_sso_token(service) return jsonify(data) @mynode_api.route("/api/get_device_info") @@ -135,6 +86,7 @@ def api_get_device_info(): data["ram"] = get_ram_usage() data["temp"] = get_device_temp() data["is_installing_docker_images"] = is_installing_docker_images() + data["is_electrs_active"] = is_electrs_active() return jsonify(data) diff --git a/rootfs/standard/var/www/mynode/application_info.py b/rootfs/standard/var/www/mynode/application_info.py index e3742e09..d0d95aeb 100644 --- a/rootfs/standard/var/www/mynode/application_info.py +++ b/rootfs/standard/var/www/mynode/application_info.py @@ -18,34 +18,68 @@ def is_installed(current_version): def create_application(name="NAME", short_name="SHORT_NAME", + app_tile_name=None, is_premium=False, can_reinstall=True, can_uninstall=False, + requires_lightning=False, + requires_electrs=False, + requires_bitcoin=False, + requires_docker_image_installation=False, + supports_testnet=False, show_on_homepage=False, show_on_application_page=True, can_enable_disable=True, - icon="TODO", + homepage_order=9999, + homepage_section="", + app_tile_button_text=None, + app_tile_default_status_text="", + app_tile_running_status_text="", + app_tile_button_href="#", status="UNKNOWN", log_file=None, - journalctl_log_name=None): + journalctl_log_name=None, + ): app = {} app["name"] = name app["short_name"] = short_name + if app_tile_name != None: + app["app_tile_name"] = app_tile_name + else: + app["app_tile_name"] = name app["is_premium"] = is_premium app["current_version"] = get_app_current_version(short_name) app["latest_version"] = get_app_latest_version(short_name) app["is_installed"] = is_installed(app["current_version"]) app["can_reinstall"] = can_reinstall app["can_uninstall"] = can_uninstall + app["requires_lightning"] = requires_lightning + app["requires_electrs"] = requires_electrs + app["requires_bitcoin"] = requires_bitcoin + app["requires_docker_image_installation"] = requires_docker_image_installation + app["supports_testnet"] = supports_testnet app["show_on_homepage"] = show_on_homepage app["show_on_application_page"] = show_on_application_page app["can_enable_disable"] = can_enable_disable app["is_enabled"] = is_service_enabled(short_name) - app["icon"] = icon #app["status"] = status # Should status be optional to include? Takes lots of time. #app["status_color"] = get_service_status_color(short_name) app["log_file"] = log_file app["journalctl_log_name"] = journalctl_log_name + app["homepage_order"] = homepage_order + app["homepage_section"] = homepage_section + if app["homepage_section"] == "" and app["show_on_homepage"]: + app["homepage_section"] = "apps" + if app_tile_button_text != None: + app["app_tile_button_text"] = app_tile_button_text + else: + app["app_tile_button_text"] = app["app_tile_name"] + app["app_tile_default_status_text"] = app_tile_default_status_text + if app_tile_running_status_text != "": + app["app_tile_running_status_text"] = app_tile_running_status_text + else: + app["app_tile_running_status_text"] = app_tile_default_status_text + app["app_tile_button_href"] = app_tile_button_href return app def update_application(app): @@ -61,34 +95,75 @@ def initialize_applications(): apps.append(create_application( name="Bitcoin", short_name="bitcoin", + app_tile_running_status_text="Running", log_file=get_bitcoin_log_file() )) apps.append(create_application( name="LND", short_name="lnd", + app_tile_running_status_text="Running", )) apps.append(create_application( name="Loop", short_name="loop", + requires_lightning=True, )) apps.append(create_application( name="Pool", short_name="pool", + requires_lightning=True, )) apps.append(create_application( name="Lightning Terminal", short_name="lit", + requires_lightning=True, + )) + apps.append(create_application( + name="Ride the Lightning", + short_name="rtl", + app_tile_name="RTL", + app_tile_default_status_text="Lightning Wallet", + show_on_homepage=True, + requires_lightning=True, + supports_testnet=True, + homepage_order=11 )) apps.append(create_application( name="Electrum Server", short_name="electrs", + app_tile_button_text="Info", + app_tile_button_href="/electrum-server", + app_tile_default_status_text="", + app_tile_running_status_text="Running", can_reinstall=False, - show_on_homepage=True + show_on_homepage=True, + supports_testnet=True, + homepage_order=12 )) apps.append(create_application( - name="BTC RPC Explorer", - short_name="btcrpcexplorer", - show_on_homepage=True + name="BTCPay Server", + short_name="btcpayserver", + app_tile_default_status_text="Merchant Tool", + requires_lightning=True, + show_on_homepage=True, + homepage_order=13 + )) + apps.append(create_application( + name="Mempool", + short_name="mempool", + app_tile_default_status_text="Mempool Viewer", + show_on_homepage=True, + supports_testnet=True, + requires_docker_image_installation=True, + homepage_order=14 + )) + apps.append(create_application( + name="LND Hub", + short_name="lndhub", + app_tile_default_status_text="BlueWallet Backend", + requires_lightning=True, + show_on_homepage=True, + homepage_order=15 )) apps.append(create_application( name="Corsproxy", @@ -101,88 +176,118 @@ def initialize_applications(): short_name="lndconnect", )) apps.append(create_application( - name="LND Hub", - short_name="lndhub", - show_on_homepage=True - )) - apps.append(create_application( - name="Ride the Lightning", - short_name="rtl", - show_on_homepage=True - )) - apps.append(create_application( - name="BTCPay Server", - short_name="btcpayserver", - show_on_homepage=True - )) - apps.append(create_application( - name="Mempool", - short_name="mempool", - show_on_homepage=True - )) - apps.append(create_application( - name="Whirlpool", - short_name="whirlpool", - show_on_homepage=True + name="BTC RPC Explorer", + short_name="btcrpcexplorer", + app_tile_name="Explorer", + app_tile_default_status_text="BTC RPC Explorer", + requires_bitcoin=True, + show_on_homepage=True, + supports_testnet=True, + requires_electrs=True, + homepage_order=21 )) apps.append(create_application( name="Dojo", short_name="dojo", + app_tile_button_text="Info", + app_tile_button_href="/dojo", + app_tile_default_status_text="Mixing Tool", show_on_application_page=True, - show_on_homepage=True + show_on_homepage=True, + requires_electrs=True, + requires_docker_image_installation=True, + homepage_order=22 )) apps.append(create_application( - name="Joinmarket", - short_name="joinmarket", + name="Whirlpool", + short_name="whirlpool", + app_tile_button_text="Info", + app_tile_button_href="/whirlpool", + app_tile_default_status_text="Mixing Tool", show_on_homepage=True, - is_premium=True + homepage_order=23 )) apps.append(create_application( name="JoininBox", short_name="joininbox", + app_tile_button_text="Info", + app_tile_button_href="/joininbox", + app_tile_default_status_text="JoinMarket Mixing", show_on_homepage=True, + homepage_order=24, can_enable_disable=False, is_premium=True, )) apps.append(create_application( - name="Thunderhub", - short_name="thunderhub", - show_on_homepage=True, + name="Joinmarket", + short_name="joinmarket", is_premium=True )) apps.append(create_application( - name="LNbits", - short_name="lnbits", + name="Thunderhub", + short_name="thunderhub", + app_tile_default_status_text="Lightning Wallet", + requires_lightning=True, + supports_testnet=True, show_on_homepage=True, + homepage_order=25, is_premium=True )) apps.append(create_application( name="Caravan", short_name="caravan", + requires_bitcoin=True, + app_tile_button_text="Info", + app_tile_button_href="/caravan", + app_tile_default_status_text="Multisig Tool", show_on_homepage=True, + homepage_order=31, + supports_testnet=True, is_premium=True )) apps.append(create_application( name="Specter", short_name="specter", + requires_bitcoin=True, + app_tile_default_status_text="Multisig Tool", show_on_homepage=True, + homepage_order=32, + supports_testnet=True, is_premium=True )) apps.append(create_application( name="CKBunker", short_name="ckbunker", + requires_bitcoin=True, + app_tile_default_status_text="Coldcard Signing Tool", show_on_homepage=True, + homepage_order=33, + supports_testnet=True, is_premium=True )) apps.append(create_application( name="Sphinx Relay", short_name="sphinxrelay", + app_tile_button_text="Info", + app_tile_button_href="/sphinxrelay", + app_tile_default_status_text="Chat", + requires_lightning=True, show_on_homepage=True, + homepage_order=34, + is_premium=True + )) + apps.append(create_application( + name="LNbits", + short_name="lnbits", + requires_lightning=True, + app_tile_default_status_text="Lightning Wallet", + show_on_homepage=True, + homepage_order=35, is_premium=True )) apps.append(create_application( name="Web SSH", - short_name="webssh2" + short_name="webssh2", )) apps.append(create_application( name="Netdata", @@ -192,15 +297,28 @@ def initialize_applications(): apps.append(create_application( name="Tor", short_name="tor", + can_enable_disable=False, + app_tile_button_text="Tor Services", + app_tile_default_status_text="Private Connections", + app_tile_button_href="/tor", + show_on_homepage=True, show_on_application_page=False, - journalctl_log_name="tor@default" + journalctl_log_name="tor@default", + homepage_section="remote_services", + supports_testnet=True, + is_premium=True, )) apps.append(create_application( name="VPN", short_name="vpn", - show_on_homepage=True, can_reinstall=False, - show_on_application_page=False + app_tile_button_text="Info", + app_tile_button_href="/vpn-info", + show_on_homepage=True, + show_on_application_page=False, + homepage_section="remote_services", + supports_testnet=True, + is_premium=True, )) apps.append(create_application( name="NGINX", @@ -232,6 +350,8 @@ def get_all_applications(order_by="none"): apps = copy.deepcopy(mynode_applications) if order_by == "alphabetic": apps.sort(key=lambda x: x["name"]) + elif order_by == "homepage": + apps.sort(key=lambda x: x["homepage_order"]) return apps @@ -272,6 +392,118 @@ def get_application_log(short_name): else: return "ERROR: App or log not found ({})".format(short_name) +def get_application_status_special(short_name): + if short_name == "bitcoin": + return get_bitcoin_status() + elif short_name == "lnd": + return get_lnd_status() + elif short_name == "vpn": + if os.path.isfile("/home/pivpn/ovpns/mynode_vpn.ovpn"): + return "Running" + else: + return "Setting up..." + elif short_name == "electrs": + return get_electrs_status() + elif short_name == "whirlpool": + if not os.path.isfile("/mnt/hdd/mynode/whirlpool/whirlpool-cli-config.properties"): + return "Waiting for initialization..." + elif short_name == "dojo": + try: + dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True).strip() + except: + dojo_initialized = "" + if dojo_initialized != "true": + return "Error" + return "" + +def get_application_status(short_name): + # Make sure app is valid + if not is_application_valid(short_name): + return "APP NOT FOUND" + + # Get application + app = get_application(short_name) + + # Check Disabled, Testnet, Lightning, Electrum requirements... + if is_testnet_enabled() and not app["supports_testnet"]: + return "Requires Mainnet" + if app["requires_docker_image_installation"] and is_installing_docker_images(): + return "Installing..." + if not app["is_enabled"]: + return app["app_tile_default_status_text"] + if app["requires_bitcoin"] and not is_bitcoin_synced(): + return "Waiting on Bitcoin" + if app["requires_lightning"] and not is_lnd_ready(): + return "Waiting on Lightning" + if app["requires_electrs"] and not is_electrs_active(): + return "Waiting on Electrum" + + # Check special cases + special_status = get_application_status_special(short_name) + if special_status != "": + return special_status + + # Return + return app["app_tile_running_status_text"] + +def get_application_status_color_special(short_name): + if short_name == "lnd": + return get_lnd_status_color() + elif short_name == "joininbox": + return "clear" + elif short_name == "whirlpool": + if not os.path.isfile("/mnt/hdd/mynode/whirlpool/whirlpool-cli-config.properties"): + return "yellow" + elif short_name == "dojo": + try: + dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True).strip() + except: + dojo_initialized = "" + if dojo_initialized != "true": + return "red" + return "" + +def get_application_status_color(short_name): + # Make sure app is valid + if not is_application_valid(short_name): + return "gray" + + # Get application + app = get_application(short_name) + + # Check Disabled, Testnet, Lightning, Electrum requirements... + if is_testnet_enabled() and not app["supports_testnet"]: + return "gray" + if app["requires_docker_image_installation"] and is_installing_docker_images(): + return "yellow" + if app["can_enable_disable"] and not app["is_enabled"]: + return "gray" + if app["requires_bitcoin"] and not is_bitcoin_synced(): + return "yellow" + if app["requires_lightning"] and not is_lnd_ready(): + return "yellow" + if app["requires_electrs"] and not is_electrs_active(): + return "yellow" + + # Check special cases + special_status_color = get_application_status_color_special(short_name) + if special_status_color != "": + return special_status_color + + # Return service operational status + return get_service_status_color(short_name) + +def get_application_sso_token(short_name): + # Make sure app is valid + if not is_application_valid(short_name): + return "APP NOT FOUND" + + if short_name == "btcrpcexplorer": + return get_btcrpcexplorer_sso_token() + if short_name == "thunderhub": + return get_thunderhub_sso_token() + return "" + def restart_application(short_name): try: subprocess.check_output('systemctl restart {}'.format(short_name), shell=True) diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index a6e773a1..c8fd8a01 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -1,13 +1,13 @@ from config import * from threading import Timer from werkzeug.routing import RequestRedirect -from flask import flash +from flask import flash, redirect from utilities import * from enable_disable_functions import * -from lightning_info import is_lnd_ready, get_lnd_status, get_lnd_status_color +from lightning_info import is_lnd_ready from systemctl_info import * from electrum_info import get_electrs_status, is_electrs_active -from bitcoin_info import get_bitcoin_status, is_bitcoin_synced +from bitcoin_info import is_bitcoin_synced from datetime import timedelta import time import json @@ -460,227 +460,6 @@ def get_drive_info(drive): return data -#================================== -# Specific Service Status / Colors -#================================== -def get_bitcoin_status_and_color(): - status = "" - color = "gray" - if get_service_status_code("bitcoin") == 0: - status = get_bitcoin_status() - color = "green" - else: - status = "Error" - color = "red" - return status,color - -def get_lnd_status_and_color(): - status = get_lnd_status() - color = get_lnd_status_color() - return status,color - -def get_loop_status_and_color(): - status = "Not Displayed" - color = "gray" - if is_lnd_ready(): - color = get_service_status_color("loop") - return status,color - -def get_pool_status_and_color(): - status = "Not Displayed" - color = "gray" - if is_lnd_ready(): - color = get_service_status_color("loop") - return status,color - -def get_lit_status_and_color(): - status = "Not Displayed" - color = "gray" - if is_lnd_ready(): - color = get_service_status_color("loop") - return status,color - -def get_lndconnect_status_and_color(): - status = "Not Displayed" - color = get_service_status_color("lndconnect") - return status,color - -def get_vpn_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("vpn"): - color = get_service_status_color("vpn") - status_code = get_service_status_code("vpn") - if status_code != 0: - status = "Unknown" - else: - if os.path.isfile("/home/pivpn/ovpns/mynode_vpn.ovpn"): - status = "Running" - else: - status = "Setting up..." - return status,color - -def get_rtl_status_and_color(): - status = "Lightning Wallet" - color = "gray" - if is_lnd_ready(): - if is_service_enabled("rtl"): - status_code = get_service_status_code("rtl") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_lnbits_status_and_color(): - color = "gray" - status = "Lightning Wallet" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - if is_service_enabled("lnbits"): - status_code = get_service_status_code("lnbits") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_thunderhub_status_and_color(): - color = "gray" - status = "Lightning Wallet" - if is_lnd_ready(): - if is_service_enabled("thunderhub"): - status_code = get_service_status_code("thunderhub") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_ckbunker_status_and_color(): - status = "Coldcard Signing Tool" - color = "gray" - if is_bitcoin_synced(): - if is_service_enabled("ckbunker"): - color = get_service_status_color("ckbunker") - else: - status = "Waiting on Bitcoin" - return status,color - -def get_sphinxrelay_status_and_color(): - color = "gray" - status = "Chat" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - if is_service_enabled("sphinxrelay"): - status_code = get_service_status_code("sphinxrelay") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_lndhub_status_and_color(): - status = "BlueWallet Backend" - color = "gray" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - if is_service_enabled("lndhub"): - color = get_service_status_color("lndhub") - else: - status = "Waiting on Lightning" - return status,color - -def get_btcpayserver_status_and_color(): - status = "Merchant Tool" - color = "gray" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - color = get_service_status_color("btcpayserver") - else: - status = "Waiting on Lightning" - return status,color - -def get_electrs_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("electrs"): - status_code = get_service_status_code("electrs") - color = get_service_status_color("electrs") - if status_code == 0: - status = get_electrs_status() - return status,color - -def get_btcrpcexplorer_status_and_color_and_ready(): - status = "BTC RPC Explorer" - color = "gray" - ready = False - if is_service_enabled("btcrpcexplorer"): - if is_bitcoin_synced(): - if is_electrs_active(): - color = get_service_status_color("btcrpcexplorer") - status_code = get_service_status_code("btcrpcexplorer") - if status_code == 0: - ready = True - else: - color = "yellow" - status = "Waiting on Electrum" - else: - color = "yellow" - status = "Waiting on Bitcoin" - return status,color,ready - -def get_caravan_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("caravan"): - color = get_service_status_color("caravan") - status = "Running" - return status,color - -def get_specter_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("specter"): - color = get_service_status_color("specter") - status = "Running" - return status,color - -def get_mempool_status_and_color(): - status = "Mempool Viewer" - color = "gray" - if is_service_enabled("mempool"): - if is_installing_docker_images(): - color = "yellow" - status = "Installing..." - else: - color = get_service_status_color("mempool") - return status,color - -def get_webssh2_status_and_color(): - status = "Web SSH" - color = "gray" - if is_service_enabled("webssh2"): - if is_installing_docker_images(): - color = "yellow" - status = "Installing..." - else: - color = get_service_status_color("webssh2") - return status,color - - #================================== # UI Functions #================================== diff --git a/rootfs/standard/var/www/mynode/dojo.py b/rootfs/standard/var/www/mynode/dojo.py index af1ca85f..57abeeb9 100644 --- a/rootfs/standard/var/www/mynode/dojo.py +++ b/rootfs/standard/var/www/mynode/dojo.py @@ -5,6 +5,7 @@ from user_management import check_logged_in from enable_disable_functions import * from bitcoin_info import get_mynode_block_height from electrum_info import get_electrs_status, is_electrs_active +from application_info import * import subprocess import re import os @@ -12,6 +13,15 @@ import os mynode_dojo = Blueprint('mynode_dojo',__name__) ## Status and color +def is_dojo_initialized(): + try: + dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True) + dojo_initialized = dojo_initialized.strip() + except: + dojo_initialized = "" + + return dojo_initialized == "true" + def get_dojo_status(): # Find dojo status dojo_status = "Disabled" @@ -20,22 +30,17 @@ def get_dojo_status(): if is_installing_docker_images(): dojo_status = "Installing..." dojo_status_color = "yellow" - dojo_initialized = "" - return dojo_status, dojo_status_color, dojo_initialized + return dojo_status, dojo_status_color if is_testnet_enabled(): dojo_status = "Requires Mainnet" dojo_status_color = "gray" - dojo_initialized = "" - return dojo_status, dojo_status_color, dojo_initialized + return dojo_status, dojo_status_color + + init = is_dojo_initialized() - try: - dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True) - dojo_initialized = dojo_initialized.strip() - except: - dojo_initialized = "" if is_service_enabled("dojo"): - if dojo_initialized != "false": + if init: if is_electrs_active(): dojo_status = "Running" dojo_status_color = "green" @@ -45,9 +50,8 @@ def get_dojo_status(): else: dojo_status = "Issue Starting" dojo_status_color = "red" - dojo_initialized = "" - return dojo_status, dojo_status_color, dojo_initialized + return dojo_status, dojo_status_color def get_dojo_tracker_status(): try: @@ -116,7 +120,12 @@ def dojo_page(): admin_key = get_dojo_admin_key() dojo_v3_addr = get_dojo_addr() - dojo_status, dojo_status_color, dojo_initialized = get_dojo_status() + dojo_status = "Running" + dojo_status_code = get_service_status_code("dojo") + if not is_dojo_initialized(): + dojo_status = "Issue Starting" + elif dojo_status_code != 0: + dojo_status = "Error" # Load page templateData = { @@ -125,9 +134,7 @@ def dojo_page(): "is_dojo_installed": is_dojo_installed(), "dojo_status": dojo_status, "dojo_version": get_dojo_version(), - "dojo_status_color": dojo_status_color, "dojo_enabled": is_service_enabled("dojo"), - "dojo_initialized": dojo_initialized, "dojo_tracker_status": get_dojo_tracker_status(), "electrs_status": get_electrs_status(), "NODE_ADMIN_KEY": admin_key, @@ -138,6 +145,5 @@ def dojo_page(): @mynode_dojo.route("/restart-dojo") def page_restart_dojo(): check_logged_in() - disable_dojo() - enable_dojo() + restart_service("dojo") return redirect("/dojo") diff --git a/rootfs/standard/var/www/mynode/enable_disable_functions.py b/rootfs/standard/var/www/mynode/enable_disable_functions.py index dc028709..4b3f7563 100644 --- a/rootfs/standard/var/www/mynode/enable_disable_functions.py +++ b/rootfs/standard/var/www/mynode/enable_disable_functions.py @@ -1,15 +1,16 @@ import os import subprocess +from werkzeug.routing import RequestRedirect from config import * from systemctl_info import * # Generic Enable / Disable Function def enable_service(short_name): - enable_actions(short_name) os.system("systemctl enable {} --no-pager".format(short_name)) os.system("systemctl start {} --no-pager".format(short_name)) open("/mnt/hdd/mynode/settings/{}_enabled".format(short_name), 'a').close() # touch file clear_service_enabled_cache() + enable_actions(short_name) def disable_service(short_name): enabled_file = "/mnt/hdd/mynode/settings/{}_enabled".format(short_name) @@ -22,7 +23,10 @@ def disable_service(short_name): # Functions to handle special enable/disable cases def enable_actions(short_name): - pass + if short_name == "dojo": + if not is_dojo_installed(): + install_dojo() + raise RequestRedirect("/settings/reboot-device") def disable_actions(short_name): if short_name == "electrs": @@ -33,7 +37,9 @@ def disable_actions(short_name): os.system("systemctl stop openvpn --no-pager") os.system("systemctl disable openvpn --no-pager") - +# Function to restart service +def restart_service(short_name): + os.system("systemctl restart {} --no-pager".format(short_name)) # Dojo install / uninstall functions.... future work to abstract this @@ -47,6 +53,6 @@ def install_dojo(): def uninstall_dojo(): os.system("rm -f " + DOJO_INSTALL_FILE) os.system("rf -f /mnt/hdd/mynode/settings/dojo_url") - disable_dojo() + disable_service("dojo") os.system("sync") diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index 5c52590d..d7d7a7bc 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -4,8 +4,8 @@ from flask import Flask, render_template, Markup, send_from_directory, redirect, from user_management import * from api import mynode_api from bitcoin import mynode_bitcoin -from whirlpool import mynode_whirlpool, get_whirlpool_status -from dojo import mynode_dojo, get_dojo_status +from whirlpool import mynode_whirlpool +from dojo import mynode_dojo from joininbox import mynode_joininbox from caravan import mynode_caravan from sphinxrelay import mynode_sphinxrelay @@ -456,10 +456,6 @@ def index(): } return render_template('syncing.html', **templateData) - # Find tor status - tor_status_color = get_service_status_color("tor@default") - tor_status = "Private Connections" - # Find bitcoid status bitcoin_info = get_bitcoin_blockchain_info() bitcoin_peers = get_bitcoin_peers() @@ -480,52 +476,6 @@ def index(): if int(re.sub("[^0-9]", "", drive_usage)) > 95: low_drive_space_error = True - - # Find lndhub status - lndhub_status, lndhub_status_color = get_lndhub_status_and_color() - - # Find RTL status - rtl_status, rtl_status_color = get_rtl_status_and_color() - - # Find LNbits status - lnbits_status, lnbits_status_color = get_lnbits_status_and_color() - - # Find Thunderhub status - thunderhub_status, thunderhub_status_color = get_thunderhub_status_and_color() - - # Find CKBunker status - ckbunker_status, ckbunker_status_color = get_ckbunker_status_and_color() - - # Find Sphinx Relay status - sphinxrelay_status, sphinxrelay_status_color = get_sphinxrelay_status_and_color() - - # Find electrs status - electrs_status, electrs_status_color = get_electrs_status_and_color() - - # Find btc-rpc-explorer status - btcrpcexplorer_status, btcrpcexplorer_status_color, btcrpcexplorer_ready = get_btcrpcexplorer_status_and_color_and_ready() - - # Find mempool space status - mempool_status, mempool_status_color = get_mempool_status_and_color() - - # Find btcpayserver status - btcpayserver_status, btcpayserver_status_color = get_btcpayserver_status_and_color() - - # Find VPN status - vpn_status, vpn_status_color = get_vpn_status_and_color() - - # Find whirlpool status - whirlpool_status, whirlpool_status_color, whirlpool_initialized = get_whirlpool_status() - - # Find dojo status - dojo_status, dojo_status_color, dojo_initialized = get_dojo_status() - - # Find caravan status - caravan_status, caravan_status_color = get_caravan_status_and_color() - - # Find specter status - specter_status, specter_status_color = get_specter_status_and_color() - # Check for new version of software upgrade_available = False current = get_current_version() @@ -544,7 +494,7 @@ def index(): "title": "myNode Home", "refresh_rate": refresh_rate, "config": CONFIG, - "apps": get_all_applications(order_by="alphabetic"), + "apps": get_all_applications(order_by="homepage"), "bitcoin_status_color": bitcoin_status_color, "bitcoin_status": Markup(bitcoin_status), "current_block": current_block, @@ -562,63 +512,10 @@ def index(): "lnd_version": get_lnd_version(), "lnd_deposit_address": get_lnd_deposit_address(), "lnd_channels": get_lightning_channels(), + "electrs_active": electrs_active, "is_testnet_enabled": is_testnet_enabled(), - "tor_status_color": tor_status_color, - "tor_status": tor_status, "is_installing_docker_images": is_installing_docker_images(), "is_device_from_reseller": is_device_from_reseller(), - "electrs_status_color": electrs_status_color, - "electrs_status": Markup(electrs_status), - "electrs_enabled": is_service_enabled("electrs"), - "electrs_active": electrs_active, - "rtl_status_color": rtl_status_color, - "rtl_status": rtl_status, - "rtl_enabled": is_service_enabled("rtl"), - "lnbits_status_color": lnbits_status_color, - "lnbits_status": lnbits_status, - "lnbits_enabled": is_service_enabled("lnbits"), - "thunderhub_status_color": thunderhub_status_color, - "thunderhub_status": thunderhub_status, - "thunderhub_enabled": is_service_enabled("thunderhub"), - "thunderhub_sso_token": get_thunderhub_sso_token(), - "ckbunker_status_color": ckbunker_status_color, - "ckbunker_status": ckbunker_status, - "ckbunker_enabled": is_service_enabled("ckbunker"), - "sphinxrelay_status_color": sphinxrelay_status_color, - "sphinxrelay_status": sphinxrelay_status, - "sphinxrelay_enabled": is_service_enabled("sphinxrelay"), - "lndhub_status_color": lndhub_status_color, - "lndhub_status": lndhub_status, - "lndhub_enabled": is_service_enabled("lndhub"), - "btcrpcexplorer_ready": btcrpcexplorer_ready, - "btcrpcexplorer_status_color": btcrpcexplorer_status_color, - "btcrpcexplorer_status": btcrpcexplorer_status, - "btcrpcexplorer_enabled": is_service_enabled("btcrpcexplorer"), - "btcrpcexplorer_sso_token": get_btcrpcexplorer_sso_token(), - "caravan_status_color": caravan_status_color, - "caravan_status": caravan_status, - "caravan_enabled": is_service_enabled("caravan"), - "specter_status_color": specter_status_color, - "specter_status": specter_status, - "specter_enabled": is_service_enabled("specter"), - "mempool_status_color": mempool_status_color, - "mempool_status": mempool_status, - "mempool_enabled": is_service_enabled("mempool"), - "btcpayserver_enabled": is_service_enabled("btcpayserver"), - "btcpayserver_status_color": btcpayserver_status_color, - "btcpayserver_status": btcpayserver_status, - "vpn_status_color": vpn_status_color, - "vpn_status": vpn_status, - "vpn_enabled": is_service_enabled("vpn"), - "whirlpool_status": whirlpool_status, - "whirlpool_status_color": whirlpool_status_color, - "whirlpool_enabled": is_service_enabled("whirlpool"), - "whirlpool_initialized": whirlpool_initialized, - "is_dojo_installed": is_dojo_installed(), - "dojo_status": dojo_status, - "dojo_status_color": dojo_status_color, - "dojo_enabled": is_service_enabled("dojo"), - "dojo_initialized": dojo_initialized, "product_key_skipped": pk_skipped, "product_key_error": pk_error, "fsck_error": has_fsck_error(), diff --git a/rootfs/standard/var/www/mynode/static/css/mynode.css b/rootfs/standard/var/www/mynode/static/css/mynode.css index 2c774da6..70cc21b9 100644 --- a/rootfs/standard/var/www/mynode/static/css/mynode.css +++ b/rootfs/standard/var/www/mynode/static/css/mynode.css @@ -383,6 +383,7 @@ table.bitcoin_table td { .red { background-color: red; } .gray { background-color: gray; } .blue { background-color: blue; } +.clear { opacity: 100%; } .green_text {color: green;} .yellow_text {color: yellow;} diff --git a/rootfs/standard/var/www/mynode/static/images/electrum_logo.png b/rootfs/standard/var/www/mynode/static/images/electrs.png similarity index 100% rename from rootfs/standard/var/www/mynode/static/images/electrum_logo.png rename to rootfs/standard/var/www/mynode/static/images/electrs.png diff --git a/rootfs/standard/var/www/mynode/static/images/sphinx.png b/rootfs/standard/var/www/mynode/static/images/sphinxrelay.png similarity index 100% rename from rootfs/standard/var/www/mynode/static/images/sphinx.png rename to rootfs/standard/var/www/mynode/static/images/sphinxrelay.png diff --git a/rootfs/standard/var/www/mynode/static/images/whirlpool.png b/rootfs/standard/var/www/mynode/static/images/whirlpool.png new file mode 100644 index 00000000..bed83724 Binary files /dev/null and b/rootfs/standard/var/www/mynode/static/images/whirlpool.png differ diff --git a/rootfs/standard/var/www/mynode/static/images/wp-black.png b/rootfs/standard/var/www/mynode/static/images/wp-black.png deleted file mode 100644 index 4a0079bc..00000000 Binary files a/rootfs/standard/var/www/mynode/static/images/wp-black.png and /dev/null differ diff --git a/rootfs/standard/var/www/mynode/static/images/wp-white.png b/rootfs/standard/var/www/mynode/static/images/wp-white.png deleted file mode 100644 index 8272a154..00000000 Binary files a/rootfs/standard/var/www/mynode/static/images/wp-white.png and /dev/null differ diff --git a/rootfs/standard/var/www/mynode/templates/dojo.html b/rootfs/standard/var/www/mynode/templates/dojo.html index 4fad024d..47ef3a83 100644 --- a/rootfs/standard/var/www/mynode/templates/dojo.html +++ b/rootfs/standard/var/www/mynode/templates/dojo.html @@ -49,7 +49,7 @@ Uninstall - {% if dojo_enabled and dojo_initialized and electrs_status == "Running" %} + {% if dojo_enabled and electrs_status == "Running" %} Dojo V3 Onion Address {{DOJO_V3_ADDR}} diff --git a/rootfs/standard/var/www/mynode/templates/electrum_server.html b/rootfs/standard/var/www/mynode/templates/electrum_server.html index a3249a85..2d40a945 100644 --- a/rootfs/standard/var/www/mynode/templates/electrum_server.html +++ b/rootfs/standard/var/www/mynode/templates/electrum_server.html @@ -102,7 +102,7 @@
- +
Local
PC Wallet
@@ -112,7 +112,7 @@
- +
Local
Mobile Wallets
diff --git a/rootfs/standard/var/www/mynode/templates/includes/apps.html b/rootfs/standard/var/www/mynode/templates/includes/apps.html index 6a2d1b52..4d51e3e2 100644 --- a/rootfs/standard/var/www/mynode/templates/includes/apps.html +++ b/rootfs/standard/var/www/mynode/templates/includes/apps.html @@ -1,286 +1,39 @@
Apps
- -
- -
-
- - -
RTL
-
{{ rtl_status }}
-
- {% if lnd_ready %} - {% if rtl_enabled %} - RTL - {% endif %} - - {% if rtl_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
- -
-
- -
Electrum Server
-
{{ electrs_status }}
-
- {% if electrs_enabled %} - Info - {% endif %} - - {% if electrs_enabled %}Disable{% else %}Enable{% endif %} - -
-
- -
-
- -
BTCPay Server
-
{{ btcpayserver_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if lnd_ready and not is_testnet_enabled %} - {% if btcpayserver_enabled %} - BTCPay Server +
+ + {% for app in apps %} + {% if app.show_on_homepage and app.homepage_section == "apps" %} +
+
+ +
{{app.app_tile_name}}
+
+
+ {% if product_key_skipped and app.is_premium %} + Premium Feature + {% else %} + {% if not is_testnet_enabled or is_testnet_enabled and app.supports_testnet %} + {% if lnd_ready or ( not lnd_ready and not app.requires_lightning ) %} + {% if electrs_active or ( not electrs_active and not app.requires_electrs ) %} + {% if not is_installing_docker_images or ( is_installing_docker_images and not app.requires_docker_image_installation ) %} + {% if app.is_enabled or not app.can_enable_disable %} + {{app.app_tile_button_text}} + {% endif %} + {% if app.can_enable_disable %} + + {% if app.is_enabled %}Disable{% else %}Enable{% endif %} + + {% endif %} + {% endif %} + {% endif %} + {% endif %} + {% endif %} {% endif %} - - {% if btcpayserver_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} - {% endif %} -
-
- -
-
- -
Mempool
-
{{ mempool_status }}
-
- {% if not is_installing_docker_images %} - {% if mempool_enabled %} - View - {% endif %} - - {% if mempool_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
-
-
- -
LND Hub
-
{{ lndhub_status }}
-
- {% if lnd_ready and not is_testnet_enabled %} - {% if lndhub_enabled %} - LND Hub - {% endif %} - - {% if lndhub_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
- -
-
- -
Explorer
-
{{ btcrpcexplorer_status }}
-
- {% if btcrpcexplorer_enabled and btcrpcexplorer_ready %} - Explorer - {% endif %} - - {% if btcrpcexplorer_enabled %}Disable{% else %}Enable{% endif %} - -
-
- - {% if not is_device_from_reseller %} -
-
- -
Dojo
-
{{ dojo_status }}
-
- {% if not is_installing_docker_images and not is_testnet_enabled %} - {% if is_dojo_installed %} - Info - {% if electrs_active %} - - {% if dojo_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} - {% else %} - Install - {% endif %} - {% endif %} -
-
- -
-
- {% if ui_settings['darkmode'] %} - - {% else %} - +
+
{% endif %} -
Whirlpool
-
{{ whirlpool_status }}
-
- {% if not is_testnet_enabled %} - Info - - {% if whirlpool_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
- {% endif %} - -
- - -
JoininBox
-
JoinMarket Mixing
-
- Info -
-
- -
-
- -
Thunderhub
-
{{ thunderhub_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if lnd_ready %} - {% if thunderhub_enabled %} - Thunderhub - {% endif %} - - {% if thunderhub_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} - {% endif %} -
-
- -
-
- -
Caravan
-
{{ caravan_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if caravan_enabled %} - Info - {% endif %} - - {% if caravan_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
- -
-
- -
Specter
-
{{ specter_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if specter_enabled %} - Specter - {% endif %} - - {% if specter_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
- -
-
- - -
CKBunker
-
{{ ckbunker_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if ckbunker_enabled %} - CKBunker - {% endif %} - - {% if ckbunker_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
- -
-
- -
Sphinx Relay
-
{{ sphinxrelay_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if lnd_ready and not is_testnet_enabled %} - {% if sphinxrelay_enabled %} - Info - {% endif %} - - {% if sphinxrelay_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} - {% endif %} -
-
- -
-
- -
LNbits
-
{{ lnbits_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if lnd_ready and not is_testnet_enabled %} - {% if lnbits_enabled %} - LNbits - {% endif %} - - {% if lnbits_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} - {% endif %} -
-
- + {% endfor %}
@@ -289,37 +42,38 @@
Remote Access Services
-
-
- -
Tor
-
{{ tor_status }}
-
- {% if product_key_skipped %} - Remote Access Premium Feature - {% else %} - Tor Services - {% endif %} -
-
-
-
- -
VPN
-
{{ vpn_status }}
-
- {% if product_key_skipped %} - Premium Feature - {% else %} - {% if vpn_enabled %} - Info - {% endif %} - - {% if vpn_enabled %}Disable{% else %}Enable{% endif %} - - {% endif %} -
-
+ {% for app in apps %} + {% if app.show_on_homepage and app.homepage_section == "remote_services" %} +
+
+ +
{{app.app_tile_name}}
+
+
+ {% if product_key_skipped and app.is_premium %} + Premium Feature + {% else %} + {% if not is_testnet_enabled or is_testnet_enabled and app.supports_testnet %} + {% if lnd_ready or ( not lnd_ready and not app.requires_lightning ) %} + {% if electrs_active or ( not electrs_active and not app.requires_electrs ) %} + {% if not is_installing_docker_images or ( is_installing_docker_images and not app.requires_docker_image_installation ) %} + {% if app.is_enabled or not app.can_enable_disable %} + {{app.app_tile_button_text}} + {% endif %} + {% if app.can_enable_disable %} + + {% if app.is_enabled %}Disable{% else %}Enable{% endif %} + + {% endif %} + {% endif %} + {% endif %} + {% endif %} + {% endif %} + {% endif %} +
+
+ {% endif %} + {% endfor %}
diff --git a/rootfs/standard/var/www/mynode/templates/main.html b/rootfs/standard/var/www/mynode/templates/main.html index a0b18668..61c6b289 100644 --- a/rootfs/standard/var/www/mynode/templates/main.html +++ b/rootfs/standard/var/www/mynode/templates/main.html @@ -13,6 +13,9 @@ application_data["{{app.short_name}}"]["short_name"] = "{{app.short_name}}"; application_data["{{app.short_name}}"]["is_enabled"] = {% if app.is_enabled %}true{% else %}false{% endif %}; {% endfor %} + var electrs_active = {% if electrs_active %}1{% else %}0{% endif %}; + var lnd_ready = {% if lnd_ready %}true{% else %}false{% endif %}; + var is_installing_docker_images = {% if is_installing_docker_images %}true{% else %}false{% endif %}; // Toggle enable/disable functions function get_custom_enable_message(short_name) { @@ -23,6 +26,8 @@ } else if (short_name == "vpn") { message = "Enabling VPN will set your IP to a static IP rather than a dynamic one via DHCP. \ The initial setup may take about an hour."; + } else if (short_name == "dojo") { + message = "Enabling Dojo for the first time will reboot your device and install Dojo."; } if (message != "") { message += "

"; @@ -72,6 +77,7 @@ $("#"+status_icon_name).removeClass("green"); $("#"+status_icon_name).removeClass("gray"); $("#"+status_icon_name).removeClass("blue"); + $("#"+status_icon_name).removeClass("clear"); $("#"+status_icon_name).addClass(data["color"]); } } @@ -83,10 +89,17 @@ $("#channel_status_icon_"+c["chan_id"]).removeClass("green"); $("#channel_status_icon_"+c["chan_id"]).removeClass("gray"); $("#channel_status_icon_"+c["chan_id"]).removeClass("blue"); + $("#channel_status_icon_"+c["chan_id"]).removeClass("clear"); $("#channel_status_icon_"+c["chan_id"]).addClass(c["status_color"]); } } + function update_sso_token(short_name, data) { + if ("sso_token" in data && data["sso_token"] != null && data["sso_token"] != "") { + application_data[short_name]["sso_token"] = data["sso_token"] + } + } + function refresh_page() { window.location.href=location.protocol+'//'+location.hostname+"/"; } @@ -125,11 +138,6 @@ // Update page function - var lnd_ready = {% if lnd_ready %}true{% else %}false{% endif %}; - var btcrpcexplorer_ready = {% if btcrpcexplorer_ready %}true{% else %}false{% endif %}; - var btcrpcexplorer_sso_token = "{{btcrpcexplorer_sso_token}}"; - var thunderhub_sso_token = "{{thunderhub_sso_token}}"; - var is_installing_docker_images = {% if is_installing_docker_images %}true{% else %}false{% endif %}; function update_page() { // Update Bitcoin Info $.getJSON("/api/get_bitcoin_info", function( data ) { @@ -206,88 +214,15 @@ }); // Update app status - $.getJSON("/api/get_service_status?service=bitcoin", function( data ) { - update_status("bitcoin_status", data); - update_status_icon("bitcoin_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=lnd", function( data ) { - update_status("lnd_status", data); - update_status_icon("lnd_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=electrs", function( data ) { - update_status("electrs_status", data); - update_status_icon("electrs_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=dojo", function( data ) { - update_status("dojo_status", data); - update_status_icon("dojo_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=rtl", function( data ) { - update_status("rtl_status", data); - update_status_icon("rtl_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=mempool", function( data ) { - update_status("mempool_status", data); - update_status_icon("mempool_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=whirlpool", function( data ) { - update_status("whirlpool_status", data); - update_status_icon("whirlpool_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=btcpayserver", function( data ) { - update_status("btcpayserver_status", data); - update_status_icon("btcpayserver_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=lndhub", function( data ) { - update_status("lndhub_status", data); - update_status_icon("lndhub_status_icon", data); - }); - // BTC RPC Explorer // TODO: Refresh page if btcexplorerready changes - $.getJSON("/api/get_service_status?service=btcrpcexplorer", function( data ) { - update_status("btcrpcexplorer_status", data); - update_status_icon("btcrpcexplorer_status_icon", data); - if ("sso_token" in data && data["sso_token"] != null) { - btcrpcexplorer_sso_token = data["sso_token"] - } - if ("ready" in data && data["ready"] != null && btcrpcexplorer_ready != data["ready"]) { - refresh_page(); - } - }); - $.getJSON("/api/get_service_status?service=caravan", function( data ) { - update_status("caravan_status", data); - update_status_icon("caravan_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=specter", function( data ) { - update_status("specter_status", data); - update_status_icon("specter_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=lnbits", function( data ) { - update_status("lnbits_status", data); - update_status_icon("lnbits_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=thunderhub", function( data ) { - update_status("thunderhub_status", data); - update_status_icon("thunderhub_status_icon", data); - if ("sso_token" in data && data["sso_token"] != null) { - thunderhub_sso_token = data["sso_token"] - } - }); - $.getJSON("/api/get_service_status?service=ckbunker", function( data ) { - update_status("ckbunker_status", data); - update_status_icon("ckbunker_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=sphinxrelay", function( data ) { - update_status("sphinxrelay_status", data); - update_status_icon("sphinxrelay_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=tor", function( data ) { - update_status("tor_status", data); - update_status_icon("tor_status_icon", data); - }); - $.getJSON("/api/get_service_status?service=vpn", function( data ) { - update_status("vpn_status", data); - update_status_icon("vpn_status_icon", data); - }); + {% for app in apps %} + {% if app.show_on_homepage %} + $.getJSON("/api/get_service_status?service={{app.short_name}}", function( data ) { + update_status("{{app.short_name}}_status", data); + update_status_icon("{{app.short_name}}_status_icon", data); + update_sso_token("{{app.short_name}}", data); + }); + {% endif %} + {% endfor %} // Update device info $.getJSON("/api/get_device_info", function( data ) { @@ -312,6 +247,11 @@ refresh_page(); } } + if ("is_electrs_active" in data && data["is_electrs_active"] != null) { + if (electrs_active != data["is_electrs_active"]) { + refresh_page(); + } + } }); // Check if we need a full page refresh (errors, status changes, etc...) @@ -326,11 +266,6 @@ // Run when page ready $(document).ready(function() { - electrs_enabled = {% if electrs_enabled %}1{% else %}0{% endif %} - lndhub_enabled = {% if lndhub_enabled %}1{% else %}0{% endif %} - vpn_enabled = {% if vpn_enabled %}1{% else %}0{% endif %} - mempool_enabled = {% if mempool_enabled %}1{% else %}0{% endif %} - $( document ).tooltip(); $("#lit").on("click", function() { @@ -372,7 +307,7 @@ } // Swap to use SSO (make optional? - needing password is safer) url = location.protocol+'//'+location.hostname+':'+port - //url = location.protocol+'//'+location.hostname+':'+port+'/sso?'+'token='+thunderhub_sso_token + //url = location.protocol+'//'+location.hostname+':'+port+'/sso?'+'token='+application_data["thunderhub"]["sso_token"] window.open(url,'_blank'); }) @@ -385,16 +320,12 @@ window.open(url,'_blank'); }) - $("#sphinxrelay").on("click", function() { - alert("TODO???") - }) - $("#btcrpcexplorer").on("click", function() { port="3002" if (location.protocol == "https:") { port="3003" } - url = location.protocol+'//'+location.hostname+':'+port+'/?'+'token='+btcrpcexplorer_sso_token + url = location.protocol+'//'+location.hostname+':'+port+'/?'+'token='+application_data["btcrpcexplorer"]["sso_token"] window.open(url,'_blank'); }) diff --git a/rootfs/standard/var/www/mynode/templates/whirlpool.html b/rootfs/standard/var/www/mynode/templates/whirlpool.html index b28f4d17..23b6596e 100644 --- a/rootfs/standard/var/www/mynode/templates/whirlpool.html +++ b/rootfs/standard/var/www/mynode/templates/whirlpool.html @@ -30,7 +30,7 @@ Actions - + {% if whirlpool_enabled %}Disable{% else %}Enable{% endif %} {% if whirlpool_enabled %} diff --git a/rootfs/standard/var/www/mynode/whirlpool.py b/rootfs/standard/var/www/mynode/whirlpool.py index 82223e39..06fcfb08 100644 --- a/rootfs/standard/var/www/mynode/whirlpool.py +++ b/rootfs/standard/var/www/mynode/whirlpool.py @@ -2,6 +2,7 @@ from flask import Blueprint, render_template, redirect from user_management import check_logged_in from enable_disable_functions import * from device_info import read_ui_settings, is_testnet_enabled, get_local_ip +from application_info import * from systemctl_info import * import subprocess import os @@ -9,30 +10,9 @@ import os mynode_whirlpool = Blueprint('mynode_whirlpool',__name__) ## Status and color -def get_whirlpool_status(): - # Find whirlpool status - whirlpool_status = "Disabled" - whirlpool_status_color = "gray" - whirlpool_initialized = os.path.isfile("/mnt/hdd/mynode/whirlpool/whirlpool-cli-config.properties") +def is_whirlpool_initialized(): + return os.path.isfile("/mnt/hdd/mynode/whirlpool/whirlpool-cli-config.properties") - if is_testnet_enabled(): - whirlpool_status = "Requires Mainnet" - whirlpool_status_color = "gray" - return whirlpool_status, whirlpool_status_color, whirlpool_initialized - - if is_service_enabled("whirlpool"): - status_code = get_service_status_code("whirlpool") - if status_code != 0: - whirlpool_status = "Inactive" - whirlpool_status_color = "red" - else: - if whirlpool_initialized: - whirlpool_status = "Running" - whirlpool_status_color = "green" - else: - whirlpool_status = "Waiting for initialization..." - whirlpool_status_color = "yellow" - return whirlpool_status, whirlpool_status_color, whirlpool_initialized ### Page functions @mynode_whirlpool.route("/whirlpool") @@ -45,7 +25,12 @@ def whirlpool_page(): except: whirlpool_api_key = 'error' - whirlpool_status, whirlpool_status_color, whirlpool_initialized = get_whirlpool_status() + whirlpool_status = "Running" + whirlpool_status_code = get_service_status_code("whirlpool") + if not is_whirlpool_initialized(): + whirlpool_status = "Waiting on Initialization..." + elif whirlpool_status_code != 0: + whirlpool_status = "Inactive" # Load page templateData = { @@ -53,9 +38,8 @@ def whirlpool_page(): "ui_settings": read_ui_settings(), "local_ip": get_local_ip(), "whirlpool_status": whirlpool_status, - "whirlpool_status_color": whirlpool_status_color, "whirlpool_enabled": is_service_enabled("whirlpool"), - "whirlpool_initialized": whirlpool_initialized, + "whirlpool_initialized": is_whirlpool_initialized(), "whirlpool_api_key": whirlpool_api_key } return render_template('whirlpool.html', **templateData)