Add Params declaration UI (ticket 034)
New Params panel (Log viewer / Params / Metrics / Dashboards) declares a bare param via POST /api/params, mirroring Metrics' declare-then-list pattern including inline 400 error surfacing. Lifted the params list from LogPreview's own effect into App.tsx so declaring a param there updates the Columns picker immediately, without a page reload. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
41c9a3660b
commit
dd1a0a234d
+26
-2
@@ -3,10 +3,20 @@ import { NavMenu } from './components/NavMenu'
|
||||
import { FilterBar } from './components/FilterBar'
|
||||
import { LogTimeline, computePresetRange, type TimeRange, type TimeRangePresetId } from './components/LogTimeline'
|
||||
import { LogPreview } from './components/LogPreview'
|
||||
import { Params } from './components/Params'
|
||||
import { Metrics } from './components/Metrics'
|
||||
import { Dashboards } from './components/Dashboards'
|
||||
import { Alerts } from './components/Alerts'
|
||||
import { fetchLogs, fetchStats, fetchTimeline, type LogEntry, type Stats, type TimelineBucket } from './lib/api'
|
||||
import {
|
||||
fetchLogs,
|
||||
fetchParamDeclarations,
|
||||
fetchStats,
|
||||
fetchTimeline,
|
||||
type LogEntry,
|
||||
type ParamDeclaration,
|
||||
type Stats,
|
||||
type TimelineBucket,
|
||||
} from './lib/api'
|
||||
import { DocsNavProvider } from './lib/docsNav'
|
||||
|
||||
const POLL_MS = 2000
|
||||
@@ -14,6 +24,7 @@ const POLL_MS = 2000
|
||||
export default function App() {
|
||||
const [stats, setStats] = useState<Stats | null>(null)
|
||||
const [logs, setLogs] = useState<LogEntry[]>([])
|
||||
const [params, setParams] = useState<ParamDeclaration[]>([])
|
||||
const [buckets, setBuckets] = useState<TimelineBucket[]>([])
|
||||
const [range, setRange] = useState<TimeRange | null>(null)
|
||||
const [activePreset, setActivePreset] = useState<TimeRangePresetId | null>('all')
|
||||
@@ -30,6 +41,18 @@ export default function App() {
|
||||
rangeRef.current = range
|
||||
}, [range])
|
||||
|
||||
async function loadParams() {
|
||||
try {
|
||||
setParams(await fetchParamDeclarations())
|
||||
} catch {
|
||||
// engine not reachable yet; leave the previous list in place
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadParams()
|
||||
}, [])
|
||||
|
||||
function selectPreset(id: TimeRangePresetId) {
|
||||
setActivePreset(id)
|
||||
setRange(computePresetRange(id))
|
||||
@@ -108,7 +131,8 @@ export default function App() {
|
||||
activePreset={activePreset}
|
||||
onSelectPreset={selectPreset}
|
||||
/>
|
||||
<LogPreview logs={logs} />
|
||||
<LogPreview logs={logs} params={params} />
|
||||
<Params params={params} onDeclared={loadParams} />
|
||||
<Metrics range={range} />
|
||||
<Dashboards range={range} />
|
||||
<Alerts />
|
||||
|
||||
Reference in New Issue
Block a user