tidy
This commit is contained in:
@@ -5,7 +5,7 @@ use client_network::{
|
|||||||
use crossbeam_channel::{Receiver, Sender};
|
use crossbeam_channel::{Receiver, Sender};
|
||||||
use egui::{
|
use egui::{
|
||||||
Align, CentralPanel, CollapsingHeader, Color32, Context, CornerRadius, Frame, Id, Layout,
|
Align, CentralPanel, CollapsingHeader, Color32, Context, CornerRadius, Frame, Id, Layout,
|
||||||
ProgressBar, Response, ScrollArea, SidePanel, Stroke, TopBottomPanel, Ui, ViewportCommand,
|
ProgressBar, ScrollArea, SidePanel, Stroke, TopBottomPanel, Ui, ViewportCommand,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@@ -278,6 +278,7 @@ impl eframe::App for P2PClientApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.remaining_chunks.is_empty() {
|
if self.remaining_chunks.is_empty() {
|
||||||
|
self.current_total_chunks = None;
|
||||||
self.current_received_chunks = 0;
|
self.current_received_chunks = 0;
|
||||||
println!("bigfile téléchargé");
|
println!("bigfile téléchargé");
|
||||||
}
|
}
|
||||||
@@ -431,12 +432,17 @@ impl eframe::App for P2PClientApp {
|
|||||||
if ui.button("Connect").clicked() {
|
if ui.button("Connect").clicked() {
|
||||||
let addr = self.connect_address_input.clone();
|
let addr = self.connect_address_input.clone();
|
||||||
let name = self.connect_name_input.clone();
|
let name = self.connect_name_input.clone();
|
||||||
let _ = self
|
let _ = self.network_cmd_tx.send(
|
||||||
.network_cmd_tx
|
NetworkCommand::ConnectToServerPut(
|
||||||
.send(NetworkCommand::ConnectToServerPut(addr, name));
|
addr,
|
||||||
|
name.to_string(),
|
||||||
|
),
|
||||||
|
);
|
||||||
self.server_status = ServerStatus::Loading;
|
self.server_status = ServerStatus::Loading;
|
||||||
ui.close();
|
ui.close();
|
||||||
self.show_network_window = false;
|
self.show_network_window = false;
|
||||||
|
self.loaded_fs
|
||||||
|
.insert(name.to_string(), self.shared_tree.clone());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -520,7 +526,19 @@ impl eframe::App for P2PClientApp {
|
|||||||
for peer in &self.known_peers {
|
for peer in &self.known_peers {
|
||||||
let is_active =
|
let is_active =
|
||||||
self.active_peer.as_ref().map_or(false, |id| id == &peer.0); // if peer.id == self.active_peer_id
|
self.active_peer.as_ref().map_or(false, |id| id == &peer.0); // if peer.id == self.active_peer_id
|
||||||
|
//
|
||||||
|
if peer.0.eq(&self.connect_name_input) {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
let resp = ui.selectable_label(
|
||||||
|
is_active,
|
||||||
|
format!("{} (you)", peer.0),
|
||||||
|
);
|
||||||
|
|
||||||
|
if resp.clicked() {
|
||||||
|
self.active_peer = Some(peer.0.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
// place spinner to the right of the label
|
// place spinner to the right of the label
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let resp = if &self.active_server == &peer.0 {
|
let resp = if &self.active_server == &peer.0 {
|
||||||
@@ -561,12 +579,13 @@ impl eframe::App for P2PClientApp {
|
|||||||
.contains_key(self.active_peer.as_ref().unwrap())
|
.contains_key(self.active_peer.as_ref().unwrap())
|
||||||
{
|
{
|
||||||
//todo!();
|
//todo!();
|
||||||
let _ =
|
let _ = self.network_cmd_tx.send(
|
||||||
self.network_cmd_tx.send(NetworkCommand::Discover(
|
NetworkCommand::Discover(
|
||||||
peer.0.clone(),
|
peer.0.clone(),
|
||||||
"root".to_string(),
|
"root".to_string(),
|
||||||
self.connected_address.clone(),
|
self.connected_address.clone(),
|
||||||
));
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp.context_menu(|ui| {
|
resp.context_menu(|ui| {
|
||||||
@@ -625,74 +644,7 @@ impl eframe::App for P2PClientApp {
|
|||||||
// ... autres boutons
|
// ... autres boutons
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
// if self.loading_peers.contains(&peer.0) {
|
|
||||||
// ui.spinner();
|
|
||||||
// }
|
|
||||||
|
|
||||||
//if selectable.clicked() {
|
|
||||||
// switch to displaying this peer's tree
|
|
||||||
//self.active_peer = Some(peer.0.clone());
|
|
||||||
//// Request root content if not loaded
|
|
||||||
//if !self
|
|
||||||
// .loaded_fs
|
|
||||||
// .contains_key(self.active_peer.as_ref().unwrap())
|
|
||||||
//{
|
|
||||||
// //todo!();
|
|
||||||
// let _ = self.network_cmd_tx.send(NetworkCommand::Discover(
|
|
||||||
// peer.0.clone(),
|
|
||||||
// "root".to_string(),
|
|
||||||
// self.connected_address.clone(),
|
|
||||||
// ));
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//selectable.context_menu(|ui| {
|
|
||||||
// // ... action
|
|
||||||
// match self.server_status {
|
|
||||||
// ServerStatus::Connected => {
|
|
||||||
// if ui
|
|
||||||
// .button("Utiliser le peer en tant que serveur")
|
|
||||||
// .clicked()
|
|
||||||
// {
|
|
||||||
// self.active_server = peer.0.to_string();
|
|
||||||
// let res = self.network_cmd_tx.send(
|
|
||||||
// NetworkCommand::ServerHandshake(
|
|
||||||
// peer.0.to_string(),
|
|
||||||
// self.connected_address.clone(),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// _ => {}
|
|
||||||
// }
|
|
||||||
// if ui.button("Send Ping").clicked() {
|
|
||||||
// let res = self.network_cmd_tx.send(NetworkCommand::Ping(
|
|
||||||
// peer.0.to_string(),
|
|
||||||
// self.connected_address.clone(),
|
|
||||||
// ));
|
|
||||||
|
|
||||||
// self.loading_peers.push(peer.0.to_owned());
|
|
||||||
// }
|
|
||||||
// if ui.button("Send Nat Traversal Request").clicked() {
|
|
||||||
// match self.network_cmd_tx.send(NetworkCommand::NatTraversal(
|
|
||||||
// peer.0.to_string(),
|
|
||||||
// self.connected_address.clone(),
|
|
||||||
// )) {
|
|
||||||
// Ok(_) => {
|
|
||||||
// print!("[+] successfully sent nat traversal request")
|
|
||||||
// }
|
|
||||||
// Err(_) => {
|
|
||||||
// print!("[-] failed to send nat traversal request")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if ui.button("Infos").clicked() {
|
|
||||||
// // action 3
|
|
||||||
// ui.close();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // ... autres boutons
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user