work on friends and mail UI

This commit is contained in:
Kevin Froman 2019-03-04 13:03:35 -06:00
parent 4798308ccd
commit 45221291fa
5 changed files with 14 additions and 19 deletions

View File

@ -844,9 +844,9 @@ class Onionr:
# count stats # count stats
'div2' : True, 'div2' : True,
'Known Peers Count' : str(len(self.onionrCore.listPeers()) - 1), 'Known Peers' : str(len(self.onionrCore.listPeers()) - 1),
'Enabled Plugins Count' : str(len(config.get('plugins.enabled', list()))) + ' / ' + str(len(os.listdir(self.dataDir + 'plugins/'))), 'Enabled Plugins' : str(len(config.get('plugins.enabled', list()))) + ' / ' + str(len(os.listdir(self.dataDir + 'plugins/'))),
'Known Blocks Count' : str(totalBlocks), 'Stored Blocks' : str(totalBlocks),
'Percent Blocks Signed' : str(round(100 * signedBlocks / max(totalBlocks, 1), 2)) + '%' 'Percent Blocks Signed' : str(round(100 * signedBlocks / max(totalBlocks, 1), 2)) + '%'
} }

View File

@ -52,12 +52,7 @@ def list_sentbox():
deleted = [] deleted = []
for x in range(len(sentbox_list_copy)): for x in range(len(sentbox_list_copy)):
if sentbox_list_copy[x]['hash'] in deleted: if sentbox_list_copy[x]['hash'] in deleted:
x -= 1
sentbox_list.pop(x) sentbox_list.pop(x)
'''
hash_list = []
for x in sentbox_list:
hash_list.append({x['hash'])
return ','.join(hash_list)
'''
return json.dumps(sentbox_list) return json.dumps(sentbox_list)

View File

@ -33,8 +33,9 @@ addForm.onsubmit = function(){
headers: { headers: {
"token": webpass "token": webpass
}}).then(function(data) { }}).then(function(data) {
if (alias.value.trim().length > 0){ if (alias.value.trim().length > 0){
post_to_url('/friends/setinfo/' + friend.value + '/name', {'data': alias.value, 'token': webpass}) post_to_url('/friends/setinfo/' + friend.value + '/name', {'data': alias.value, 'token': webpass})
} }
}) })

View File

@ -18,7 +18,7 @@
<a href='/' class='idLink'>Home</a> <a href='/' class='idLink'>Home</a>
<h2>Friend Manager</h2> <h2>Friend Manager</h2>
<form id='addFriend' action='/' method='POST'> <form id='addFriend' action='/' method='POST'>
<label>Friend ID: <input type='text' name='addKey' placeholder='public key/ID' required></label> <label>Friend ID: <input type='text' name='addKey' placeholder='public key/ID' minlength="56" maxlength="56" required></label>
<label>Set Alias: <input type='text' name='data' placeholder='what to call them'></label> <label>Set Alias: <input type='text' name='data' placeholder='what to call them'></label>
<input type='submit' value='Add Friend' class='successBtn'> <input type='submit' value='Add Friend' class='successBtn'>
</form> </form>

View File

@ -57,8 +57,9 @@ function openThread(bHash, sender, date, sigBool, pubkey){
sigEl.classList.remove('danger') sigEl.classList.remove('danger')
} }
else{ else{
sigMsg = 'Bad/no ' + sigMsg + ' (message could be fake)' sigMsg = 'Bad/no ' + sigMsg + ' (message could be impersonating someone)'
sigEl.classList.add('danger') sigEl.classList.add('danger')
replyBtn.style.display = 'none'
} }
sigEl.innerText = sigMsg sigEl.innerText = sigMsg
overlay('messageDisplay') overlay('messageDisplay')
@ -72,7 +73,6 @@ function setActiveTab(tabName){
switch(tabName){ switch(tabName){
case 'inbox': case 'inbox':
refreshPms() refreshPms()
getInbox()
break break
case 'sentbox': case 'sentbox':
getSentbox() getSentbox()
@ -112,13 +112,12 @@ function loadInboxEntries(bHash){
var humanDate = new Date(0) var humanDate = new Date(0)
var metadata = resp['metadata'] var metadata = resp['metadata']
humanDate.setUTCSeconds(resp['meta']['time']) humanDate.setUTCSeconds(resp['meta']['time'])
validSig.style.display = 'none'
if (resp['meta']['signer'] != ''){ if (resp['meta']['signer'] != ''){
senderInput.value = httpGet('/friends/getinfo/' + resp['meta']['signer'] + '/name') senderInput.value = httpGet('/friends/getinfo/' + resp['meta']['signer'] + '/name')
} }
if (resp['meta']['validSig']){ if (! resp['meta']['validSig']){
validSig.innerText = 'Signature Validity: Good' validSig.style.display = 'inline'
}
else{
validSig.innerText = 'Signature Validity: Bad' validSig.innerText = 'Signature Validity: Bad'
validSig.style.color = 'red' validSig.style.color = 'red'
} }
@ -145,9 +144,9 @@ function loadInboxEntries(bHash){
entry.appendChild(deleteBtn) entry.appendChild(deleteBtn)
entry.appendChild(bHashDisplay) entry.appendChild(bHashDisplay)
entry.appendChild(senderInput) entry.appendChild(senderInput)
entry.appendChild(validSig)
entry.appendChild(subjectLine) entry.appendChild(subjectLine)
entry.appendChild(dateStr) entry.appendChild(dateStr)
entry.appendChild(validSig)
entry.classList.add('threadEntry') entry.classList.add('threadEntry')
entry.onclick = function(event){ entry.onclick = function(event){
@ -246,6 +245,7 @@ fetch('/mail/getinbox', {
.then((resp) => resp.text()) // Transform the data into json .then((resp) => resp.text()) // Transform the data into json
.then(function(data) { .then(function(data) {
pms = data.split(',') pms = data.split(',')
getInbox()
}) })
} }
@ -310,5 +310,4 @@ fetch('/friends/list', {
//alert(resp[keys[i]]['name']) //alert(resp[keys[i]]['name'])
} }
}) })
setActiveTab('inbox') setActiveTab('inbox')