From 45221291fa193df518f3697261ddf57e18974442 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 4 Mar 2019 13:03:35 -0600 Subject: [PATCH] work on friends and mail UI --- onionr/onionr.py | 6 +++--- onionr/static-data/default-plugins/pms/mailapi.py | 7 +------ onionr/static-data/www/friends/friends.js | 3 ++- onionr/static-data/www/friends/index.html | 2 +- onionr/static-data/www/mail/mail.js | 15 +++++++-------- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/onionr/onionr.py b/onionr/onionr.py index 1a16742b..8e64214b 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -844,9 +844,9 @@ class Onionr: # count stats 'div2' : True, - 'Known Peers Count' : str(len(self.onionrCore.listPeers()) - 1), - 'Enabled Plugins Count' : str(len(config.get('plugins.enabled', list()))) + ' / ' + str(len(os.listdir(self.dataDir + 'plugins/'))), - 'Known Blocks Count' : str(totalBlocks), + 'Known Peers' : str(len(self.onionrCore.listPeers()) - 1), + 'Enabled Plugins' : str(len(config.get('plugins.enabled', list()))) + ' / ' + str(len(os.listdir(self.dataDir + 'plugins/'))), + 'Stored Blocks' : str(totalBlocks), 'Percent Blocks Signed' : str(round(100 * signedBlocks / max(totalBlocks, 1), 2)) + '%' } diff --git a/onionr/static-data/default-plugins/pms/mailapi.py b/onionr/static-data/default-plugins/pms/mailapi.py index cdc77094..31f6f18e 100644 --- a/onionr/static-data/default-plugins/pms/mailapi.py +++ b/onionr/static-data/default-plugins/pms/mailapi.py @@ -52,12 +52,7 @@ def list_sentbox(): deleted = [] for x in range(len(sentbox_list_copy)): if sentbox_list_copy[x]['hash'] in deleted: + x -= 1 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) \ No newline at end of file diff --git a/onionr/static-data/www/friends/friends.js b/onionr/static-data/www/friends/friends.js index 68cc8661..c18da68b 100755 --- a/onionr/static-data/www/friends/friends.js +++ b/onionr/static-data/www/friends/friends.js @@ -33,8 +33,9 @@ addForm.onsubmit = function(){ headers: { "token": webpass }}).then(function(data) { + 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}) } }) diff --git a/onionr/static-data/www/friends/index.html b/onionr/static-data/www/friends/index.html index 8c1074fe..3d214274 100755 --- a/onionr/static-data/www/friends/index.html +++ b/onionr/static-data/www/friends/index.html @@ -18,7 +18,7 @@ Home

Friend Manager

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