Refresh name button
This commit is contained in:
parent
79a3ad1790
commit
861e072537
@ -1,7 +1,7 @@
|
|||||||
# AIRA
|
# AIRA
|
||||||
AIRA is peer-to-peer encrypted communication tool for local networks built on the [PSEC protocol](https://forge.chapril.org/hardcoresushi/PSEC). It allows to securely send text messages and files without any server or Internet access. AIRA automatically discovers and connects to other peers on your network, so you don't need any prior configuration to start communicating.
|
AIRA is peer-to-peer encrypted communication tool for local networks built on the [PSEC protocol](https://forge.chapril.org/hardcoresushi/PSEC). It allows to securely send text messages and files without any server or Internet access. AIRA automatically discovers and connects to other peers on your network, so you don't need any prior configuration to start communicating.
|
||||||
|
|
||||||
![Screenshot of a conversation between Alice and Bob on AIRA](/screenshot.png)
|
![Screenshot of a conversation between Alice and Bob on AIRA](https://forge.chapril.org/hardcoresushi/AIRA/raw/branch/master/screenshot.png)
|
||||||
|
|
||||||
# Rationale
|
# Rationale
|
||||||
When people want to send a file from one computer to another located only meters apart, they usually send it via mail. This mail usually goes through many servers around the world before reaching its final destination.
|
When people want to send a file from one computer to another located only meters apart, they usually send it via mail. This mail usually goes through many servers around the world before reaching its final destination.
|
||||||
|
@ -37,6 +37,17 @@ button::after {
|
|||||||
button:hover::after {
|
button:hover::after {
|
||||||
background-color: var(--accent);
|
background-color: var(--accent);
|
||||||
}
|
}
|
||||||
|
.classic_button {
|
||||||
|
background-color: var(--button-background);
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.classic_button:hover {
|
||||||
|
background-color: var(--accent);
|
||||||
|
}
|
||||||
input[type="file"] {
|
input[type="file"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -104,17 +115,6 @@ input[type="file"] {
|
|||||||
display: block;
|
display: block;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
.popup button {
|
|
||||||
background-color: var(--button-background);
|
|
||||||
color: white;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.popup button:hover {
|
|
||||||
background-color: var(--accent);
|
|
||||||
}
|
|
||||||
.popup span {
|
.popup span {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@ -128,13 +128,17 @@ input[type="file"] {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.popup .session_info h2 {
|
#session_info .name {
|
||||||
text-align: center;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
.popup .session_info p:first-of-type, .popup .session_info pre {
|
#session_info .name button::after {
|
||||||
|
content: url("/static/imgs/icons/refresh");
|
||||||
|
}
|
||||||
|
#session_info p:first-of-type, #session_info pre {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
.popup .session_info p:nth-of-type(2) {
|
#session_info p, #session_info pre {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
.button_row {
|
.button_row {
|
||||||
|
@ -63,6 +63,7 @@ document.getElementById("delete_conversation").onclick = function() {
|
|||||||
mainDiv.appendChild(p1);
|
mainDiv.appendChild(p1);
|
||||||
mainDiv.appendChild(p2);
|
mainDiv.appendChild(p2);
|
||||||
let button = document.createElement("button");
|
let button = document.createElement("button");
|
||||||
|
button.classList.add("classic_button");
|
||||||
button.textContent = "Delete";
|
button.textContent = "Delete";
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
socket.send("delete_conversation "+currentSessionId);
|
socket.send("delete_conversation "+currentSessionId);
|
||||||
@ -89,6 +90,7 @@ document.getElementById("remove_contact").onclick = function() {
|
|||||||
p2.textContent = "Do you really want to remove this contact ?";
|
p2.textContent = "Do you really want to remove this contact ?";
|
||||||
mainDiv.appendChild(p2);
|
mainDiv.appendChild(p2);
|
||||||
let button = document.createElement("button");
|
let button = document.createElement("button");
|
||||||
|
button.classList.add("classic_button");
|
||||||
button.textContent = "Delete";
|
button.textContent = "Delete";
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
socket.send("uncontact "+currentSessionId);
|
socket.send("uncontact "+currentSessionId);
|
||||||
@ -130,6 +132,7 @@ document.getElementById("verify").onclick = function() {
|
|||||||
let buttonRow = document.createElement("div");
|
let buttonRow = document.createElement("div");
|
||||||
buttonRow.classList.add("button_row");
|
buttonRow.classList.add("button_row");
|
||||||
let verifyButton = document.createElement("button");
|
let verifyButton = document.createElement("button");
|
||||||
|
verifyButton.classList.add("classic_button");
|
||||||
verifyButton.textContent = "They match";
|
verifyButton.textContent = "They match";
|
||||||
verifyButton.onclick = function() {
|
verifyButton.onclick = function() {
|
||||||
socket.send("verify "+currentSessionId);
|
socket.send("verify "+currentSessionId);
|
||||||
@ -140,6 +143,7 @@ document.getElementById("verify").onclick = function() {
|
|||||||
};
|
};
|
||||||
buttonRow.appendChild(verifyButton);
|
buttonRow.appendChild(verifyButton);
|
||||||
let cancelButton = document.createElement("button");
|
let cancelButton = document.createElement("button");
|
||||||
|
cancelButton.classList.add("classic_button");
|
||||||
cancelButton.textContent = "They don't match";
|
cancelButton.textContent = "They don't match";
|
||||||
cancelButton.onclick = removePopup;
|
cancelButton.onclick = removePopup;
|
||||||
buttonRow.appendChild(cancelButton);
|
buttonRow.appendChild(cancelButton);
|
||||||
@ -157,6 +161,7 @@ document.getElementById("logout").onclick = function() {
|
|||||||
p_ask.textContent = "Do you really want to log out ?";
|
p_ask.textContent = "Do you really want to log out ?";
|
||||||
mainDiv.appendChild(p_ask);
|
mainDiv.appendChild(p_ask);
|
||||||
let button = document.createElement("button");
|
let button = document.createElement("button");
|
||||||
|
button.classList.add("classic_button");
|
||||||
button.textContent = "Log out";
|
button.textContent = "Log out";
|
||||||
button.onclick = logout;
|
button.onclick = logout;
|
||||||
mainDiv.appendChild(button);
|
mainDiv.appendChild(button);
|
||||||
@ -243,6 +248,7 @@ profile_div.onclick = function() {
|
|||||||
inputName.value = identityName;
|
inputName.value = identityName;
|
||||||
sectionName.appendChild(inputName);
|
sectionName.appendChild(inputName);
|
||||||
let saveNameButton = document.createElement("button");
|
let saveNameButton = document.createElement("button");
|
||||||
|
saveNameButton.classList.add("classic_button");;
|
||||||
saveNameButton.textContent = "Save";
|
saveNameButton.textContent = "Save";
|
||||||
saveNameButton.onclick = function() {
|
saveNameButton.onclick = function() {
|
||||||
socket.send("change_name "+document.getElementById("new_name").value);
|
socket.send("change_name "+document.getElementById("new_name").value);
|
||||||
@ -272,6 +278,7 @@ profile_div.onclick = function() {
|
|||||||
errorMsg.style.color = "red";
|
errorMsg.style.color = "red";
|
||||||
sectionPassword.appendChild(errorMsg);
|
sectionPassword.appendChild(errorMsg);
|
||||||
let changePasswordButton = document.createElement("button");
|
let changePasswordButton = document.createElement("button");
|
||||||
|
changePasswordButton.classList.add("classic_button");
|
||||||
changePasswordButton.textContent = "Change password";
|
changePasswordButton.textContent = "Change password";
|
||||||
changePasswordButton.onclick = function() {
|
changePasswordButton.onclick = function() {
|
||||||
let inputs = document.querySelectorAll("input[type=\"password\"]");
|
let inputs = document.querySelectorAll("input[type=\"password\"]");
|
||||||
@ -314,6 +321,7 @@ profile_div.onclick = function() {
|
|||||||
p.style.color = "red";
|
p.style.color = "red";
|
||||||
sectionDelete.appendChild(p);
|
sectionDelete.appendChild(p);
|
||||||
let deleteButton = document.createElement("button");
|
let deleteButton = document.createElement("button");
|
||||||
|
deleteButton.classList.add("classic_button");
|
||||||
deleteButton.textContent = "Delete";
|
deleteButton.textContent = "Delete";
|
||||||
deleteButton.style.backgroundColor = "red";
|
deleteButton.style.backgroundColor = "red";
|
||||||
deleteButton.onclick = function() {
|
deleteButton.onclick = function() {
|
||||||
@ -323,6 +331,7 @@ profile_div.onclick = function() {
|
|||||||
p.textContent = "This action is irreversible. Are you sure you want to delete all your data ?";
|
p.textContent = "This action is irreversible. Are you sure you want to delete all your data ?";
|
||||||
mainDiv.appendChild(p);
|
mainDiv.appendChild(p);
|
||||||
let deleteButton = document.createElement("button");
|
let deleteButton = document.createElement("button");
|
||||||
|
deleteButton.classList.add("classic_button");
|
||||||
deleteButton.style.backgroundColor = "red";
|
deleteButton.style.backgroundColor = "red";
|
||||||
deleteButton.textContent = "Delete";
|
deleteButton.textContent = "Delete";
|
||||||
deleteButton.onclick = function() {
|
deleteButton.onclick = function() {
|
||||||
@ -336,37 +345,7 @@ profile_div.onclick = function() {
|
|||||||
showPopup(mainDiv);
|
showPopup(mainDiv);
|
||||||
};
|
};
|
||||||
let chatHeader = document.getElementById("chat_header");
|
let chatHeader = document.getElementById("chat_header");
|
||||||
chatHeader.children[0].onclick = function() {
|
chatHeader.children[0].onclick = showSessionInfoPopup;
|
||||||
let session = sessionsData.get(currentSessionId);
|
|
||||||
if (typeof session !== "undefined") {
|
|
||||||
let mainDiv = document.createElement("div");
|
|
||||||
mainDiv.classList.add("session_info");
|
|
||||||
mainDiv.appendChild(generateAvatar(session.name));
|
|
||||||
let h2 = document.createElement("h2");
|
|
||||||
h2.textContent = session.name;
|
|
||||||
mainDiv.appendChild(h2);
|
|
||||||
let pFingerprint = document.createElement("p");
|
|
||||||
pFingerprint.textContent = "Fingerprint:";
|
|
||||||
mainDiv.appendChild(pFingerprint);
|
|
||||||
let pre = document.createElement("pre");
|
|
||||||
pre.textContent = ' '+beautifyFingerprint(session.fingerprint);
|
|
||||||
mainDiv.appendChild(pre);
|
|
||||||
if (session.isOnline) {
|
|
||||||
let pIp = document.createElement("p");
|
|
||||||
pIp.textContent = "IP: "+session.ip;
|
|
||||||
mainDiv.appendChild(pIp);
|
|
||||||
let pConnection = document.createElement("p");
|
|
||||||
pConnection.textContent = "Connection: ";
|
|
||||||
if (session.outgoing) {
|
|
||||||
pConnection.textContent += "outgoing";
|
|
||||||
} else {
|
|
||||||
pConnection.textContent += "incomming";
|
|
||||||
}
|
|
||||||
mainDiv.appendChild(pConnection);
|
|
||||||
}
|
|
||||||
showPopup(mainDiv);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
document.querySelector("#refresher button").onclick = function() {
|
document.querySelector("#refresher button").onclick = function() {
|
||||||
socket.send("refresh");
|
socket.send("refresh");
|
||||||
};
|
};
|
||||||
@ -517,6 +496,10 @@ function onNameTold(sessionId, name) {
|
|||||||
sessionsData.get(sessionId).name = name;
|
sessionsData.get(sessionId).name = name;
|
||||||
if (sessionId == currentSessionId) {
|
if (sessionId == currentSessionId) {
|
||||||
displayHeader();
|
displayHeader();
|
||||||
|
if (document.getElementById("session_info") !== null) {
|
||||||
|
removePopup();
|
||||||
|
showSessionInfoPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
displaySessions();
|
displaySessions();
|
||||||
}
|
}
|
||||||
@ -609,6 +592,7 @@ function onAskLargeFiles(sessionId, encodedDownloadLocation, filesInfo) {
|
|||||||
let buttonRow = document.createElement("div");
|
let buttonRow = document.createElement("div");
|
||||||
buttonRow.classList.add("button_row");
|
buttonRow.classList.add("button_row");
|
||||||
let buttonDownload = document.createElement("button");
|
let buttonDownload = document.createElement("button");
|
||||||
|
buttonDownload.classList.add("classic_button");
|
||||||
buttonDownload.textContent = "Download";
|
buttonDownload.textContent = "Download";
|
||||||
buttonDownload.onclick = function() {
|
buttonDownload.onclick = function() {
|
||||||
removePopup();
|
removePopup();
|
||||||
@ -634,6 +618,7 @@ function onAskLargeFiles(sessionId, encodedDownloadLocation, filesInfo) {
|
|||||||
};
|
};
|
||||||
buttonRow.appendChild(buttonDownload);
|
buttonRow.appendChild(buttonDownload);
|
||||||
let buttonRefuse = document.createElement("button");
|
let buttonRefuse = document.createElement("button");
|
||||||
|
buttonRefuse.classList.add("classic_button");
|
||||||
buttonRefuse.textContent = "Refuse";
|
buttonRefuse.textContent = "Refuse";
|
||||||
buttonRefuse.onclick = function() {
|
buttonRefuse.onclick = function() {
|
||||||
removePopup();
|
removePopup();
|
||||||
@ -764,6 +749,47 @@ function beautifyFingerprint(f) {
|
|||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
function showSessionInfoPopup() {
|
||||||
|
let session = sessionsData.get(currentSessionId);
|
||||||
|
if (typeof session !== "undefined") {
|
||||||
|
let mainDiv = document.createElement("div");
|
||||||
|
mainDiv.id = "session_info";
|
||||||
|
mainDiv.appendChild(generateAvatar(session.name));
|
||||||
|
let nameDiv = document.createElement("div");
|
||||||
|
nameDiv.classList.add("name");
|
||||||
|
let h2 = document.createElement("h2");
|
||||||
|
h2.textContent = session.name;
|
||||||
|
nameDiv.appendChild(h2);
|
||||||
|
if (session.isOnline) {
|
||||||
|
let button = document.createElement("button");
|
||||||
|
button.onclick = function() {
|
||||||
|
socket.send("ask_name "+currentSessionId);
|
||||||
|
};
|
||||||
|
nameDiv.appendChild(button);
|
||||||
|
}
|
||||||
|
mainDiv.appendChild(nameDiv);
|
||||||
|
let pFingerprint = document.createElement("p");
|
||||||
|
pFingerprint.textContent = "Fingerprint:";
|
||||||
|
mainDiv.appendChild(pFingerprint);
|
||||||
|
let pre = document.createElement("pre");
|
||||||
|
pre.textContent = ' '+beautifyFingerprint(session.fingerprint);
|
||||||
|
mainDiv.appendChild(pre);
|
||||||
|
if (session.isOnline) {
|
||||||
|
let pIp = document.createElement("p");
|
||||||
|
pIp.textContent = "IP: "+session.ip;
|
||||||
|
mainDiv.appendChild(pIp);
|
||||||
|
let pConnection = document.createElement("p");
|
||||||
|
pConnection.textContent = "Connection: ";
|
||||||
|
if (session.outgoing) {
|
||||||
|
pConnection.textContent += "outgoing";
|
||||||
|
} else {
|
||||||
|
pConnection.textContent += "incomming";
|
||||||
|
}
|
||||||
|
mainDiv.appendChild(pConnection);
|
||||||
|
}
|
||||||
|
showPopup(mainDiv);
|
||||||
|
}
|
||||||
|
}
|
||||||
function addSession(sessionId, name, outgoing, fingerprint, ip, isContact, isVerified, isOnline) {
|
function addSession(sessionId, name, outgoing, fingerprint, ip, isContact, isVerified, isOnline) {
|
||||||
sessionsData.set(sessionId, {
|
sessionsData.set(sessionId, {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -230,6 +230,14 @@ async fn websocket_worker(mut ui_connection: UiConnection, global_vars: Arc<RwLo
|
|||||||
Err(e) => print_error!(e)
|
Err(e) => print_error!(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"ask_name" => {
|
||||||
|
let session_id: usize = args[1].parse().unwrap();
|
||||||
|
if let Err(e) = session_manager.send_command(&session_id, SessionCommand::Send {
|
||||||
|
buff: protocol::ask_name()
|
||||||
|
}).await {
|
||||||
|
print_error!(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
"change_name" => {
|
"change_name" => {
|
||||||
let new_name = &msg[args[0].len()+1..];
|
let new_name = &msg[args[0].len()+1..];
|
||||||
match session_manager.change_name(new_name.to_string()).await {
|
match session_manager.change_name(new_name.to_string()).await {
|
||||||
|
Loading…
Reference in New Issue
Block a user