fix: collapse ping section by default, expand on click
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -632,6 +632,7 @@ function WorkstationCard({
|
|||||||
const [updateMsg, setUpdateMsg] = useState<string | null>(null)
|
const [updateMsg, setUpdateMsg] = useState<string | null>(null)
|
||||||
const [testResults, setTestResults] = useState<Record<string, { ok: boolean; msg: string } | null>>({})
|
const [testResults, setTestResults] = useState<Record<string, { ok: boolean; msg: string } | null>>({})
|
||||||
const [testingDeviceId, setTestingDeviceId] = useState<string | null>(null)
|
const [testingDeviceId, setTestingDeviceId] = useState<string | null>(null)
|
||||||
|
const [showPing, setShowPing] = useState(false)
|
||||||
const [pingHost, setPingHost] = useState('')
|
const [pingHost, setPingHost] = useState('')
|
||||||
const [pinging, setPinging] = useState(false)
|
const [pinging, setPinging] = useState(false)
|
||||||
const [pingResult, setPingResult] = useState<{ ok: boolean; output?: string; error?: string } | null>(null)
|
const [pingResult, setPingResult] = useState<{ ok: boolean; output?: string; error?: string } | null>(null)
|
||||||
@@ -959,35 +960,47 @@ function WorkstationCard({
|
|||||||
{/* Ping tool — only when agent is online */}
|
{/* Ping tool — only when agent is online */}
|
||||||
{ws.isOnline && (
|
{ws.isOnline && (
|
||||||
<div className="pt-2 border-t border-slate-100 dark:border-slate-700">
|
<div className="pt-2 border-t border-slate-100 dark:border-slate-700">
|
||||||
<p className="text-xs text-slate-400 dark:text-slate-500 mb-2">Пинг через агента</p>
|
<button
|
||||||
<div className="flex gap-2">
|
onClick={() => { setShowPing(v => !v); setPingResult(null) }}
|
||||||
<input
|
className="flex items-center gap-1.5 text-xs text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 transition-colors"
|
||||||
value={pingHost}
|
>
|
||||||
onChange={e => setPingHost(e.target.value)}
|
<Network size={12} />
|
||||||
onKeyDown={e => e.key === 'Enter' && pingNow()}
|
Пинг через агента
|
||||||
placeholder="192.168.1.1 или hostname"
|
{showPing ? <ChevronDown size={11} /> : <ChevronRight size={11} />}
|
||||||
className="input text-sm font-mono flex-1 py-1.5"
|
</button>
|
||||||
/>
|
{showPing && (
|
||||||
<button
|
<div className="mt-2">
|
||||||
onClick={pingNow}
|
<div className="flex gap-2">
|
||||||
disabled={pinging || !pingHost.trim()}
|
<input
|
||||||
className="btn-secondary py-1.5 px-3 text-sm flex items-center gap-1.5 shrink-0 h-9 whitespace-nowrap"
|
value={pingHost}
|
||||||
>
|
onChange={e => setPingHost(e.target.value)}
|
||||||
{pinging ? <RefreshCw size={13} className="animate-spin" /> : <Network size={13} />}
|
onKeyDown={e => e.key === 'Enter' && pingNow()}
|
||||||
{pinging ? 'Пинг...' : 'Пинг'}
|
placeholder="192.168.1.1 или hostname"
|
||||||
</button>
|
className="input text-sm font-mono flex-1 py-1.5"
|
||||||
</div>
|
autoFocus
|
||||||
{pingResult && (
|
/>
|
||||||
<div className={cn(
|
<button
|
||||||
'mt-2 rounded-lg text-xs',
|
onClick={pingNow}
|
||||||
pingResult.ok
|
disabled={pinging || !pingHost.trim()}
|
||||||
? 'bg-emerald-50 dark:bg-emerald-900/20 text-emerald-700 dark:text-emerald-400'
|
className="btn-secondary py-1.5 px-3 text-sm flex items-center gap-1.5 shrink-0 h-9 whitespace-nowrap"
|
||||||
: 'bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400',
|
>
|
||||||
)}>
|
{pinging ? <RefreshCw size={13} className="animate-spin" /> : <Network size={13} />}
|
||||||
{pingResult.ok && pingResult.output ? (
|
{pinging ? 'Пинг...' : 'Пинг'}
|
||||||
<pre className="p-3 whitespace-pre-wrap font-mono text-xs overflow-x-auto">{pingResult.output.trim()}</pre>
|
</button>
|
||||||
) : (
|
</div>
|
||||||
<p className="p-3 flex items-center gap-1.5"><X size={11} />{pingResult.error ?? 'Ошибка'}</p>
|
{pingResult && (
|
||||||
|
<div className={cn(
|
||||||
|
'mt-2 rounded-lg text-xs',
|
||||||
|
pingResult.ok
|
||||||
|
? 'bg-emerald-50 dark:bg-emerald-900/20 text-emerald-700 dark:text-emerald-400'
|
||||||
|
: 'bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400',
|
||||||
|
)}>
|
||||||
|
{pingResult.ok && pingResult.output ? (
|
||||||
|
<pre className="p-3 whitespace-pre-wrap font-mono text-xs overflow-x-auto">{pingResult.output.trim()}</pre>
|
||||||
|
) : (
|
||||||
|
<p className="p-3 flex items-center gap-1.5"><X size={11} />{pingResult.error ?? 'Ошибка'}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user