Files
NODEDC_MISSION_CORE/packages/router-ui/src/RouterAccess.tsx
T
DCCONSTRUCTIONS a49fb00b8e feat(routers): integrate Banana Pi Client API and onboard LibreSpeed measurements
Discover Ethernet routers under the board, map physical SIM slots, expose vendor controls and real telemetry, and provide packaged VPS speed tests with a live monochrome gauge. Enforce compact typography across Core and Node UI.
2026-11-11 23:53:46 +03:00

19 lines
1.9 KiB
TypeScript

import {useState} from 'react';
import {Button,Description,SettingsCard,StatusBadge,TextAreaField,TextField} from '@nodedc/ui-react';
import type {RouterDevice,RouterSnapshot,RouterTransport} from './contracts';
import {useRouterRequest} from './useRouterRequest';
export function RouterAccess({device,value,transport,fresh}:{device:RouterDevice;value:RouterSnapshot;transport:RouterTransport;fresh:boolean}){
const [token,setToken]=useState(''),[ca,setCA]=useState('');const request=useRouterRequest(value,transport);
const busy=request.busy||value.results.some(r=>r.state==='queued'||r.state==='applying');
function authorize(){const key=token,certificate=ca;setToken('');setCA('');void request.send({device_id:device.id,model_id:'',client_api:{token:key,ca:certificate}});}
return <SettingsCard title="Client API" description={device.client_api?`Подключён · модуль ${device.client_api.module_version}`:'Подключите Client API, если он установлен в прошивке этого роутера.'}>
<div className="router-form">
<Description>Ключ из config.json и сертификат ca.pem выдаются для конкретного роутера. Они сохраняются на борту отдельно от пароля админки.</Description>
<TextField label="Ключ Client API" type="password" value={token} maxLength={4096} disabled={busy} autoComplete="new-password" onChange={e=>setToken(e.target.value)}/>
<TextAreaField label="Сертификат CA (PEM)" value={ca} rows={6} maxLength={8192} disabled={busy} autoComplete="off" spellCheck={false} onChange={e=>setCA(e.target.value)}/>
<Button loading={request.busy} disabled={!fresh||busy||!token||!ca} onClick={authorize}>Подключить Client API</Button>
{request.message&&<StatusBadge tone="neutral">{request.message}</StatusBadge>}
</div>
</SettingsCard>;
}