fixed UI sentbox

This commit is contained in:
Kevin Froman 2019-03-04 21:16:33 -06:00
parent 9b6553511b
commit c262b67626
3 changed files with 19 additions and 9 deletions

View File

@ -20,6 +20,7 @@
import sys, os, json
from flask import Response, request, redirect, Blueprint, abort
import core
from onionrusers import contactmanager
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
import loadinbox, sentboxdb
@ -54,5 +55,7 @@ def list_sentbox():
if sentbox_list_copy[x]['hash'] in deleted:
x -= 1
sentbox_list.pop(x)
else:
sentbox_list[x]['name'] = contactmanager.ContactManager(c, sentbox_list[x]['peer'], saveUser=False).get_info('name')
return json.dumps(sentbox_list)

View File

@ -191,36 +191,41 @@ function getSentbox(){
.then(function(resp) {
var keys = [];
var entry = document.createElement('div')
var entryUsed;
for(var k in resp) keys.push(k);
if (keys.length == 0){
threadPart.innerHTML = "nothing to show here yet."
}
for (var i = 0; i < keys.length; i++){
var entry = document.createElement('div')
var obj = resp[i];
var obj = resp[i]
var toLabel = document.createElement('span')
toLabel.innerText = 'To: '
var toEl = document.createElement('input')
var preview = document.createElement('span')
var deleteBtn = document.createElement('button')
var message = resp[i]['message']
deleteBtn.classList.add('deleteBtn', 'dangerBtn')
deleteBtn.innerText = 'X'
toEl.readOnly = true
toEl.value = resp[i]['peer']
if (resp[i]['name'] == null){
toEl.value = resp[i]['peer']
}
else{
toEl.value = resp[i]['name']
}
preview.innerText = '(' + resp[i]['subject'] + ')'
entry.setAttribute('data-hash', resp[i]['hash'])
entry.appendChild(deleteBtn)
entry.appendChild(toLabel)
entry.appendChild(toEl)
entry.appendChild(preview)
entryUsed = resp[i]['message']
entry.onclick = function(){
entry.onclick = (function(tree, el, msg) {return function() {
console.log(resp)
if (! entry.target.classList.contains('deleteBtn')){
showSentboxWindow(toEl.value, entryUsed)
if (! entry.classList.contains('deleteBtn')){
showSentboxWindow(el.value, msg)
}
}
};})(entry, toEl, message);
deleteBtn.onclick = function(){
entry.parentNode.removeChild(entry);
deleteMessage(entry.getAttribute('data-hash'))

View File

@ -27,6 +27,7 @@ function sendMail(to, message, subject){
//postData = {"postData": '{"to": "' + to + '", "message": "' + message + '"}'} // galaxy brain
postData = {'message': message, 'to': to, 'type': 'pm', 'encrypt': true, 'meta': JSON.stringify({'subject': subject})}
postData = JSON.stringify(postData)
sendForm.style.display = 'none'
fetch('/insertblock', {
method: 'POST',
body: postData,
@ -36,6 +37,8 @@ function sendMail(to, message, subject){
}})
.then((resp) => resp.text()) // Transform the data into json
.then(function(data) {
sendForm.style.display = 'block'
alert('Queued for sending!')
})
}
@ -51,7 +54,6 @@ sendForm.onsubmit = function(){
return false
}
}
sendMail(to.value, messageContent.value, subject.value)
return false
}