pr work
This commit is contained in:
@@ -55,6 +55,7 @@ struct UIState {
|
||||
network_down_up: Dirty<(f32, f32)>,
|
||||
connection_state: Dirty<ConnectionState>,
|
||||
peers_state: Dirty<Vec<PeerTableData>>,
|
||||
node_id: Dirty<String>,
|
||||
}
|
||||
|
||||
impl UIState {
|
||||
@@ -65,6 +66,7 @@ impl UIState {
|
||||
network_down_up: Dirty::new((0.0, 0.0)),
|
||||
connection_state: Dirty::new(ConnectionState::Disconnected),
|
||||
peers_state: Dirty::new(Vec::new()),
|
||||
node_id: Dirty::new("".to_owned()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,6 +216,11 @@ impl UI {
|
||||
});
|
||||
}
|
||||
|
||||
fn node_events_panel(
|
||||
s: &mut Cursive,
|
||||
) -> ViewRef<Panel<ResizedView<NamedView<ScrollView<FlexiLoggerView>>>>> {
|
||||
s.find_name("node-events-panel").unwrap()
|
||||
}
|
||||
fn command_line(s: &mut Cursive) -> ViewRef<EditView> {
|
||||
s.find_name("command-line").unwrap()
|
||||
}
|
||||
@@ -572,6 +579,12 @@ impl UI {
|
||||
}
|
||||
}
|
||||
|
||||
fn refresh_main_titlebar(s: &mut Cursive) {
|
||||
let mut main_window = UI::node_events_panel(s);
|
||||
let inner = Self::inner_mut(s);
|
||||
main_window.set_title(format!("Node: {}", inner.ui_state.node_id.get()));
|
||||
}
|
||||
|
||||
fn refresh_statusbar(s: &mut Cursive) {
|
||||
let mut statusbar = UI::status_bar(s);
|
||||
|
||||
@@ -634,6 +647,7 @@ impl UI {
|
||||
let mut refresh_button_attach = false;
|
||||
let mut refresh_connection_dialog = false;
|
||||
let mut refresh_peers = false;
|
||||
let mut refresh_main_titlebar = false;
|
||||
if inner.ui_state.attachment_state.take_dirty() {
|
||||
refresh_statusbar = true;
|
||||
refresh_button_attach = true;
|
||||
@@ -654,6 +668,9 @@ impl UI {
|
||||
if inner.ui_state.peers_state.take_dirty() {
|
||||
refresh_peers = true;
|
||||
}
|
||||
if inner.ui_state.node_id.take_dirty() {
|
||||
refresh_main_titlebar = true;
|
||||
}
|
||||
|
||||
drop(inner);
|
||||
|
||||
@@ -669,6 +686,9 @@ impl UI {
|
||||
if refresh_peers {
|
||||
Self::refresh_peers(s);
|
||||
}
|
||||
if refresh_main_titlebar {
|
||||
Self::refresh_main_titlebar(s);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -722,7 +742,8 @@ impl UI {
|
||||
.full_screen(),
|
||||
)
|
||||
.title_position(HAlign::Left)
|
||||
.title("Node Events");
|
||||
.title("Node Events")
|
||||
.with_name("node-events-panel");
|
||||
|
||||
let peers_table_view = PeersTableView::new()
|
||||
.column(PeerTableColumn::NodeId, "Node Id", |c| c.width(43))
|
||||
@@ -839,6 +860,16 @@ impl UI {
|
||||
inner.ui_state.peers_state.set(peers);
|
||||
let _ = inner.cb_sink.send(Box::new(UI::update_cb));
|
||||
}
|
||||
pub fn set_config(&mut self, config: VeilidConfigInner) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
inner.ui_state.node_id.set(
|
||||
config
|
||||
.network
|
||||
.node_id
|
||||
.map(|x| x.encode())
|
||||
.unwrap_or("<unknown>".to_owned()),
|
||||
);
|
||||
}
|
||||
pub fn set_connection_state(&mut self, state: ConnectionState) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
inner.ui_state.connection_state.set(state);
|
||||
|
||||
Reference in New Issue
Block a user