Hosts list for 480x222 landscape.
(self)
| 582 | # ------------------------------------------------------------------ |
| 583 | |
| 584 | def draw_hosts(self): |
| 585 | """Hosts list for 480x222 landscape.""" |
| 586 | self.pager.clear(self.DARK_BG) |
| 587 | self.refresh_list_data() |
| 588 | |
| 589 | alive = sum(1 for h in self._hosts_data if h['alive']) |
| 590 | self._draw_screen_header(f"HOSTS ({alive} alive)") |
| 591 | |
| 592 | y = 26 |
| 593 | max_y = self.height - 2 |
| 594 | row_h = 24 |
| 595 | visible = (max_y - y) // row_h |
| 596 | |
| 597 | hosts = self._hosts_data |
| 598 | total = len(hosts) |
| 599 | self.scroll_offset = min(self.scroll_offset, max(0, total - visible)) |
| 600 | |
| 601 | if not hosts: |
| 602 | self.pager.draw_ttf_centered(100, "No hosts found yet", self.GRAY, self.font_arial, 16) |
| 603 | else: |
| 604 | # Column headers |
| 605 | self.pager.draw_ttf(8, y, "IP", self.GRAY, self.font_arial, 10) |
| 606 | self.pager.draw_ttf(150, y, "HOSTNAME", self.GRAY, self.font_arial, 10) |
| 607 | self.pager.draw_ttf(310, y, "PORTS", self.GRAY, self.font_arial, 10) |
| 608 | y += 16 |
| 609 | |
| 610 | for i in range(self.scroll_offset, min(self.scroll_offset + visible - 1, total)): |
| 611 | h = hosts[i] |
| 612 | cy = y + (i - self.scroll_offset) * row_h |
| 613 | |
| 614 | # Alternating row bg |
| 615 | if (i - self.scroll_offset) % 2 == 0: |
| 616 | self.pager.fill_rect(2, cy, self.width - 4, row_h - 2, self.CARD_BG) |
| 617 | |
| 618 | # Status dot |
| 619 | dot_color = self.GREEN if h['alive'] else self.RED |
| 620 | self.pager.fill_rect(4, cy + 7, 5, 5, dot_color) |
| 621 | |
| 622 | # IP |
| 623 | self.pager.draw_ttf(12, cy + 3, h['ip'][:18], self.WHITE, self.font_arial, 13) |
| 624 | # Hostname |
| 625 | hn = h['hostname'][:18] if h['hostname'] else "" |
| 626 | self.pager.draw_ttf(150, cy + 3, hn, self.GRAY, self.font_arial, 12) |
| 627 | # Ports |
| 628 | ports = h['ports'][:22] if h['ports'] else "-" |
| 629 | self.pager.draw_ttf(310, cy + 3, ports, self.CYAN, self.font_arial, 11) |
| 630 | |
| 631 | # Scroll indicator |
| 632 | if total > visible: |
| 633 | sb_h = max(8, int((max_y - 42) * visible / total)) |
| 634 | sb_y = 42 + int((max_y - 42 - sb_h) * self.scroll_offset / max(1, total - visible)) |
| 635 | self.pager.fill_rect(self.width - 3, sb_y, 2, sb_h, self.GRAY) |
| 636 | |
| 637 | # ------------------------------------------------------------------ |
| 638 | # Screen 2: Credentials |
no test coverage detected