MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / renderDashboard

Method renderDashboard

internal/tui/dashboard.go:120–231  ·  view source on GitHub ↗
(cfg map[string]any, authFiles []map[string]any, apiKeys []string)

Source from the content-addressed store, hash-verified

118}
119
120func (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")

Callers 1

UpdateMethod · 0.95

Calls 8

TFunction · 0.85
getBoolFunction · 0.85
minIntFunction · 0.85
getFloatFunction · 0.85
getStringFunction · 0.85
boolEmojiFunction · 0.85
WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected