Testing
This commit is contained in:
parent
859df2dec1
commit
d76302e1c4
@ -818,15 +818,9 @@ impl Collector for ServiceCollector {
|
|||||||
|
|
||||||
// Add nginx sites as individual sub-services
|
// Add nginx sites as individual sub-services
|
||||||
if let Some(sites) = self.get_nginx_sites().await {
|
if let Some(sites) = self.get_nginx_sites().await {
|
||||||
for (i, site) in sites.iter().enumerate() {
|
for site in sites.iter() {
|
||||||
let site_name = if i == sites.len() - 1 {
|
|
||||||
format!("└─ {}", site)
|
|
||||||
} else {
|
|
||||||
format!("├─ {}", site)
|
|
||||||
};
|
|
||||||
|
|
||||||
services.push(ServiceData {
|
services.push(ServiceData {
|
||||||
name: site_name,
|
name: site.clone(),
|
||||||
status: ServiceStatus::Running, // Assume sites are running if nginx is running
|
status: ServiceStatus::Running, // Assume sites are running if nginx is running
|
||||||
memory_used_mb: 0.0,
|
memory_used_mb: 0.0,
|
||||||
memory_quota_mb: 0.0,
|
memory_quota_mb: 0.0,
|
||||||
|
|||||||
@ -106,7 +106,7 @@ fn render_metrics(
|
|||||||
|
|
||||||
if svc.sub_service.is_some() {
|
if svc.sub_service.is_some() {
|
||||||
// Sub-services only show name and status, no memory/CPU/disk data
|
// Sub-services only show name and status, no memory/CPU/disk data
|
||||||
data.add_row(
|
data.add_row_with_sub_service(
|
||||||
Some(WidgetStatus::new(status_level)),
|
Some(WidgetStatus::new(status_level)),
|
||||||
description,
|
description,
|
||||||
vec![
|
vec![
|
||||||
@ -115,6 +115,7 @@ fn render_metrics(
|
|||||||
"".to_string(),
|
"".to_string(),
|
||||||
"".to_string(),
|
"".to_string(),
|
||||||
],
|
],
|
||||||
|
svc.sub_service.clone(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Regular services show all columns
|
// Regular services show all columns
|
||||||
|
|||||||
@ -77,6 +77,22 @@ pub fn render_placeholder(frame: &mut Frame, area: Rect, title: &str, message: &
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_last_sub_service_in_group(rows: &[WidgetRow], current_idx: usize, parent_service: &Option<String>) -> bool {
|
||||||
|
if let Some(parent) = parent_service {
|
||||||
|
// Look ahead to see if there are any more sub-services for this parent
|
||||||
|
for i in (current_idx + 1)..rows.len() {
|
||||||
|
if let Some(ref other_parent) = rows[i].sub_service {
|
||||||
|
if other_parent == parent {
|
||||||
|
return false; // Found another sub-service for same parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true // No more sub-services found for this parent
|
||||||
|
} else {
|
||||||
|
false // Not a sub-service
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render_widget_data(frame: &mut Frame, area: Rect, data: WidgetData) {
|
pub fn render_widget_data(frame: &mut Frame, area: Rect, data: WidgetData) {
|
||||||
render_combined_widget_data(frame, area, data.title, data.status, vec![data.dataset]);
|
render_combined_widget_data(frame, area, data.title, data.status, vec![data.dataset]);
|
||||||
}
|
}
|
||||||
@ -265,7 +281,7 @@ fn render_dataset_with_wrapping(frame: &mut Frame, dataset: &WidgetDataSet, inne
|
|||||||
current_y += 1;
|
current_y += 1;
|
||||||
|
|
||||||
// Render data rows for this section
|
// Render data rows for this section
|
||||||
for row in &dataset.rows {
|
for (row_idx, row) in dataset.rows.iter().enumerate() {
|
||||||
if current_y >= inner.y + inner.height {
|
if current_y >= inner.y + inner.height {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -295,8 +311,18 @@ fn render_dataset_with_wrapping(frame: &mut Frame, dataset: &WidgetDataSet, inne
|
|||||||
if content.is_empty() {
|
if content.is_empty() {
|
||||||
cells.push(Cell::from(""));
|
cells.push(Cell::from(""));
|
||||||
} else {
|
} else {
|
||||||
|
// Check if this is the first column (service name) and if it's a sub-service
|
||||||
|
let display_content = if col_idx == 0 && row.sub_service.is_some() {
|
||||||
|
// Determine if this is the last sub-service for this parent
|
||||||
|
let is_last_sub_service = is_last_sub_service_in_group(&dataset.rows, row_idx, &row.sub_service);
|
||||||
|
let tree_char = if is_last_sub_service { "└─" } else { "├─" };
|
||||||
|
format!("{} {}", tree_char, content)
|
||||||
|
} else {
|
||||||
|
content.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
cells.push(Cell::from(Line::from(vec![Span::styled(
|
cells.push(Cell::from(Line::from(vec![Span::styled(
|
||||||
content.to_string(),
|
display_content,
|
||||||
neutral_text_style(),
|
neutral_text_style(),
|
||||||
)])));
|
)])));
|
||||||
}
|
}
|
||||||
@ -375,6 +401,7 @@ pub struct WidgetRow {
|
|||||||
pub status: Option<WidgetStatus>,
|
pub status: Option<WidgetStatus>,
|
||||||
pub values: Vec<String>,
|
pub values: Vec<String>,
|
||||||
pub description: Vec<String>,
|
pub description: Vec<String>,
|
||||||
|
pub sub_service: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
@ -404,10 +431,15 @@ impl WidgetData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_row(&mut self, status: Option<WidgetStatus>, description: Vec<String>, values: Vec<String>) -> &mut Self {
|
pub fn add_row(&mut self, status: Option<WidgetStatus>, description: Vec<String>, values: Vec<String>) -> &mut Self {
|
||||||
|
self.add_row_with_sub_service(status, description, values, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_row_with_sub_service(&mut self, status: Option<WidgetStatus>, description: Vec<String>, values: Vec<String>, sub_service: Option<String>) -> &mut Self {
|
||||||
self.dataset.rows.push(WidgetRow {
|
self.dataset.rows.push(WidgetRow {
|
||||||
status,
|
status,
|
||||||
values,
|
values,
|
||||||
description,
|
description,
|
||||||
|
sub_service,
|
||||||
});
|
});
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -423,10 +455,15 @@ impl WidgetDataSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_row(&mut self, status: Option<WidgetStatus>, description: Vec<String>, values: Vec<String>) -> &mut Self {
|
pub fn add_row(&mut self, status: Option<WidgetStatus>, description: Vec<String>, values: Vec<String>) -> &mut Self {
|
||||||
|
self.add_row_with_sub_service(status, description, values, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_row_with_sub_service(&mut self, status: Option<WidgetStatus>, description: Vec<String>, values: Vec<String>, sub_service: Option<String>) -> &mut Self {
|
||||||
self.rows.push(WidgetRow {
|
self.rows.push(WidgetRow {
|
||||||
status,
|
status,
|
||||||
values,
|
values,
|
||||||
description,
|
description,
|
||||||
|
sub_service,
|
||||||
});
|
});
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user