fixed, removed log library
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -429,7 +429,6 @@ dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dotenvy",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"prost",
|
||||
"ratatui",
|
||||
"serde",
|
||||
|
||||
@@ -12,7 +12,6 @@ crossterm = "0.28.1"
|
||||
dirs = "6.0.0"
|
||||
dotenvy = "0.15.7"
|
||||
lazy_static = "1.5.0"
|
||||
log = "0.4.27"
|
||||
prost = "0.13.5"
|
||||
ratatui = "0.29.0"
|
||||
serde = { version = "1.0.218", features = ["derive"] }
|
||||
|
||||
@@ -36,12 +36,21 @@ pub async fn save(
|
||||
login_state.set_has_unsaved_changes(false);
|
||||
login_state.error_message = None;
|
||||
|
||||
let success_message = "Login Successful!".to_string();
|
||||
// Format the success message using response data
|
||||
let success_message = format!(
|
||||
"Login Successful!\n\n\
|
||||
Username: {}\n\
|
||||
User ID: {}\n\
|
||||
Role: {}",
|
||||
response.username,
|
||||
response.user_id,
|
||||
response.role
|
||||
);
|
||||
|
||||
app_state.show_dialog(
|
||||
"Login Success",
|
||||
&success_message,
|
||||
vec!["OK".to_string()],
|
||||
vec!["Menu".to_string(), "Exit".to_string()],
|
||||
DialogPurpose::LoginSuccess,
|
||||
);
|
||||
login_state.password.clear();
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::tui::functions::common::login; // <-- Add login module import
|
||||
use std::time::Instant;
|
||||
use crossterm::cursor::SetCursorStyle;
|
||||
use crossterm::event as crossterm_event;
|
||||
use log; // <-- Add log import
|
||||
use tracing::{info, error};
|
||||
|
||||
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = Config::load()?;
|
||||
@@ -137,7 +137,6 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// --- End Cursor Visibility Logic ---
|
||||
|
||||
// --- 2. Check for Pending Login Action ---
|
||||
// Check *after* drawing, so the loading state was rendered.
|
||||
if login_state.login_request_pending {
|
||||
// Reset the flag *before* calling save
|
||||
login_state.login_request_pending = false;
|
||||
@@ -145,27 +144,33 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create AuthClient and call save
|
||||
match AuthClient::new().await {
|
||||
Ok(mut auth_client_instance) => {
|
||||
// Call the ORIGINAL save function from the login module
|
||||
let save_result = login::save(
|
||||
&mut auth_state,
|
||||
&mut login_state,
|
||||
&mut auth_client_instance,
|
||||
&mut auth_client_instance, // Pass the new client instance
|
||||
&mut app_state,
|
||||
).await;
|
||||
|
||||
// Use tracing for logging the outcome
|
||||
match save_result {
|
||||
Ok(msg) => log::info!("Login save result: {}", msg),
|
||||
Err(e) => log::error!("Error during login save: {}", e),
|
||||
// save returns Result<String, Error>, Ok contains the message
|
||||
Ok(msg) => info!(message = %msg, "Login save result"), // Use tracing::info!
|
||||
Err(e) => error!(error = %e, "Error during login save"), // Use tracing::error!
|
||||
}
|
||||
// Note: save already handles showing the final dialog (success/failure)
|
||||
}
|
||||
Err(e) => {
|
||||
// Handle connection error
|
||||
app_state.show_dialog(
|
||||
// Handle client connection error - show dialog directly
|
||||
// Ensure flag is already false here
|
||||
app_state.show_dialog( // Use show_dialog, not update_dialog_content
|
||||
"Login Failed",
|
||||
&format!("Connection Error: {}", e),
|
||||
vec!["OK".to_string()],
|
||||
DialogPurpose::LoginFailed,
|
||||
DialogPurpose::LoginFailed, // Use appropriate purpose
|
||||
);
|
||||
login_state.error_message = Some(format!("Connection Error: {}", e));
|
||||
log::error!("Failed to create AuthClient: {}", e);
|
||||
error!(error = %e, "Failed to create AuthClient"); // Use tracing::error!
|
||||
}
|
||||
}
|
||||
// After save runs, the state (dialog content, etc.) is updated.
|
||||
|
||||
Reference in New Issue
Block a user