Added tor restart button to index and tor restart command. Enabled tor restart daemon event

This commit is contained in:
Kevin Froman 2020-09-15 17:08:50 +00:00
parent b4d80da3ff
commit 1f067f614a
9 changed files with 63 additions and 6 deletions

View file

@ -12,6 +12,7 @@
<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/bulma-quickview.min.css">
<link rel="stylesheet" href="/shared/bulma-tooltip.min.css">
<link rel="stylesheet" href="/gettheme">
<link rel="stylesheet" href="/shared/sidebar/sidebar.css">
<script defer src="/shared/node_modules/pnotify/dist/iife/PNotify.js"></script>
@ -274,6 +275,12 @@
<pre id="connectedNodes">Unable to get nodes</pre>
</div>
<br>
<div class="field">
<p class="control">
<a class="button is-light restartTor" data-tooltip="Use if there have been no incoming or outgoing connections in a long time">Restart Tor</a>
</p>
</div>
<br>
<h4>Blocks</h4>
<div class="columns">
<div class="column">

View file

@ -20,6 +20,46 @@
shutdownBtn = document.getElementById('shutdownNode')
restartBtn = document.getElementById('restartNode')
let restartTorBtnControl = function(){
if (typeof config == "undefined" || typeof config.tor == "undefined"){
setTimeout(function(){restartTorBtnControl()}, 10)
return
}
var restartTor = document.getElementsByClassName('restartTor')[0]
if (config.tor.use_existing_tor){
restartTor.classList.add('is-hidden')
return
}
restartTor.onclick = function(){
if (restartTor.disabled){
console.debug("Tor still restarting (or restart_tor event failed)")
return
}
restartTor.disabled = true
PNotify.success({
text: 'Initializing Tor restart...'
})
fetch('/daemon-event/restart_tor', {
method: 'POST',
body: {},
headers: {
"content-type": "application/json",
"token": webpass
}})
.then((resp) => resp.text())
.then(function(data) {
PNotify.success({
text: 'Tor restarting...'
})
restartTor.disabled = false
})
}
}
restartTorBtnControl()
shutdownBtn.onclick = function(){
if (! nowebpass){
if (confirm("Really shutdown Onionr?")){