made particles more efficient, finished basic blocks feed

This commit is contained in:
Kevin 2020-06-21 02:27:55 -05:00
parent dafa4b6117
commit 34416c07fe
8 changed files with 132 additions and 38 deletions

View File

@ -57,9 +57,14 @@ def stream_tor_circuits():
def stream_recent_blocks(): def stream_recent_blocks():
def _compile_json(b_list): def _compile_json(b_list):
js = {} js = {}
block_obj = None
for block in b_list: for block in b_list:
block_obj = Block(block)
if block_obj.isEncrypted:
js[block] = 'encrypted'
else:
js[block] = Block(block).btype js[block] = Block(block).btype
return ujson.dumps(js, reject_bytes=True) return ujson.dumps({"blocks": js}, reject_bytes=True)
def _stream_recent(): def _stream_recent():
last_time = Path(block_meta_db).stat().st_ctime last_time = Path(block_meta_db).stat().st_ctime

View File

@ -71,6 +71,7 @@
"tor": true "tor": true
}, },
"ui": { "ui": {
"animated_background": true,
"theme": "dark" "theme": "dark"
} }
} }

View File

@ -81,25 +81,6 @@
</h2> </h2>
</div> </div>
<div class="column is-7"> <div class="column is-7">
<div class="field">
<div class="field has-addons">
<p class="control">
<a class="button is-static">
<i class="fas fa-fingerprint"></i>
</a>
</p>
<p class="control is-expanded">
<input id="myPub" class="input myPub" type="text" readonly>
</p>
<p class="control">
<a id="myPubCopy" class="button is-primary">
<span class="icon">
<i class="fas fa-copy"></i>
</span>
</a>
</p>
</div>
</div>
<div class="field is-grouped is-grouped-centered"> <div class="field is-grouped is-grouped-centered">
<p class="control"> <p class="control">
<a class="button is-danger is-outlined" id="shutdownNode"> <a class="button is-danger is-outlined" id="shutdownNode">
@ -202,6 +183,26 @@
</header> </header>
<div class="card-content"> <div class="card-content">
<div class="content"> <div class="content">
<div class="columns">
<div class="column">
<div class="field">
<div class="field has-addons">
<p class="control">
<a class="button is-static">
<i class="fas fa-fingerprint"></i>
</a>
</p>
<p class="control is-expanded">
<input id="myPub" class="input myPub" type="text" readonly>
</p>
<p class="control">
<a id="myPubCopy" class="button is-primary"><i class="fas fa-copy"></i></a>
</p>
</div>
</div>
</div>
</div>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<span class="icon"> <span class="icon">
@ -248,6 +249,24 @@
Total Requests: <span id="totalRec">None since start</span> Total Requests: <span id="totalRec">None since start</span>
</div> </div>
</div> </div>
<details>
<summary>Transport addresses</summary>
<div class="field has-addons torTransportField">
<p class="control">
<a class="button is-static">
<i class="fas fa-adjust"></i>
</a>
</p>
<p class="control is-expanded">
<input id="myTor" class="input myTor" type="text" readonly>
</p>
<p class="control">
<a id="myTorCopy" class="button is-primary"><i class="fas fa-copy"></i></a>
</p>
</div>
</details>
<i class="fas fa-link"></i> <i class="fas fa-link"></i>
Outgoing Connections: Outgoing Connections:
<div class="control"> <div class="control">
@ -268,7 +287,7 @@
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<p class="buttons"> <p class="buttons">
<button class="button is-small"> <button class="button is-small recentBlocksBtn">
<span class="icon is-small"> <span class="icon is-small">
<i class="fas fa-stream"></i> <i class="fas fa-stream"></i>
</span> </span>
@ -281,7 +300,7 @@
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<i class="fas fa-microchip"></i> <i class="fas fa-microchip"></i>
Current CPU threads: <span id="threads"></span> Current threads: <span id="threads"></span>
</div> </div>
<div class="column"> <div class="column">
<i class="fas fa-memory"></i> <i class="fas fa-memory"></i>
@ -336,7 +355,8 @@
<button class="closeRecentModal delete" aria-label="close"></button> <button class="closeRecentModal delete" aria-label="close"></button>
</header> </header>
<section class="modal-card-body recentBody"> <section class="modal-card-body recentBody">
Loading... <i class="fas fa-spinner fa-spin"></i> Keep this open to see new blocks!
<pre class="recentBlockList"></pre>
</section> </section>
</div> </div>
</div> </div>

