'use client'; import { useState } from 'react'; import { fmtInt } from '@/lib/format'; import type { AdminRaw } from '@/lib/types'; import { AdminPage, ErrorNote, Field, inputCls, useAdmin } from './shared'; const TABLES = ['measurements', 'traceroutes', 'bgp_events', 'bgp_stats', 'pressure_history', 'signal_features', 'probe_health']; export function Raw() { const [table, setTable] = useState('measurements'); const [probe, setProbe] = useState(''); const [target, setTarget] = useState(''); const [limit, setLimit] = useState(100); const { data, err, loading } = useAdmin('/raw', { table, probe_id: probe || undefined, target_id: target || undefined, limit }); return (
setProbe(e.target.value)} className={`${inputCls} num w-full`} /> setTarget(e.target.value)} className={`${inputCls} num w-full`} /> setLimit(Math.min(200, Math.max(1, Number(e.target.value) || 1)))} className={`${inputCls} num w-full`} />
{loading ? 'loading…' : data ? `${fmtInt(data.rows.length)} rows` : ''}
{data && (
{data.columns.map((c) => ( ))} {data.rows.map((r, i) => ( {r.map((v, j) => ( ))} ))}
{c}
{v === null || v === undefined ? ∅ : typeof v === 'boolean' ? (v ? 'true' : 'false') : String(v)}
)}
); }