Compare commits

...

3 Commits

Author SHA1 Message Date
c8f800a1e5 Implement git commit hash tracking for build display
All checks were successful
Build and Release / build-and-release (push) Successful in 1m24s
- Add get_git_commit() method to read /var/lib/cm-dashboard/git-commit
- Replace NixOS build version with actual git commit hash
- Show deployed commit hash as 'Build:' value for accurate tracking
- Enable verification of which exact commit is deployed per host
- Update version to 0.1.42
2025-10-29 15:29:02 +01:00
fc6b3424cf Add hostname to NixOS title and make dashboard title bold
All checks were successful
Build and Release / build-and-release (push) Successful in 2m46s
- Change system panel title from 'NixOS:' to 'NixOS hostname:'
- Make main dashboard title 'cm-dashboard' bold in top bar
- Remove unused Typography::title() function to fix warnings
- Update SystemWidget::render_with_scroll to accept hostname parameter
- Update version to 0.1.41 in all Cargo.toml files and dashboard code
2025-10-29 14:24:17 +01:00
35e06c6734 Implement clean NixOS rebuild tmux popup
All checks were successful
Build and Release / build-and-release (push) Successful in 1m22s
- Replace complex ASCII logo with simple text header
- Remove extra blank lines for compact display
- Left-align text for clean appearance
- Add spacing after target line for readability
- Simplify heredoc format for better maintainability
2025-10-28 23:59:05 +01:00
9 changed files with 40 additions and 38 deletions

6
Cargo.lock generated
View File

