refactored main page to not use xhr, added thread ui stat area
This commit is contained in:
parent
b5ac1ed7d8
commit
b2f4dae226
@ -262,6 +262,13 @@
|
|||||||
Blocks in queue: <span id="blockQueue"></span>
|
Blocks in queue: <span id="blockQueue"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h6>Process Info</h6>
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<i class="fas fa-microchip"></i>
|
||||||
|
Current CPU threads: <span id="threads"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -55,50 +55,79 @@ function seconds2time (seconds) {
|
|||||||
return time
|
return time
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (httpGet('/config/get/general.security_level')){
|
|
||||||
case "0":
|
fetch('/config/get/general.security_level', {
|
||||||
sec_description_str = 'normal'
|
headers: {
|
||||||
break;
|
"token": webpass
|
||||||
case "1":
|
}})
|
||||||
sec_description_str = 'high'
|
.then((resp) => resp.text()) // Transform the data into text
|
||||||
break;
|
.then(function(resp) {
|
||||||
case "2":
|
switch(resp){
|
||||||
sec_description_str = 'very high'
|
case "0":
|
||||||
break;
|
sec_description_str = 'normal'
|
||||||
case "3":
|
break;
|
||||||
sec_description_str = 'extreme'
|
case "1":
|
||||||
break;
|
sec_description_str = 'high'
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
sec_description_str = 'very high'
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
sec_description_str = 'extreme'
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sec_description_str !== 'normal'){
|
||||||
|
showSecStatNotice()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
var getStats = function(){
|
||||||
|
fetch('/getstats', {
|
||||||
|
headers: {
|
||||||
|
"token": webpass
|
||||||
|
}})
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then(function(stats) {
|
||||||
|
uptimeDisplay.innerText = seconds2time(stats['uptime'])
|
||||||
|
connectedNodes = stats['connectedNodes'].split('\n')
|
||||||
|
connectedDisplay.innerText = ''
|
||||||
|
for (x = 0; x < connectedNodes.length; x++){
|
||||||
|
if (! connectedDisplay.innerText.includes(connectedNodes[x])){
|
||||||
|
connectedDisplay.innerText += '🧅 ' + connectedNodes[x] + '\n'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
storedBlockDisplay.innerText = stats['blockCount']
|
||||||
|
queuedBlockDisplay.innerText = stats['blockQueueCount']
|
||||||
|
document.getElementById('threads').innerText = stats['threads']
|
||||||
|
securityLevel.innerText = sec_description_str
|
||||||
|
fetch('/hitcount', {
|
||||||
|
headers: {
|
||||||
|
"token": webpass
|
||||||
|
}})
|
||||||
|
.then((resp) => resp.text())
|
||||||
|
.then(function(totalRec) {
|
||||||
|
totalRec.innerText = totalRec
|
||||||
|
})
|
||||||
|
fetch('/lastconnect', {
|
||||||
|
headers: {
|
||||||
|
"token": webpass
|
||||||
|
}})
|
||||||
|
.then((resp) => resp.text())
|
||||||
|
.then(function(conn) {
|
||||||
|
var lastConnect = conn
|
||||||
|
if (lastConnect > 0){
|
||||||
|
var humanDate = new Date(0)
|
||||||
|
humanDate.setUTCSeconds(conn)
|
||||||
|
humanDate = humanDate.toString()
|
||||||
|
lastConnect = humanDate.substring(0, humanDate.indexOf('('));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lastConnect = 'None since start'
|
||||||
|
}
|
||||||
|
lastIncoming.innerText = lastConnect
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sec_description_str !== 'normal'){
|
|
||||||
showSecStatNotice()
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStats(){
|
|
||||||
stats = JSON.parse(httpGet('getstats', webpass))
|
|
||||||
uptimeDisplay.innerText = seconds2time(stats['uptime'])
|
|
||||||
connectedNodes = stats['connectedNodes'].split('\n')
|
|
||||||
connectedDisplay.innerText = ''
|
|
||||||
for (x = 0; x < connectedNodes.length; x++){
|
|
||||||
if (! connectedDisplay.innerText.includes(connectedNodes[x])){
|
|
||||||
connectedDisplay.innerText += '🧅 ' + connectedNodes[x] + '\n'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
storedBlockDisplay.innerText = stats['blockCount']
|
|
||||||
queuedBlockDisplay.innerText = stats['blockQueueCount']
|
|
||||||
securityLevel.innerText = sec_description_str
|
|
||||||
totalRec.innerText = httpGet('/hitcount')
|
|
||||||
var lastConnect = httpGet('/lastconnect')
|
|
||||||
if (lastConnect > 0){
|
|
||||||
var humanDate = new Date(0)
|
|
||||||
humanDate.setUTCSeconds(httpGet('/lastconnect'))
|
|
||||||
humanDate = humanDate.toString()
|
|
||||||
lastConnect = humanDate.substring(0, humanDate.indexOf('('));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
lastConnect = 'None since start'
|
|
||||||
}
|
|
||||||
lastIncoming.innerText = lastConnect
|
|
||||||
}
|
|
||||||
getStats()
|
getStats()
|
||||||
setInterval(function(){getStats()}, 10000)
|
setInterval(function(){getStats()}, 10000)
|
@ -25,7 +25,7 @@ fetch('/getHumanReadable', {
|
|||||||
headers: {
|
headers: {
|
||||||
"token": webpass
|
"token": webpass
|
||||||
}})
|
}})
|
||||||
.then((resp) => resp.text())
|
.then((resp) => resp.text())
|
||||||
.then(function(resp) {
|
.then(function(resp) {
|
||||||
myPub = resp
|
myPub = resp
|
||||||
})
|
})
|
||||||
@ -46,7 +46,7 @@ function post_to_url(path, params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.body.appendChild(form)
|
document.body.appendChild(form)
|
||||||
form.submit()
|
form.submit()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof webpass == "undefined"){
|
if (typeof webpass == "undefined"){
|
||||||
@ -87,7 +87,7 @@ var passLinks = document.getElementsByClassName("idLink")
|
|||||||
for(var i = 0; i < passLinks.length; i++) {
|
for(var i = 0; i < passLinks.length; i++) {
|
||||||
passLinks[i].href += '#' + webpass
|
passLinks[i].href += '#' + webpass
|
||||||
}
|
}
|
||||||
|
|
||||||
var refreshLinks = document.getElementsByClassName("refresh")
|
var refreshLinks = document.getElementsByClassName("refresh")
|
||||||
|
|
||||||
for(var i = 0; i < refreshLinks.length; i++) {
|
for(var i = 0; i < refreshLinks.length; i++) {
|
||||||
@ -133,7 +133,7 @@ if (typeof myPubCopy != "undefined"){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log("copied pubkey to clipboard")
|
console.log("copied pubkey to clipboard")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For Config toggle on homepage */
|
/* For Config toggle on homepage */
|
||||||
|
Loading…
Reference in New Issue
Block a user