feat: instrument analysis
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useState, useEffect, useRef, useCallback } from 'react'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import {
|
||||
FlaskConical, Library, Zap, BarChart3, RefreshCw, Edit3,
|
||||
Sliders, Brain, Search, CheckCircle, XCircle, Minus, AlertCircle,
|
||||
@@ -372,7 +373,7 @@ function GraphLegend() {
|
||||
|
||||
// ── Tab: Bibliothèque ─────────────────────────────────────────────────────────
|
||||
|
||||
function TabLibrary() {
|
||||
function TabLibrary({ initialTemplateId }: { initialTemplateId?: number | null }) {
|
||||
const [templates, setTemplates] = useState<Template[]>([])
|
||||
const [selected, setSelected] = useState<Template | null>(null)
|
||||
const [catFilter, setCatFilter] = useState('')
|
||||
@@ -396,6 +397,13 @@ function TabLibrary() {
|
||||
.finally(() => setLoading(false))
|
||||
}, [catFilter])
|
||||
|
||||
// Auto-select template when arriving from a deep-link (?template=ID)
|
||||
useEffect(() => {
|
||||
if (!initialTemplateId || !templates.length || selected) return
|
||||
const t = templates.find(t => t.id === initialTemplateId)
|
||||
if (t) selectTemplate(t)
|
||||
}, [templates, initialTemplateId])
|
||||
|
||||
function selectTemplate(t: Template) {
|
||||
setSelected(t)
|
||||
setEditCoefs(Object.fromEntries(
|
||||
@@ -1676,7 +1684,9 @@ const TABS = [
|
||||
]
|
||||
|
||||
export default function CausalLab() {
|
||||
const [tab, setTab] = useState('library')
|
||||
const [searchParams] = useSearchParams()
|
||||
const initialTemplateId = searchParams.get('template') ? parseInt(searchParams.get('template')!) : null
|
||||
const [tab, setTab] = useState('library')
|
||||
|
||||
return (
|
||||
<div className="p-6 min-h-screen">
|
||||
@@ -1702,7 +1712,7 @@ export default function CausalLab() {
|
||||
</div>
|
||||
|
||||
<div className="bg-dark-800 rounded-xl p-5 border border-slate-700/30">
|
||||
{tab === 'library' && <TabLibrary />}
|
||||
{tab === 'library' && <TabLibrary initialTemplateId={initialTemplateId} />}
|
||||
{tab === 'editor' && <TabEditor />}
|
||||
{tab === 'analyze' && <TabAnalyze />}
|
||||
{tab === 'calib' && <TabCalibration />}
|
||||
|
||||
Reference in New Issue
Block a user