Add shutdown option from settings page

This commit is contained in:
Taylor Helsper 2019-09-11 23:48:52 -05:00
parent cd8fad2a13
commit 5a67cc2c62
4 changed files with 60 additions and 1 deletions

View File

@ -1,5 +1,6 @@
=== v0.1.44 ===
- TODO
- Add changelog to settings page
- Add shutdown option on settings page
=== v0.1.43 ===
- Initial changelog

View File

@ -68,6 +68,9 @@ def delete_lnd_data():
def reboot_device():
os.system("reboot")
def shutdown_device():
os.system("shutdown -h now")
def reset_blockchain():
stop_bitcoind()
delete_bitcoin_data()
@ -221,6 +224,20 @@ def reboot_device_page():
}
return render_template('reboot.html', **templateData)
@mynode_settings.route("/settings/shutdown-device")
def shutdown_device_page():
# Trigger shutdown
t = Timer(1.0, shutdown_device)
t.start()
# Wait until device is restarted
templateData = {
"title": "myNode Shutdown",
"header_text": "Shutting down...",
"subheader_text": Markup("Your myNode is shutting down.<br/><br/>You will need to power cycle the device to turn it back on.")
}
return render_template('shutdown.html', **templateData)
@mynode_settings.route("/settings/reindex-blockchain")
def reindex_blockchain_page():
os.system("echo 'BTCARGS=-reindex-chainstate' > "+BITCOIN_ENV_FILE)

View File

@ -117,6 +117,17 @@
okFunction)
});
$("#shutdown-device").on("click", function() {
// Enable electrs
var okFunction = function() {
window.location.href="/settings/shutdown-device"
}
openConfirmDialog("confirm-dialog",
"Shutdown Device",
"Are you sure you want to shutdown your device?",
okFunction)
});
$("#reindex-blockchain").on("click", function() {
// Enable electrs
var okFunction = function() {
@ -353,6 +364,13 @@
<div class="divider"></div>
<div class="settings_block_subheader">Shutdown Device</div>
This will shutdown your myNode. You will need to power cycle the device to turn it back on.
<br/>
<button id="shutdown-device" class="ui-button ui-widget ui-corner-all settings_button">Shutdown Device</button>
<div class="divider"></div>
<div class="settings_block_subheader">Download Logs</div>
This will download all recent logs from your mynode. This can be helpful for debugging issues.
<br/>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html lang="en">
<head>
<title>{{ title }}</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='images/favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename="css/mynode.css")}}">
<meta http-equiv="Content-Language" content="en">
<meta name="google" content="notranslate">
<script src="{{ url_for('static', filename="js/jquery-3.3.1.min.js")}}"></script>
<script src="{{ url_for('static', filename="js/mynode.js")}}"></script>
</head>
<body>
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename="images/logo.png")}}"/></a></div>
<div class="state_header">{{ header_text }}</div>
<div class="state_subheader">
{{ subheader_text }}
<br/><br/>
</div>
</body>
</html>