diff --git a/onionr/httpapi/miscclientapi/endpoints.py b/onionr/httpapi/miscclientapi/endpoints.py index d4b903e6..4062e2ec 100644 --- a/onionr/httpapi/miscclientapi/endpoints.py +++ b/onionr/httpapi/miscclientapi/endpoints.py @@ -27,6 +27,7 @@ from serializeddata import SerializedData from onionrutils import mnemonickeys from onionrutils import bytesconverter from utils import reconstructhash +from onionrcommands import restartonionr pub_key = onionrcrypto.pub_key.replace('=', '') @@ -90,6 +91,11 @@ class PrivateEndpoints: @private_endpoints_bp.route('/shutdown') def shutdown(): return apiutils.shutdown.shutdown(client_api) + + @private_endpoints_bp.route('/restartclean') + def restart_clean(): + restartonionr.restart() + return Response("bye") @private_endpoints_bp.route('/getstats') def getStats(): diff --git a/onionr/onionrcommands/restartonionr.py b/onionr/onionrcommands/restartonionr.py index 996ab406..1abe3620 100644 --- a/onionr/onionrcommands/restartonionr.py +++ b/onionr/onionrcommands/restartonionr.py @@ -35,6 +35,7 @@ def restart(): daemonlaunch.kill_daemon() while localcommand.local_command('ping', maxWait=8) == 'pong!': time.sleep(0.3) + time.sleep(4) subprocess.Popen([SCRIPT_NAME, 'start']) restart.onionr_help = 'Gracefully restart Onionr' diff --git a/onionr/static-data/www/private/index.html b/onionr/static-data/www/private/index.html index 2ba75af9..4096a367 100755 --- a/onionr/static-data/www/private/index.html +++ b/onionr/static-data/www/private/index.html @@ -9,6 +9,7 @@ Onionr + @@ -100,7 +101,9 @@

- Refresh Stats + + Restart +

@@ -120,7 +123,7 @@

- Onionr + Onionr Sites

@@ -147,6 +150,13 @@

Statistics

+
diff --git a/onionr/static-data/www/private/main.css b/onionr/static-data/www/private/main.css index f7954963..7a80bef2 100755 --- a/onionr/static-data/www/private/main.css +++ b/onionr/static-data/www/private/main.css @@ -1,13 +1,3 @@ -.configEditor{ - width: 100%; - height: 300px; -} - -.saveConfig{ - margin-top: 1em; -} - - .idLink{ -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ @@ -16,3 +6,6 @@ user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */ } +#refreshStats{ + margin: 5px; +} \ No newline at end of file diff --git a/onionr/static-data/www/shared/panel.js b/onionr/static-data/www/shared/panel.js index 665904e8..8bfc1fb0 100755 --- a/onionr/static-data/www/shared/panel.js +++ b/onionr/static-data/www/shared/panel.js @@ -1,5 +1,26 @@ +/* + Onionr - Private P2P Communication + + This file handles the mail interface + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + shutdownBtn = document.getElementById('shutdownNode') refreshStatsBtn = document.getElementById('refreshStats') +restartBtn = document.getElementById('restartNode') + shutdownBtn.onclick = function(){ if (! nowebpass){ httpGet('shutdownclean') @@ -7,6 +28,17 @@ shutdownBtn.onclick = function(){ } } +restartBtn.onclick = function(){ + if (! nowebpass){ + fetch('/restartclean', { + headers: { + "token": webpass + }}) + PNotify.notice('Node is restarting') + } +} + + refreshStatsBtn.onclick = function(){ getStats() -} \ No newline at end of file +}