added restart button to ui

master
Kevin Froman 2019-09-20 12:53:42 -05:00
parent a7a5f88142
commit 4187aba570
5 changed files with 55 additions and 13 deletions

View File

@ -27,6 +27,7 @@ from serializeddata import SerializedData
from onionrutils import mnemonickeys from onionrutils import mnemonickeys
from onionrutils import bytesconverter from onionrutils import bytesconverter
from utils import reconstructhash from utils import reconstructhash
from onionrcommands import restartonionr
pub_key = onionrcrypto.pub_key.replace('=', '') pub_key = onionrcrypto.pub_key.replace('=', '')
@ -90,6 +91,11 @@ class PrivateEndpoints:
@private_endpoints_bp.route('/shutdown') @private_endpoints_bp.route('/shutdown')
def shutdown(): def shutdown():
return apiutils.shutdown.shutdown(client_api) return apiutils.shutdown.shutdown(client_api)
@private_endpoints_bp.route('/restartclean')
def restart_clean():
restartonionr.restart()
return Response("bye")
@private_endpoints_bp.route('/getstats') @private_endpoints_bp.route('/getstats')
def getStats(): def getStats():

View File

@ -35,6 +35,7 @@ def restart():
daemonlaunch.kill_daemon() daemonlaunch.kill_daemon()
while localcommand.local_command('ping', maxWait=8) == 'pong!': while localcommand.local_command('ping', maxWait=8) == 'pong!':
time.sleep(0.3) time.sleep(0.3)
time.sleep(4)
subprocess.Popen([SCRIPT_NAME, 'start']) subprocess.Popen([SCRIPT_NAME, 'start'])
restart.onionr_help = 'Gracefully restart Onionr' restart.onionr_help = 'Gracefully restart Onionr'

View File

@ -9,6 +9,7 @@
Onionr Onionr
</title> </title>
<link rel='shortcut icon' type='image/ico' href='/shared/images/favicon.ico'> <link rel='shortcut icon' type='image/ico' href='/shared/images/favicon.ico'>
<link rel="stylesheet" href="/private/main.css">
<link rel="stylesheet" href="/shared/fontawesome-free-5.10.2/css/all.min.css"> <link rel="stylesheet" href="/shared/fontawesome-free-5.10.2/css/all.min.css">
<link rel='stylesheet' href='/shared/main/PNotifyBrightTheme.css'> <link rel='stylesheet' href='/shared/main/PNotifyBrightTheme.css'>
<link rel="stylesheet" href="/shared/main/bulma.min.css"> <link rel="stylesheet" href="/shared/main/bulma.min.css">
@ -100,7 +101,9 @@
</a> </a>
</p> </p>
<p class="control"> <p class="control">
<a class="button is-link" id='refreshStats'>Refresh Stats</a> <a class="button is-warning is-outlined" id='restartNode'>
Restart
</a>
</p> </p>
</div> </div>
</div> </div>
@ -120,7 +123,7 @@
<div class="card"> <div class="card">
<header class="card-header"> <header class="card-header">
<p class="card-header-title"> <p class="card-header-title">
Onionr Onionr Sites
</p> </p>
</header> </header>
<div class="card-content"> <div class="card-content">
@ -147,6 +150,13 @@
<p class="card-header-title"> <p class="card-header-title">
Statistics Statistics
</p> </p>
<div class="field">
<div class="is-pulled-right">
<a class="button is-link" id='refreshStats'>
Refresh Stats
</a>
</div>
</div>
</header> </header>
<div class="card-content"> <div class="card-content">
<div class="content"> <div class="content">

View File

@ -1,13 +1,3 @@
.configEditor{
width: 100%;
height: 300px;
}
.saveConfig{
margin-top: 1em;
}
.idLink{ .idLink{
-webkit-touch-callout: none; /* iOS Safari */ -webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */ -webkit-user-select: none; /* Safari */
@ -16,3 +6,6 @@
user-select: none; /* Non-prefixed version, currently user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */ supported by Chrome and Opera */
} }
#refreshStats{
margin: 5px;
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
shutdownBtn = document.getElementById('shutdownNode') shutdownBtn = document.getElementById('shutdownNode')
refreshStatsBtn = document.getElementById('refreshStats') refreshStatsBtn = document.getElementById('refreshStats')
restartBtn = document.getElementById('restartNode')
shutdownBtn.onclick = function(){ shutdownBtn.onclick = function(){
if (! nowebpass){ if (! nowebpass){
httpGet('shutdownclean') 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(){ refreshStatsBtn.onclick = function(){
getStats() getStats()
} }