View File

@ -18,6 +18,9 @@
*/ */
apiOnline = true apiOnline = true
async function doPing(){ async function doPing(){
if (document.hidden){
return
}
out = setTimeout(function(){ out = setTimeout(function(){
if (apiOnline){ if (apiOnline){
PNotify.notice('Connection lost with API server') PNotify.notice('Connection lost with API server')

View File

@ -1539,3 +1539,15 @@ var pJS = function(tag_id, params){
xhr.send(); xhr.send();
}; };
let toggleAnimation = function () {
if (document.hidden) {
cancelRequestAnimFrame(pJSDom[0].pJS.fn.checkAnimFrame);
cancelRequestAnimFrame(pJSDom[0].pJS.fn.drawAnimFrame);
pJSDom[0].pJS.fn.particlesEmpty();
pJSDom[0].pJS.fn.canvasClear();
return;
}
pJSDom[0].pJS.fn.vendors.start();
}
document.addEventListener("visibilitychange", toggleAnimation, false);

View File

@ -1,10 +1,51 @@
var recentSource = new EventSourcePolyfill('/recentblocks', { var getRecent = function(){
var recentSource = new EventSourcePolyfill('/recentblocks', {
headers: { headers: {
"token": webpass "token": webpass
} }
}) })
recentSource.onmessage = function(e){ recentSource.onmessage = function(e){
console.debug(e) if (e.data == "none"){
return
}
var existing = document.getElementsByClassName('recentBlockList')[0].innerText;
let data = JSON.parse(e.data)
Object.entries(data.blocks).forEach(([key, value]) => {
if (existing.includes(key)){
return
}
existing = key + " - " + value + "\n" + existing
})
document.getElementsByClassName('recentBlockList')[0].innerText = existing
console.debug(data)
}
return recentSource
}
recentSource = getRecent()
function toggleRecentStream() {
if (document.hidden){
console.debug("Stopped recent block stream")
recentSource.close()
return
}
if (document.getElementsByClassName('recentModal')[0].classList.contains('is-active')){
recentSource.close()
getRecent()
}
}
document.getElementsByClassName('recentBlocksBtn')[0].onclick = function(){
document.getElementsByClassName('recentModal')[0].classList.add('is-active')
}
document.getElementsByClassName('recentBlocksBtn')
document.addEventListener("visibilitychange", toggleRecentStream, false);
document.getElementsByClassName('closeRecentModal')[0].onclick = function(){
document.getElementsByClassName('recentBlockList')[0].innerText = ""
document.getElementsByClassName('recentModal')[0].classList.remove('is-active')
} }

View File

@ -146,7 +146,19 @@ getStats()
setInterval(function(){getStats()}, 1000) setInterval(function(){getStats()}, 1000)
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
particlesJS.load('particles-js', '/shared/main/particles.json', function() { fetch('/config/get/ui.animated_background', {
console.log('callback - particles.js config loaded'); headers: {
}); "token": webpass
}})
.then((resp) => resp.text()) // Transform the data into text
.then(function(resp) {
if (resp == "false"){
return
}
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
particlesJS.load('particles-js', '/shared/main/particles.json', function() {
console.debug('callback - particles.js config loaded')
})
}
)

View File

@ -5,7 +5,7 @@ fetch('/config/get/transports.tor', {
.then((resp) => resp.text()) // Transform the data into text .then((resp) => resp.text()) // Transform the data into text
.then(function(resp) { .then(function(resp) {
var displays = document.getElementsByClassName('torInfo') var displays = document.getElementsByClassName('torInfo')
if (resp == true){ if (resp == "true"){
var torSource = new EventSourcePolyfill('/torcircuits', { var torSource = new EventSourcePolyfill('/torcircuits', {
headers: { headers: {
"token": webpass "token": webpass