clean up client ui

This commit is contained in:
John Smith 2022-08-29 15:19:28 -04:00
parent 38ec19d9da
commit f1377e6eba
2 changed files with 13 additions and 9 deletions

View File

@ -111,7 +111,8 @@ attach - attach the server to the Veilid network
detach - detach the server from the Veilid network detach - detach the server from the Veilid network
debug - send a debugging command to the Veilid server debug - send a debugging command to the Veilid server
change_log_level - change the log level for a tracing layer change_log_level - change the log level for a tracing layer
"#, "#
.to_owned(),
); );
let ui = self.ui(); let ui = self.ui();
ui.send_callback(callback); ui.send_callback(callback);
@ -202,7 +203,7 @@ change_log_level - change the log level for a tracing layer
let log_level = match convert_loglevel(&rest.unwrap_or_default()) { let log_level = match convert_loglevel(&rest.unwrap_or_default()) {
Ok(v) => v, Ok(v) => v,
Err(e) => { Err(e) => {
error!("failed to change log level: {}", e); ui.add_node_event(format!("Failed to change log level: {}", e));
ui.send_callback(callback); ui.send_callback(callback);
return; return;
} }
@ -210,12 +211,14 @@ change_log_level - change the log level for a tracing layer
match capi.server_change_log_level(layer, log_level).await { match capi.server_change_log_level(layer, log_level).await {
Ok(()) => { Ok(()) => {
info!("Log level changed"); ui.display_string_dialog("Success", "Log level changed", callback);
ui.send_callback(callback);
} }
Err(e) => { Err(e) => {
error!("Server command 'change_log_level' failed: {}", e); ui.display_string_dialog(
ui.send_callback(callback); "Server command 'change_log_level' failed",
e.to_string(),
callback,
);
} }
} }
}); });
@ -326,8 +329,9 @@ change_log_level - change the log level for a tracing layer
} }
pub fn update_log(&mut self, log: veilid_core::VeilidStateLog) { pub fn update_log(&mut self, log: veilid_core::VeilidStateLog) {
let message = format!("{}: {}", log.log_level, log.message); self.inner()
self.inner().ui.add_node_event(&message); .ui
.add_node_event(format!("{}: {}", log.log_level, log.message));
} }
pub fn update_shutdown(&mut self) { pub fn update_shutdown(&mut self) {

View File

@ -790,7 +790,7 @@ impl UI {
inner.ui_state.connection_state.set(state); inner.ui_state.connection_state.set(state);
let _ = inner.cb_sink.send(Box::new(UI::update_cb)); let _ = inner.cb_sink.send(Box::new(UI::update_cb));
} }
pub fn add_node_event(&self, event: &str) { pub fn add_node_event(&self, event: String) {
let inner = self.inner.borrow(); let inner = self.inner.borrow();
let color = *inner.log_colors.get(&Level::Info).unwrap(); let color = *inner.log_colors.get(&Level::Info).unwrap();
for line in event.lines() { for line in event.lines() {