Add enable/disable for RTL (default on)

This commit is contained in:
Taylor Helsper 2020-05-26 21:01:05 -05:00
parent 3c84cf6792
commit 41fd789e09
3 changed files with 32 additions and 6 deletions

View File

@ -41,6 +41,18 @@ def disable_electrs():
os.system("systemctl disable electrs --no-pager")
def is_rtl_enabled():
return is_service_enabled("rtl")
def enable_rtl():
os.system("systemctl enable rtl --no-pager")
os.system("systemctl start rtl --no-pager")
def disable_rtl():
os.system("systemctl stop rtl --no-pager")
os.system("systemctl disable rtl --no-pager")
def is_btcrpcexplorer_enabled():
if os.path.isfile(BTCRPCEXPLORER_ENABLED_FILE):
return True

View File

@ -366,11 +366,12 @@ def index():
# Find RTL status
if lnd_ready:
status_code = get_service_status_code("rtl")
if status_code != 0:
rtl_status_color = "red"
else:
rtl_status_color = "green"
if is_rtl_enabled():
status_code = get_service_status_code("rtl")
if status_code != 0:
rtl_status_color = "red"
else:
rtl_status_color = "green"
# Find electrs status
if is_electrs_enabled():
@ -473,6 +474,7 @@ def index():
"electrs_active": electrs_active,
"rtl_status_color": rtl_status_color,
"rtl_status": rtl_status,
"rtl_enabled": is_rtl_enabled(),
"lndhub_status_color": lndhub_status_color,
"lndhub_enabled": is_lndhub_enabled(),
"explorer_ready": explorer_ready,
@ -581,6 +583,15 @@ def page_toggle_electrs():
enable_electrs()
return redirect("/")
@app.route("/toggle-rtl")
def page_toggle_rtl():
check_logged_in()
if is_rtl_enabled():
disable_rtl()
else:
enable_rtl()
return redirect("/")
@app.route("/toggle-btcrpcexplorer")
def page_toggle_btcrpcexplorer():
check_logged_in()

View File

@ -7,7 +7,10 @@
<div class="app_status">{% if not lnd_ready %}Waiting on LND...{% else %}{{ rtl_status }}{% endif %}</div>
<div class="app_contents">
{% if lnd_ready %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="rtl">RTL</a>
{% if rtl_enabled %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="rtl">RTL</a>
{% endif %}
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/toggle-rtl" id="toggle-rtl">{% if rtl_enabled %}Disable{% else %}Enable{% endif %}</a>
{% endif %}
</div>
</div>