fix(backends): safeID server name matching + routing priority swap
Backend Detail page: HAProxy stat rows use safeID(name) as server token (spaces/dots → '_') but the UI matched on the raw DB name, so servers with non-alphanumeric names never showed live status. Added matching safeID helper in TypeScript (mirrors haproxy.go implementation). Routing Rules: commit priority up/down swap buttons (developed in a previous session, were left uncommitted). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,13 @@ function fmtBytes(n: number): string {
|
||||
return n + ' B'
|
||||
}
|
||||
|
||||
// Mirror of haproxy.go safeID: replaces any char outside [a-zA-Z0-9_-] with '_'.
|
||||
// HAProxy uses this to generate server tokens; we need it to match stat rows.
|
||||
function safeID(s: string): string {
|
||||
const out = s.replace(/[^a-zA-Z0-9_-]/g, '_')
|
||||
return out || 'unnamed'
|
||||
}
|
||||
|
||||
export default function BackendDetailPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
@@ -316,7 +323,7 @@ function ServerPanel({ backendID, haproxyStats, isViewer }: { backendID: number;
|
||||
title: t('backends.server.live'), key: 'live', width: 160,
|
||||
render: (_, r) => {
|
||||
const stat = haproxyStats.find(
|
||||
s => s.backend === `eg_backend_${backendID}` && s.server === r.name
|
||||
s => s.backend === `eg_backend_${backendID}` && s.server === safeID(r.name)
|
||||
)
|
||||
if (!stat) return <Text type="secondary" style={{ fontSize: 11 }}>—</Text>
|
||||
const color = stat.status === 'UP' ? 'green' : stat.status === 'no check' ? 'default' : 'red'
|
||||
|
||||
Reference in New Issue
Block a user