now shows log in sidebar
This commit is contained in:
parent
c23b286540
commit
60c7e6cb37
@ -1,6 +1,6 @@
|
|||||||
<div id="quickviewDefault" class="quickview">
|
<div id="quickviewDefault" class="quickview">
|
||||||
<header class="quickview-header">
|
<header class="quickview-header">
|
||||||
<span class="delete" data-dismiss="quickview"></span>
|
<span class="delete closeSidebar" data-dismiss="quickview"></span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="quickview-body">
|
<div class="quickview-body">
|
||||||
@ -20,6 +20,7 @@
|
|||||||
Add Peer
|
Add Peer
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<pre id="logfileOutput"></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,6 +10,22 @@ fetch('/shared/sidebar/sidebar.html', {
|
|||||||
sidebarAddPeerRegister()
|
sidebarAddPeerRegister()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var lastLogOffset = 0
|
||||||
|
async function showLog(){
|
||||||
|
fetch('/readfileoffset/onionr.log?offset=' + lastLogOffset, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"token": webpass
|
||||||
|
}})
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then(function(resp){
|
||||||
|
lastLogOffset = resp['new_offset']
|
||||||
|
document.getElementById('logfileOutput').innerText += resp.data.replace(
|
||||||
|
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sidebarAddPeerRegister(){
|
function sidebarAddPeerRegister(){
|
||||||
document.getElementById('addPeerBtn').onclick = function(){
|
document.getElementById('addPeerBtn').onclick = function(){
|
||||||
let newPeer = document.getElementById('addPeerInput').value
|
let newPeer = document.getElementById('addPeerInput').value
|
||||||
@ -55,12 +71,18 @@ function sidebarAddPeerRegister(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("keydown", function(event) {
|
window.addEventListener("keydown", function(event) {
|
||||||
|
var refreshSideBarInterval = null
|
||||||
|
document.getElementsByClassName('closeSidebar')[0].onclick = function(){
|
||||||
|
clearInterval(sidebarLogInterval)
|
||||||
|
clearInterval(refreshSideBarInterval)
|
||||||
|
}
|
||||||
if (event.key === "s"){
|
if (event.key === "s"){
|
||||||
if (document.activeElement.nodeName == "TEXTAREA" || document.activeElement.nodeName == "INPUT"){
|
if (document.activeElement.nodeName == "TEXTAREA" || document.activeElement.nodeName == "INPUT"){
|
||||||
if (! document.activeElement.hasAttribute("readonly")){
|
if (! document.activeElement.hasAttribute("readonly")){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sidebarLogInterval = setInterval(function(){showLog()}, 1000)
|
||||||
let refreshSideBar = function(){
|
let refreshSideBar = function(){
|
||||||
if (document.hidden){return}
|
if (document.hidden){return}
|
||||||
var existingValue = document.getElementById("insertingBlocks").innerText
|
var existingValue = document.getElementById("insertingBlocks").innerText
|
||||||
@ -99,7 +121,7 @@ window.addEventListener("keydown", function(event) {
|
|||||||
document.getElementById("uploadBlocks").innerText = resp.split(',').length - 1
|
document.getElementById("uploadBlocks").innerText = resp.split(',').length - 1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
setInterval(refreshSideBar, 3000)
|
refreshSideBarInterval = setInterval(refreshSideBar, 3000)
|
||||||
|
|
||||||
setTimeout(function(){document.getElementsByClassName('sidebarBtn')[0].click()}, 300)
|
setTimeout(function(){document.getElementsByClassName('sidebarBtn')[0].click()}, 300)
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,15 @@ createdirs.create_dirs()
|
|||||||
setup_config()
|
setup_config()
|
||||||
|
|
||||||
class TestReadOffset(unittest.TestCase):
|
class TestReadOffset(unittest.TestCase):
|
||||||
|
def test_read_offset(self):
|
||||||
|
temp = tempfile.mkstemp()[1]
|
||||||
|
f = open(temp, 'wb')
|
||||||
|
data = b"test1\ntest2\ntest3\test4"
|
||||||
|
f.write(data)
|
||||||
|
f.close()
|
||||||
|
self.assertEqual(readoffset.read_from_offset(temp, 5).data, data[5:])
|
||||||
|
self.assertEqual(readoffset.read_from_offset(temp, 5).new_offset, len(data))
|
||||||
|
os.remove(temp)
|
||||||
def test_read_whole(self):
|
def test_read_whole(self):
|
||||||
temp = tempfile.mkstemp()[1]
|
temp = tempfile.mkstemp()[1]
|
||||||
f = open(temp, 'wb')
|
f = open(temp, 'wb')
|
||||||
@ -23,6 +32,7 @@ class TestReadOffset(unittest.TestCase):
|
|||||||
f.write(data)
|
f.write(data)
|
||||||
f.close()
|
f.close()
|
||||||
self.assertEqual(readoffset.read_from_offset(temp).data, data)
|
self.assertEqual(readoffset.read_from_offset(temp).data, data)
|
||||||
|
self.assertEqual(readoffset.read_from_offset(temp).new_offset, len(data))
|
||||||
os.remove(temp)
|
os.remove(temp)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user