@@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]] [[package]]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.38" version = "0.1.40"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -291,7 +291,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.38" version = "0.1.40"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@@ -314,7 +314,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.38" version = "0.1.40"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.39" version = "0.1.42"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@@ -37,6 +37,22 @@ impl NixOSCollector {
} }
/// Get configuration hash from deployed nix store system /// Get configuration hash from deployed nix store system
/// Get git commit hash from rebuild process
fn get_git_commit(&self) -> Result<String, Box<dyn std::error::Error>> {
let commit_file = "/var/lib/cm-dashboard/git-commit";
match std::fs::read_to_string(commit_file) {
Ok(content) => {
let commit_hash = content.trim();
if commit_hash.len() >= 7 {
Ok(commit_hash.to_string())
} else {
Err("Git commit hash too short".into())
}
}
Err(e) => Err(format!("Failed to read git commit file: {}", e).into())
}
}
fn get_config_hash(&self) -> Result<String, Box<dyn std::error::Error>> { fn get_config_hash(&self) -> Result<String, Box<dyn std::error::Error>> {
// Read the symlink target of /run/current-system to get nix store path // Read the symlink target of /run/current-system to get nix store path
let output = Command::new("readlink") let output = Command::new("readlink")
@@ -74,25 +90,25 @@ impl Collector for NixOSCollector {
let mut metrics = Vec::new(); let mut metrics = Vec::new();
let timestamp = chrono::Utc::now().timestamp() as u64; let timestamp = chrono::Utc::now().timestamp() as u64;
// Collect NixOS build information (config hash) // Collect git commit information (shows what's actually deployed)
match self.get_config_hash() { match self.get_git_commit() {
Ok(config_hash) => { Ok(git_commit) => {
metrics.push(Metric { metrics.push(Metric {
name: "system_nixos_build".to_string(), name: "system_nixos_build".to_string(),
value: MetricValue::String(config_hash), value: MetricValue::String(git_commit),
unit: None, unit: None,
description: Some("NixOS deployed configuration hash".to_string()), description: Some("Git commit hash of deployed configuration".to_string()),
status: Status::Ok, status: Status::Ok,
timestamp, timestamp,
}); });
} }
Err(e) => { Err(e) => {
debug!("Failed to get config hash: {}", e); debug!("Failed to get git commit: {}", e);
metrics.push(Metric { metrics.push(Metric {
name: "system_nixos_build".to_string(), name: "system_nixos_build".to_string(),
value: MetricValue::String("unknown".to_string()), value: MetricValue::String("unknown".to_string()),
unit: None, unit: None,
description: Some("NixOS config hash (failed to detect)".to_string()), description: Some("Git commit hash (failed to detect)".to_string()),
status: Status::Unknown, status: Status::Unknown,
timestamp, timestamp,
}); });

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.39" version = "0.1.42"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@@ -14,7 +14,7 @@ use app::Dashboard;
/// Get hardcoded version /// Get hardcoded version
fn get_version() -> &'static str { fn get_version() -> &'static str {
"v0.1.33" "v0.1.42"
} }
/// Check if running inside tmux session /// Check if running inside tmux session

View File

@@ -246,20 +246,12 @@ impl TuiApp {
if let Some(hostname) = self.current_host.clone() { if let Some(hostname) = self.current_host.clone() {
// Create command that shows CM Dashboard logo and then rebuilds // Create command that shows CM Dashboard logo and then rebuilds
let logo_and_rebuild = format!( let logo_and_rebuild = format!(
"echo ''; \ r"cat << 'EOF'
echo -e '\\033[1;32m _____ __ __ _____ _ _ _ \\033[0m'; \ NixOS System Rebuild
echo -e '\\033[1;32m / ____| \\/ | | __ \\ | | | | | |\\033[0m'; \ Target: {}
echo -e '\\033[1;32m| | | \\ / | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| |\\033[0m'; \
echo -e '\\033[1;32m| | | |\\/| | | | | |/ _` / __| \\'_ \\| \\'_ \\ / _ \\ / _` | \\'__/ _` |\\033[0m'; \ EOF
echo -e '\\033[1;32m| |____| | | | | |__| | (_| \\__ \\ | | | |_) | (_) | (_| | | | (_| |\\033[0m'; \ ssh -tt {}@{} 'bash -ic {}'",
echo -e '\\033[1;32m \\_____|_| |_| |_____/ \\__,_|___/_| |_|_.__/ \\___/ \\__,_|_| \\__,_|\\033[0m'; \
echo ''; \
echo -e '\\033[1;33m NixOS System Rebuild\\033[0m'; \
echo -e '\\033[1;32m Target: {}\\033[0m'; \
echo ''; \
echo -e '\\033[1;90m────────────────────────────────────────────────────────────────────────────────\\033[0m'; \
echo ''; \
ssh -tt {}@{} 'bash -ic {}'",
hostname, hostname,
self.config.ssh.rebuild_user, self.config.ssh.rebuild_user,
hostname, hostname,
@@ -576,7 +568,7 @@ impl TuiApp {
// Left side: "cm-dashboard" text // Left side: "cm-dashboard" text
let left_span = Span::styled( let left_span = Span::styled(
" cm-dashboard", " cm-dashboard",
Style::default().fg(Theme::background()).bg(background_color) Style::default().fg(Theme::background()).bg(background_color).add_modifier(Modifier::BOLD)
); );
let left_title = Paragraph::new(Line::from(vec![left_span])) let left_title = Paragraph::new(Line::from(vec![left_span]))
.style(Style::default().bg(background_color)); .style(Style::default().bg(background_color));
@@ -716,7 +708,7 @@ impl TuiApp {
host_widgets.system_scroll_offset host_widgets.system_scroll_offset
}; };
let host_widgets = self.get_or_create_host_widgets(&hostname); let host_widgets = self.get_or_create_host_widgets(&hostname);
host_widgets.system_widget.render_with_scroll(frame, inner_area, scroll_offset); host_widgets.system_widget.render_with_scroll(frame, inner_area, scroll_offset, &hostname);
} }
} }

View File

@@ -292,12 +292,6 @@ impl Components {
} }
impl Typography { impl Typography {
/// Main title style (dashboard header)
pub fn title() -> Style {
Style::default()
.fg(Theme::primary_text())
.bg(Theme::background())
}
/// Widget title style (panel headers) - bold bright white /// Widget title style (panel headers) - bold bright white
pub fn widget_title() -> Style { pub fn widget_title() -> Style {

View File

@@ -439,12 +439,12 @@ impl Widget for SystemWidget {
impl SystemWidget { impl SystemWidget {
/// Render with scroll offset support /// Render with scroll offset support
pub fn render_with_scroll(&mut self, frame: &mut Frame, area: Rect, scroll_offset: usize) { pub fn render_with_scroll(&mut self, frame: &mut Frame, area: Rect, scroll_offset: usize, hostname: &str) {
let mut lines = Vec::new(); let mut lines = Vec::new();
// NixOS section // NixOS section
lines.push(Line::from(vec![ lines.push(Line::from(vec![
Span::styled("NixOS:", Typography::widget_title()) Span::styled(format!("NixOS {}:", hostname), Typography::widget_title())
])); ]));
let build_text = self.nixos_build.as_deref().unwrap_or("unknown"); let build_text = self.nixos_build.as_deref().unwrap_or("unknown");

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.39" version = "0.1.42"
edition = "2021" edition = "2021"
[dependencies] [dependencies]