| 118 | } |
| 119 | |
| 120 | func (m dashboardModel) renderDashboard(cfg map[string]any, authFiles []map[string]any, apiKeys []string) string { |
| 121 | var sb strings.Builder |
| 122 | |
| 123 | sb.WriteString(titleStyle.Render(T("dashboard_title"))) |
| 124 | sb.WriteString("\n") |
| 125 | sb.WriteString(helpStyle.Render(T("dashboard_help"))) |
| 126 | sb.WriteString("\n\n") |
| 127 | |
| 128 | // ━━━ Connection Status ━━━ |
| 129 | connStyle := lipgloss.NewStyle().Bold(true).Foreground(colorSuccess) |
| 130 | sb.WriteString(connStyle.Render(T("connected"))) |
| 131 | sb.WriteString(fmt.Sprintf(" %s", m.client.baseURL)) |
| 132 | sb.WriteString("\n\n") |
| 133 | |
| 134 | // ━━━ Stats Cards ━━━ |
| 135 | cardWidth := 25 |
| 136 | if m.width > 0 { |
| 137 | cardWidth = (m.width - 2) / 2 |
| 138 | if cardWidth < 18 { |
| 139 | cardWidth = 18 |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | cardStyle := lipgloss.NewStyle(). |
| 144 | Border(lipgloss.RoundedBorder()). |
| 145 | BorderForeground(lipgloss.Color("240")). |
| 146 | Padding(0, 1). |
| 147 | Width(cardWidth). |
| 148 | Height(2) |
| 149 | |
| 150 | // Card 1: API Keys |
| 151 | keyCount := len(apiKeys) |
| 152 | card1 := cardStyle.Render(fmt.Sprintf( |
| 153 | "%s\n%s", |
| 154 | lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("111")).Render(fmt.Sprintf("🔑 %d", keyCount)), |
| 155 | lipgloss.NewStyle().Foreground(colorMuted).Render(T("mgmt_keys")), |
| 156 | )) |
| 157 | |
| 158 | // Card 2: Auth Files |
| 159 | authCount := len(authFiles) |
| 160 | activeAuth := 0 |
| 161 | for _, f := range authFiles { |
| 162 | if !getBool(f, "disabled") { |
| 163 | activeAuth++ |
| 164 | } |
| 165 | } |
| 166 | card2 := cardStyle.Render(fmt.Sprintf( |
| 167 | "%s\n%s", |
| 168 | lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("76")).Render(fmt.Sprintf("📄 %d", authCount)), |
| 169 | lipgloss.NewStyle().Foreground(colorMuted).Render(fmt.Sprintf("%s (%d %s)", T("auth_files_label"), activeAuth, T("active_suffix"))), |
| 170 | )) |
| 171 | |
| 172 | sb.WriteString(lipgloss.JoinHorizontal(lipgloss.Top, card1, " ", card2)) |
| 173 | sb.WriteString("\n\n") |
| 174 | |
| 175 | // ━━━ Current Config ━━━ |
| 176 | sb.WriteString(lipgloss.NewStyle().Bold(true).Foreground(colorHighlight).Render(T("current_config"))) |
| 177 | sb.WriteString("\n") |