Replace tmux popups with split windows for better log navigation
Some checks failed
Build and Release / build-and-release (push) Failing after 1m9s
Some checks failed
Build and Release / build-and-release (push) Failing after 1m9s
- Change J/L log commands from popups to split windows for scrolling support - Change rebuild command from popup to split window with consistent 30% height - Add auto-close behavior with bash -c "command; exit" wrapper for logs - Add "press any key to close" prompt with visual separators for rebuild - Enable proper tmux copy mode and navigation in all split windows Users can now scroll through logs, copy text, and resize windows while maintaining clean auto-close behavior for all operations.
This commit is contained in:
parent
6fedf4c7fc
commit
e4469a0ebf
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.50"
|
||||
version = "0.1.51"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -291,7 +291,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.50"
|
||||
version = "0.1.51"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -314,7 +314,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.50"
|
||||
version = "0.1.51"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.51"
|
||||
version = "0.1.52"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.51"
|
||||
version = "0.1.52"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -244,14 +244,20 @@ impl TuiApp {
|
||||
KeyCode::Char('r') => {
|
||||
// System rebuild command - works on any panel for current host
|
||||
if let Some(hostname) = self.current_host.clone() {
|
||||
// Create command that shows CM Dashboard logo and then rebuilds
|
||||
// Create command that shows logo, rebuilds, and waits for user input
|
||||
let logo_and_rebuild = format!(
|
||||
r"cat << 'EOF'
|
||||
r"bash -c 'cat << \"EOF\"
|
||||
NixOS System Rebuild
|
||||
Target: {}
|
||||
|
||||
EOF
|
||||
ssh -tt {}@{} 'bash -ic {}'",
|
||||
ssh -tt {}@{} \"bash -ic {}\"
|
||||
echo
|
||||
echo \"========================================\"
|
||||
echo \"Rebuild completed. Press any key to close...\"
|
||||
echo \"========================================\"
|
||||
read -n 1 -s
|
||||
exit'",
|
||||
hostname,
|
||||
self.config.ssh.rebuild_user,
|
||||
hostname,
|
||||
@ -259,11 +265,10 @@ ssh -tt {}@{} 'bash -ic {}'",
|
||||
);
|
||||
|
||||
std::process::Command::new("tmux")
|
||||
.arg("display-popup")
|
||||
.arg("-w")
|
||||
.arg("80%")
|
||||
.arg("-h")
|
||||
.arg("80%")
|
||||
.arg("split-window")
|
||||
.arg("-v")
|
||||
.arg("-p")
|
||||
.arg("30")
|
||||
.arg(&logo_and_rebuild)
|
||||
.spawn()
|
||||
.ok(); // Ignore errors, tmux will handle them
|
||||
@ -286,49 +291,43 @@ ssh -tt {}@{} 'bash -ic {}'",
|
||||
}
|
||||
}
|
||||
KeyCode::Char('J') => {
|
||||
// Show service logs via journalctl in tmux popup
|
||||
// Show service logs via journalctl in tmux split window
|
||||
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
||||
let journalctl_command = format!(
|
||||
"ssh -tt {}@{} 'sudo journalctl -u {}.service -f --no-pager -n 50'",
|
||||
"bash -c \"ssh -tt {}@{} 'sudo journalctl -u {}.service -f --no-pager -n 50'; exit\"",
|
||||
self.config.ssh.rebuild_user,
|
||||
hostname,
|
||||
service_name
|
||||
);
|
||||
|
||||
std::process::Command::new("tmux")
|
||||
.arg("display-popup")
|
||||
.arg("-w")
|
||||
.arg("80%")
|
||||
.arg("-h")
|
||||
.arg("80%")
|
||||
.arg("-T")
|
||||
.arg(format!("Logs: {}", service_name))
|
||||
.arg("split-window")
|
||||
.arg("-v")
|
||||
.arg("-p")
|
||||
.arg("30")
|
||||
.arg(&journalctl_command)
|
||||
.spawn()
|
||||
.ok(); // Ignore errors, tmux will handle them
|
||||
}
|
||||
}
|
||||
KeyCode::Char('L') => {
|
||||
// Show custom service log file in tmux popup
|
||||
// Show custom service log file in tmux split window
|
||||
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
|
||||
// Check if this service has a custom log file configured
|
||||
if let Some(host_logs) = self.config.service_logs.get(&hostname) {
|
||||
if let Some(log_config) = host_logs.iter().find(|config| config.service_name == service_name) {
|
||||
let tail_command = format!(
|
||||
"ssh -tt {}@{} 'sudo tail -n 50 -f {}'",
|
||||
"bash -c \"ssh -tt {}@{} 'sudo tail -n 50 -f {}'; exit\"",
|
||||
self.config.ssh.rebuild_user,
|
||||
hostname,
|
||||
log_config.log_file_path
|
||||
);
|
||||
|
||||
std::process::Command::new("tmux")
|
||||
.arg("display-popup")
|
||||
.arg("-w")
|
||||
.arg("80%")
|
||||
.arg("-h")
|
||||
.arg("80%")
|
||||
.arg("-T")
|
||||
.arg(format!("Custom Log: {}", service_name))
|
||||
.arg("split-window")
|
||||
.arg("-v")
|
||||
.arg("-p")
|
||||
.arg("30")
|
||||
.arg(&tail_command)
|
||||
.spawn()
|
||||
.ok(); // Ignore errors, tmux will handle them
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.51"
|
||||
version = "0.1.52"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user