mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-04-18 14:56:04 -04:00
Merge branch 'feature/346-cli-statusbar-node-count-status' into 'main'
active and total node count in cli status bar Closes #346 See merge request veilid/veilid!333
This commit is contained in:
commit
a7bb4cb687
@ -72,6 +72,7 @@ struct UIState {
|
||||
network_down_up: Dirty<(f32, f32)>,
|
||||
connection_state: Dirty<ConnectionState>,
|
||||
peers_state: Dirty<Vec<json::JsonValue>>,
|
||||
tunnels_state: Dirty<Vec<json::JsonValue>>,
|
||||
node_id: Dirty<String>,
|
||||
}
|
||||
|
||||
@ -85,6 +86,7 @@ impl UIState {
|
||||
network_down_up: Dirty::new((0.0, 0.0)),
|
||||
connection_state: Dirty::new(ConnectionState::Disconnected),
|
||||
peers_state: Dirty::new(Vec::new()),
|
||||
tunnels_state: Dirty::new(Vec::new()),
|
||||
node_id: Dirty::new("".to_owned()),
|
||||
}
|
||||
}
|
||||
@ -938,11 +940,48 @@ impl CursiveUI {
|
||||
ColorStyle::highlight_inactive(),
|
||||
);
|
||||
status.append_styled("|", ColorStyle::highlight_inactive());
|
||||
// Add tunnel status
|
||||
status.append_styled(" No Tunnels ", ColorStyle::highlight_inactive());
|
||||
// Check for tunnels first, fallback to node count if none
|
||||
let tunnel_count = inner.ui_state.tunnels_state.get().len();
|
||||
if tunnel_count > 0 {
|
||||
status.append_styled(
|
||||
format!(" {} Tunnels ", tunnel_count),
|
||||
ColorStyle::highlight_inactive(),
|
||||
);
|
||||
} else {
|
||||
status.append_styled(" No Tunnels ", ColorStyle::highlight_inactive());
|
||||
}
|
||||
status.append_styled("|", ColorStyle::highlight_inactive());
|
||||
// Add connected vs total nodes count
|
||||
let connected_nodes = inner.ui_state.peers_state.get().len();
|
||||
let total_nodes = inner
|
||||
.ui_state
|
||||
.peers_state
|
||||
.get()
|
||||
.iter()
|
||||
.map(|peer| peer["node_ids"].len())
|
||||
.sum::<usize>();
|
||||
status.append_styled(
|
||||
format!(
|
||||
" {} Connected ({} Nodes Found) ",
|
||||
connected_nodes, total_nodes
|
||||
),
|
||||
ColorStyle::highlight_inactive(),
|
||||
);
|
||||
let tunnel_count = inner.ui_state.tunnels_state.get().len();
|
||||
if tunnel_count > 0 {
|
||||
status.append_styled(
|
||||
format!(" {} Tunnels ", tunnel_count),
|
||||
ColorStyle::highlight_inactive(),
|
||||
);
|
||||
} else {
|
||||
let peer_count = inner.ui_state.peers_state.get().len();
|
||||
status.append_styled(
|
||||
format!(" {} Nodes ", peer_count),
|
||||
ColorStyle::highlight_inactive(),
|
||||
);
|
||||
}
|
||||
status.append_styled("|", ColorStyle::highlight_inactive());
|
||||
};
|
||||
|
||||
statusbar.set_content(status);
|
||||
}
|
||||
|
||||
@ -1330,6 +1369,14 @@ impl UISender for CursiveUISender {
|
||||
}
|
||||
let _ = self.cb_sink.send(Box::new(CursiveUI::update_cb));
|
||||
}
|
||||
fn set_tunnel_status(&mut self, tunnels: Option<Vec<json::JsonValue>>) {
|
||||
let mut inner = self.inner.lock();
|
||||
inner
|
||||
.ui_state
|
||||
.tunnels_state
|
||||
.set(tunnels.unwrap_or_default());
|
||||
let _ = self.cb_sink.send(Box::new(CursiveUI::update_cb));
|
||||
}
|
||||
fn set_config(&mut self, config: &json::JsonValue) {
|
||||
let mut inner = self.inner.lock();
|
||||
|
||||
|
@ -366,6 +366,9 @@ impl UISender for InteractiveUISender {
|
||||
) {
|
||||
//
|
||||
}
|
||||
fn set_tunnel_status(&mut self, _tunnels: Option<Vec<json::JsonValue>>) {
|
||||
//
|
||||
}
|
||||
fn set_config(&mut self, _config: &json::JsonValue) {
|
||||
//
|
||||
}
|
||||
|
@ -248,6 +248,9 @@ impl<R: AsyncRead + Unpin + Send + 'static, W: AsyncWrite + Unpin + Send + 'stat
|
||||
) {
|
||||
//
|
||||
}
|
||||
fn set_tunnel_status(&mut self, _tunnels: Option<Vec<json::JsonValue>>) {
|
||||
//
|
||||
}
|
||||
fn set_config(&mut self, _config: &json::JsonValue) {
|
||||
//
|
||||
}
|
||||
|
@ -237,6 +237,9 @@ impl UISender for LogViewerUISender {
|
||||
) {
|
||||
//
|
||||
}
|
||||
fn set_tunnel_status(&mut self, _tunnels: Option<Vec<json::JsonValue>>) {
|
||||
//
|
||||
}
|
||||
fn set_config(&mut self, _config: &json::JsonValue) {
|
||||
//
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ pub trait UISender: Send {
|
||||
bps_up: u64,
|
||||
peers: Vec<json::JsonValue>,
|
||||
);
|
||||
#[expect(dead_code)]
|
||||
fn set_tunnel_status(&mut self, tunnels: Option<Vec<json::JsonValue>>);
|
||||
fn set_config(&mut self, config: &json::JsonValue);
|
||||
fn set_connection_state(&mut self, state: ConnectionState);
|
||||
fn add_node_event(&self, log_color: Level, event: &str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user