Restore component health progress bars
This commit is contained in:
@@ -353,7 +353,7 @@ class ReactorDashboard:
|
||||
],
|
||||
)
|
||||
y = self._draw_section(win, y, "Maintenance", self._maintenance_lines())
|
||||
y = self._draw_section(win, y, "Component Health", self._health_lines())
|
||||
y = self._draw_health_bars(win, y)
|
||||
|
||||
def _draw_help_panel(self, win: "curses._CursesWindow") -> None:
|
||||
win.erase()
|
||||
@@ -471,6 +471,31 @@ class ReactorDashboard:
|
||||
return [("Active", "None")]
|
||||
return [(comp, "IN PROGRESS") for comp in sorted(self.reactor.maintenance_active)]
|
||||
|
||||
def _draw_health_bars(self, win: "curses._CursesWindow", start_y: int) -> int:
|
||||
height, width = win.getmaxyx()
|
||||
inner_width = width - 4
|
||||
if start_y >= height - 2:
|
||||
return height - 2
|
||||
win.addstr(start_y, 2, "Component Health", curses.A_BOLD | curses.color_pair(1))
|
||||
bar_width = max(8, min(inner_width - 18, 40))
|
||||
row = start_y + 1
|
||||
for name, comp in self.reactor.health_monitor.components.items():
|
||||
if row >= height - 1:
|
||||
break
|
||||
label = f"{name:<12}"
|
||||
target = 0.0 if comp.failed else comp.integrity
|
||||
filled = int(bar_width * max(0.0, min(1.0, target)))
|
||||
bar = "#" * filled + "-" * (bar_width - filled)
|
||||
color = 3 if comp.integrity > 0.5 else 2 if comp.integrity > 0.2 else 4
|
||||
win.addstr(row, 4, f"{label}:")
|
||||
bar_start = 4 + len(label) + 1
|
||||
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_x = min(width - len(percent_text) - 2, bar_start + bar_width + 2)
|
||||
win.addstr(row, percent_x, percent_text, curses.color_pair(color))
|
||||
row += 1
|
||||
return row + 1
|
||||
|
||||
def _pump_status(self, pumps: list, index: int) -> str:
|
||||
if index >= len(pumps):
|
||||
return "n/a"
|
||||
|
||||
Reference in New Issue
Block a user