app/: the web app in its own folder, with the Images and Labeling pages (D-138)
- app/serveur/ (FastAPI) and app/web/ (React, Mantine) moved out of API/, which keeps
only the agents; the Support page drives them
- Images page: view.py in React (slider, zoom, sensor names, displacement arrows on a range)
- Labeling page: labeling.py in React (two aligned plots, label bar, add, edit, delete);
labels are written to labeling/{auto,manual}/ of the repo (AIMSIGHT_LABELS)
- shared station and date selector kept in the address; buttons from a support session
- app/serveur/station.py: the data of both pages, copied computations listed in app/README.md
- app/serveur/check.py: server and station checks (labels in a temporary folder)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
374d91eb15
commit
bd93e708d2
26 files changed
+1263
-206
No files matched your search
@@ -0,0 +1,117 @@
|
||||
import { lazy, Suspense, useEffect, useState } from "react";
|
||||
import {
|
||||
ActionIcon, AppShell, Burger, Group, Loader, NavLink, ScrollArea, Text, Tooltip, useComputedColorScheme, useMantineColorScheme,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconChartLine, IconMessages, IconMoon, IconPhoto, IconSun } from "@tabler/icons-react";
|
||||
import Support, { AGENTS, Etat, NOMS } from "./pages/Support.jsx";
|
||||
import Images from "./pages/Images.jsx";
|
||||
|
||||
const Etiquetage = lazy(() => import("./pages/Etiquetage.jsx")); // Plotly, chargé seulement ici
|
||||
const PAGES = [["support", "Support", IconMessages], ["images", "Images", IconPhoto], ["etiquetage", "Étiquetage", IconChartLine]];
|
||||
|
||||
// L'adresse : #/<page>?station=…&du=…&au=… ; recharger garde la page et la sélection, Retour marche
|
||||
function lireAdresse() {
|
||||
const [page, q = ""] = location.hash.replace(/^#\/?/, "").split("?");
|
||||
const p = new URLSearchParams(q);
|
||||
return { page: PAGES.some(([n]) => n === page) ? page : "support",
|
||||
selection: { station: p.get("station") || "", du: p.get("du") || "", au: p.get("au") || "" } };
|
||||
}
|
||||
|
||||
function adresse(page, s) {
|
||||
const q = new URLSearchParams(Object.entries(s).filter(([, v]) => v)).toString();
|
||||
return `#/${page}${q ? "?" + q : ""}`;
|
||||
}
|
||||
|
||||
function Entete({ dossier, mobile, bureau, basculer }) {
|
||||
const { setColorScheme } = useMantineColorScheme(), schema = useComputedColorScheme("light");
|
||||
return (
|
||||
<AppShell.Header className="entete">
|
||||
<Group h="100%" px="md" justify="space-between" wrap="nowrap">
|
||||
<Group gap="sm" wrap="nowrap">
|
||||
<Burger opened={mobile} onClick={basculer.mobile} hiddenFrom="sm" size="sm" color="white" aria-label="Menu" />
|
||||
<Burger opened={bureau} onClick={basculer.bureau} visibleFrom="sm" size="sm" color="white" aria-label="Barre latérale" />
|
||||
<Text fw={700} size="lg">AIMsight</Text>
|
||||
<Text size="sm" opacity={0.6}>Support</Text>
|
||||
</Group>
|
||||
<Group gap="sm" wrap="nowrap">
|
||||
{dossier && <Text ff="monospace" size="sm" opacity={0.75} visibleFrom="sm">{dossier}</Text>}
|
||||
<Tooltip label={schema === "dark" ? "Mode clair" : "Mode sombre"}>
|
||||
<ActionIcon variant="subtle" color="white" size="lg" aria-label="Changer de thème"
|
||||
onClick={() => setColorScheme(schema === "dark" ? "light" : "dark")}>
|
||||
{schema === "dark" ? <IconSun size={20} /> : <IconMoon size={20} />}
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Group>
|
||||
</Group>
|
||||
</AppShell.Header>
|
||||
);
|
||||
}
|
||||
|
||||
function Barre({ page, selection, etat, fermer }) {
|
||||
const c = etat.cout, dollars = v => `${(v ?? 0).toFixed(2)} $`;
|
||||
const titre = t => <Text size="xs" fw={700} tt="uppercase" c="dimmed" px="sm" pt="lg" pb="xs">{t}</Text>;
|
||||
return (
|
||||
<AppShell.Navbar p="xs">
|
||||
<ScrollArea type="scroll">
|
||||
{titre("Pages")}
|
||||
{PAGES.map(([n, nom, Icone]) => (
|
||||
<NavLink key={n} label={nom} leftSection={<Icone size={18} />} active={page === n} onClick={fermer}
|
||||
href={adresse(n, n === "support" ? {} : selection)} />
|
||||
))}
|
||||
{page === "support" && <>
|
||||
{titre("Séance")}
|
||||
{AGENTS.map(a => <NavLink key={a} label={NOMS[a]} rightSection={<Etat occupe={etat.occupe[a]} />} />)}
|
||||
{titre("Coût")}
|
||||
{AGENTS.map(a => <NavLink key={a} label={NOMS[a]} rightSection={<Text size="sm">{dollars(c?.[a])}</Text>} />)}
|
||||
<NavLink label={<b>Total</b>} rightSection={<Text size="sm" fw={700}>{dollars(c?.total)}</Text>} />
|
||||
</>}
|
||||
</ScrollArea>
|
||||
</AppShell.Navbar>
|
||||
);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const [{ page, selection }, setLieu] = useState(lireAdresse);
|
||||
const [etat, setEtat] = useState({ occupe: { support: false, analyste: false } });
|
||||
const [evenements, setEvenements] = useState([]);
|
||||
const [mobile, { toggle: basculerMobile, close: fermerMobile }] = useDisclosure(false);
|
||||
const [bureau, { toggle: basculerBureau }] = useDisclosure(true);
|
||||
// La dernière station et plage vues, pour revenir à Images ou Étiquetage depuis Support
|
||||
const [derniere, setDerniere] = useState(selection);
|
||||
|
||||
useEffect(() => {
|
||||
const suivre = () => setLieu(lireAdresse());
|
||||
addEventListener("hashchange", suivre);
|
||||
return () => removeEventListener("hashchange", suivre);
|
||||
}, []);
|
||||
useEffect(() => { if (page !== "support") setDerniere(selection); }, [page, selection.station, selection.du, selection.au]);
|
||||
|
||||
// La séance tourne même quand on regarde une autre page : le flux reste ouvert
|
||||
useEffect(() => {
|
||||
const flux = new EventSource("/api/flux");
|
||||
flux.onmessage = ev => {
|
||||
const r = JSON.parse(ev.data), nouveaux = r.evenements.filter(e => e.type !== "cout");
|
||||
// depuis = 0 : tout l'historique de la séance (nouvelle séance, ou reconnexion) ; sinon la suite
|
||||
setEvenements(evs => (r.depuis === 0 ? nouveaux : [...evs, ...nouveaux]));
|
||||
setEtat(r);
|
||||
};
|
||||
return () => flux.close();
|
||||
}, []);
|
||||
|
||||
const choisir = s => { location.hash = adresse(page, s); };
|
||||
return (
|
||||
<AppShell header={{ height: 64 }} padding="lg"
|
||||
navbar={{ width: 260, breakpoint: "sm", collapsed: { mobile: !mobile, desktop: !bureau } }}>
|
||||
<Entete dossier={etat.dossier} mobile={mobile} bureau={bureau} basculer={{ mobile: basculerMobile, bureau: basculerBureau }} />
|
||||
<Barre page={page} selection={page === "support" ? derniere : selection} etat={etat} fermer={fermerMobile} />
|
||||
<AppShell.Main bg="var(--mantine-color-default-hover)">
|
||||
{page === "support" && <Support etat={etat} evenements={evenements} />}
|
||||
{page === "images" && <Images selection={selection} choisir={choisir} />}
|
||||
{page === "etiquetage" && (
|
||||
<Suspense fallback={<Loader m="xl" />}><Etiquetage selection={selection} choisir={choisir} /></Suspense>
|
||||
)}
|
||||
</AppShell.Main>
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user