fixed, removed unused stuff and added client side needed stuff
This commit is contained in:
49
Cargo.lock
generated
49
Cargo.lock
generated
@@ -571,6 +571,27 @@ dependencies = [
|
|||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dirs"
|
||||||
|
version = "6.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||||
|
dependencies = [
|
||||||
|
"dirs-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dirs-sys"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"option-ext",
|
||||||
|
"redox_users",
|
||||||
|
"windows-sys 0.59.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "displaydoc"
|
name = "displaydoc"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
@@ -1264,6 +1285,16 @@ version = "0.2.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libredox"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.30.1"
|
version = "0.30.1"
|
||||||
@@ -1369,6 +1400,7 @@ dependencies = [
|
|||||||
"console",
|
"console",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"dialoguer",
|
"dialoguer",
|
||||||
|
"dirs",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"prost",
|
"prost",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
@@ -1530,6 +1562,12 @@ dependencies = [
|
|||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "option-ext"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "overload"
|
name = "overload"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@@ -1810,6 +1848,17 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_users"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.2.15",
|
||||||
|
"libredox",
|
||||||
|
"thiserror 2.0.11",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.11.1"
|
version = "1.11.1"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ clap = { version = "4.5.29", features = ["derive"] }
|
|||||||
console = "0.15.10"
|
console = "0.15.10"
|
||||||
crossterm = "0.28.1"
|
crossterm = "0.28.1"
|
||||||
dialoguer = "0.11.0"
|
dialoguer = "0.11.0"
|
||||||
|
dirs = "6.0.0"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
prost = "0.13.5"
|
prost = "0.13.5"
|
||||||
ratatui = "0.29.0"
|
ratatui = "0.29.0"
|
||||||
|
|||||||
@@ -1,27 +1,21 @@
|
|||||||
// src/client/components/status_line.rs
|
// src/client/components1/handlers/status_line.rs
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
widgets::Paragraph,
|
widgets::Paragraph,
|
||||||
style::Style,
|
style::Style,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
Frame,
|
Frame,
|
||||||
|
text::{Line, Span},
|
||||||
};
|
};
|
||||||
use crate::client::colors::Theme;
|
use crate::client::colors::Theme;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn render_status_line(
|
pub fn render_status_line(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
area: Rect,
|
area: Rect,
|
||||||
current_dir: &str,
|
current_dir: &str,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
is_edit_mode: bool
|
is_edit_mode: bool,
|
||||||
) {
|
) {
|
||||||
// // Create the status line text
|
|
||||||
// let status_line = Line::from(vec![
|
|
||||||
// Span::styled(current_dir, Style::default().fg(theme.fg)),
|
|
||||||
// Span::styled(
|
|
||||||
// program_info,
|
|
||||||
// Style::default().fg(theme.secondary).add_modifier(ratatui::style::Modifier::BOLD), // Use `secondary` color
|
|
||||||
// ),
|
|
||||||
// ]);
|
|
||||||
// Program name and version
|
// Program name and version
|
||||||
let program_info = format!("multieko2 v{}", env!("CARGO_PKG_VERSION"));
|
let program_info = format!("multieko2 v{}", env!("CARGO_PKG_VERSION"));
|
||||||
|
|
||||||
@@ -31,10 +25,56 @@ pub fn render_status_line(
|
|||||||
"[READ-ONLY]"
|
"[READ-ONLY]"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Shorten the current directory path
|
||||||
|
let home_dir = dirs::home_dir().map(|p| p.to_string_lossy().into_owned()).unwrap_or_default();
|
||||||
|
let display_dir = if current_dir.starts_with(&home_dir) {
|
||||||
|
current_dir.replacen(&home_dir, "~", 1)
|
||||||
|
} else {
|
||||||
|
current_dir.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create the full status line text
|
||||||
|
let full_text = format!("{} | {} | {}", mode_text, display_dir, program_info);
|
||||||
|
|
||||||
|
// Check if the full text fits in the available width
|
||||||
|
let available_width = area.width as usize;
|
||||||
|
let mut display_text = if full_text.len() <= available_width {
|
||||||
|
// If it fits, use the full text
|
||||||
|
full_text
|
||||||
|
} else {
|
||||||
|
// If it doesn't fit, prioritize mode and program info, and show only the directory name
|
||||||
|
let dir_name = Path::new(current_dir)
|
||||||
|
.file_name()
|
||||||
|
.and_then(|n| n.to_str())
|
||||||
|
.unwrap_or(current_dir);
|
||||||
|
format!("{} | {} | {}", mode_text, dir_name, program_info)
|
||||||
|
};
|
||||||
|
|
||||||
|
// If even the shortened version overflows, truncate it
|
||||||
|
if display_text.len() > available_width {
|
||||||
|
display_text = display_text.chars().take(available_width).collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the status line text using Line and Span
|
||||||
|
let status_line = Line::from(vec![
|
||||||
|
Span::styled(mode_text, Style::default().fg(theme.accent)),
|
||||||
|
Span::styled(" | ", Style::default().fg(theme.border)),
|
||||||
|
Span::styled(
|
||||||
|
display_text.split(" | ").nth(1).unwrap_or(""), // Directory part
|
||||||
|
Style::default().fg(theme.fg),
|
||||||
|
),
|
||||||
|
Span::styled(" | ", Style::default().fg(theme.border)),
|
||||||
|
Span::styled(
|
||||||
|
program_info,
|
||||||
|
Style::default()
|
||||||
|
.fg(theme.secondary)
|
||||||
|
.add_modifier(ratatui::style::Modifier::BOLD),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
// Render the status line
|
// Render the status line
|
||||||
let text = format!(" {} | {}", mode_text, current_dir);
|
let paragraph = Paragraph::new(status_line)
|
||||||
let paragraph = Paragraph::new(text)
|
.style(Style::default().bg(theme.bg));
|
||||||
.style(Style::default().fg(theme.fg).bg(theme.bg));
|
|
||||||
|
|
||||||
f.render_widget(paragraph, area);
|
f.render_widget(paragraph, area);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ impl AppTerminal {
|
|||||||
&mut self,
|
&mut self,
|
||||||
action: &str,
|
action: &str,
|
||||||
is_saved: &mut bool,
|
is_saved: &mut bool,
|
||||||
// form_state: &mut FormState,
|
|
||||||
form_data: &PostAdresarRequest,
|
|
||||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||||
match action {
|
match action {
|
||||||
"quit" => {
|
"quit" => {
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ impl EventHandler {
|
|||||||
skladu: form_state.values[13].clone(),
|
skladu: form_state.values[13].clone(),
|
||||||
fax: form_state.values[14].clone(),
|
fax: form_state.values[14].clone(),
|
||||||
};
|
};
|
||||||
let response = app_terminal.put_adresar(put_request).await?;
|
let _response = app_terminal.put_adresar(put_request).await?;
|
||||||
"Entry updated".to_string()
|
"Entry updated".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ impl EventHandler {
|
|||||||
return Ok((false, message));
|
return Ok((false, message));
|
||||||
} else {
|
} else {
|
||||||
let (should_exit, message) = app_terminal
|
let (should_exit, message) = app_terminal
|
||||||
.handle_command(action, is_saved, &form_data)
|
.handle_command(action, is_saved)
|
||||||
.await?;
|
.await?;
|
||||||
self.command_message = message;
|
self.command_message = message;
|
||||||
self.command_input.clear(); // Clear the command input
|
self.command_input.clear(); // Clear the command input
|
||||||
|
|||||||
Reference in New Issue
Block a user