Align dashboard health bars
This commit is contained in:
@@ -528,17 +528,18 @@ class ReactorDashboard:
|
|||||||
return height - 2
|
return height - 2
|
||||||
win.addstr(start_y, 2, "Component Health", curses.A_BOLD | curses.color_pair(1))
|
win.addstr(start_y, 2, "Component Health", curses.A_BOLD | curses.color_pair(1))
|
||||||
bar_width = max(8, min(inner_width - 18, 40))
|
bar_width = max(8, min(inner_width - 18, 40))
|
||||||
|
label_width = 16
|
||||||
row = start_y + 1
|
row = start_y + 1
|
||||||
for name, comp in self.reactor.health_monitor.components.items():
|
for name, comp in self.reactor.health_monitor.components.items():
|
||||||
if row >= height - 1:
|
if row >= height - 1:
|
||||||
break
|
break
|
||||||
label = f"{name:<12}"
|
label = f"{name:<{label_width}}"
|
||||||
target = 0.0 if comp.failed else comp.integrity
|
target = 0.0 if comp.failed else comp.integrity
|
||||||
filled = int(bar_width * max(0.0, min(1.0, target)))
|
filled = int(bar_width * max(0.0, min(1.0, target)))
|
||||||
bar = "#" * filled + "-" * (bar_width - filled)
|
bar = "#" * filled + "-" * (bar_width - filled)
|
||||||
color = 3 if comp.integrity > 0.5 else 2 if comp.integrity > 0.2 else 4
|
color = 3 if comp.integrity > 0.5 else 2 if comp.integrity > 0.2 else 4
|
||||||
win.addstr(row, 4, f"{label}:")
|
win.addstr(row, 4, f"{label}:")
|
||||||
bar_start = 4 + len(label) + 1
|
bar_start = 4 + label_width + 1
|
||||||
win.addstr(row, bar_start, bar[:bar_width], curses.color_pair(color))
|
win.addstr(row, bar_start, bar[:bar_width], curses.color_pair(color))
|
||||||
percent_text = "FAILED" if comp.failed else f"{comp.integrity*100:5.1f}%"
|
percent_text = "FAILED" if comp.failed else f"{comp.integrity*100:5.1f}%"
|
||||||
percent_x = min(width - len(percent_text) - 2, bar_start + bar_width + 2)
|
percent_x = min(width - len(percent_text) - 2, bar_start + bar_width + 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user