diff --git a/src/components/panels/multi-gateway-panel.tsx b/src/components/panels/multi-gateway-panel.tsx index 9f4c191..07e4aef 100644 --- a/src/components/panels/multi-gateway-panel.tsx +++ b/src/components/panels/multi-gateway-panel.tsx @@ -160,6 +160,15 @@ export function MultiGatewayPanel() { fetchHistory() } + const updateToken = async (gw: Gateway, token: string) => { + await fetch('/api/gateways', { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ id: gw.id, token }), + }) + fetchGateways() + } + const connectTo = async (gw: Gateway) => { try { const res = await fetch('/api/gateways/connect', { @@ -285,6 +294,7 @@ export function MultiGatewayPanel() { onDelete={() => deleteGateway(gw.id)} onConnect={() => connectTo(gw)} onProbe={() => probeGateway(gw)} + onUpdateToken={(token) => updateToken(gw, token)} /> ))} @@ -437,7 +447,7 @@ export function MultiGatewayPanel() { ) } -function GatewayCard({ gateway, health, historyEntries = [], isProbing, isCurrentlyConnected, onSetPrimary, onDelete, onConnect, onProbe }: { +function GatewayCard({ gateway, health, historyEntries = [], isProbing, isCurrentlyConnected, onSetPrimary, onDelete, onConnect, onProbe, onUpdateToken }: { gateway: Gateway health?: GatewayHealthProbe historyEntries?: GatewayHealthLogEntry[] @@ -447,8 +457,11 @@ function GatewayCard({ gateway, health, historyEntries = [], isProbing, isCurren onDelete: () => void onConnect: () => void onProbe: () => void + onUpdateToken: (token: string) => void }) { const t = useTranslations('multiGateway') + const [editingToken, setEditingToken] = useState(false) + const [tokenInput, setTokenInput] = useState('') const statusColors: Record = { online: 'bg-green-500', offline: 'bg-red-500', @@ -487,10 +500,54 @@ function GatewayCard({ gateway, health, historyEntries = [], isProbing, isCurren
{gateway.host}:{gateway.port} - {t('token')}: {gateway.token_set ? t('tokenSet') : t('tokenNone')} + {gateway.latency != null && {t('latency')}: {gateway.latency}ms} {t('last')}: {lastSeen}
+ {editingToken && ( +
+ setTokenInput(e.target.value)} + placeholder="Paste gateway token..." + className="flex-1 px-2 py-1 text-xs bg-secondary border border-border rounded font-mono" + autoFocus + onKeyDown={e => { + if (e.key === 'Enter' && tokenInput.trim()) { + onUpdateToken(tokenInput.trim()) + setEditingToken(false) + setTokenInput('') + } else if (e.key === 'Escape') { + setEditingToken(false) + setTokenInput('') + } + }} + /> + + +
+ )} {health?.gateway_version && (
{t('gatewayVersion')}: {health.gateway_version}