Stations: a page of its own, under Data (the tracked stations, their position, the pumping), instead of the window of the selector
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8c8c1587a
commit
d72dccb14e
4 files changed
+97
-85
No files matched your search
+5
-2
@@ -1,6 +1,6 @@
|
||||
# The AIMsight web app
|
||||
|
||||
The tool of the manual diagnostic: a single page, **Data**.
|
||||
The tool of the manual diagnostic: two pages, **Data** and **Stations**.
|
||||
|
||||
## The Data page
|
||||
|
||||
@@ -14,11 +14,14 @@ The tool of the manual diagnostic: a single page, **Data**.
|
||||
- **The camera images**, on the right, on the same station and the same range: slider, ◀ ▶ and keyboard arrows; wheel to zoom, drag to move, double click for the whole image; Names box; a range on the bar under the slider draws the displacement arrow of each sensor. An arrow at the top left enlarges the image and pushes the plots to the left; the reverse arrow brings it back.
|
||||
- **The diagnostic settings**, under the image: "Focus on event curves" (with an event open, the plots show only its sensors: those of the detectors, or those the text of a label names), the families shown and, for Detectors only, the targets considered, the others removed before the detectors ("Rerun the detectors", parameter `targets` of `/api/detectors`).
|
||||
|
||||
- **Stations and pumping** (button of the selector): the tracked stations, `extraction/stations.txt` of `~/aimsight-data` (`SERIAL [position]`), to edit (serial, position: `lat,lon` or a Swiss place), and the checked ones pumped (`extraction/pump.sh`, `--delay 300`) over a range (by default from 3 days before the range shown, the history of the detectors) or, without dates, their missing days up to now; the end of `out/pump.log` follows, and the page loads again at the end of the pumping.
|
||||
- **The weather**: a station with a position gets, at Load, the hourly measurements of the nearest MeteoSwiss station (`weather/meteoswiss.py`) as plots "Weather: …", next to the "System: …" ones; the place found and the station chosen are written under the selector (check them: the search of a place always returns its best match).
|
||||
|
||||
The address keeps the station and the range (UTC, `end` excluded): `#/data?station=NIEDERHORN&start=2026-09-25&end=2026-10-08`; without dates, the last 5 UTC days, today included.
|
||||
|
||||
## The Stations page
|
||||
|
||||
The tracked stations, `extraction/stations.txt` of `~/aimsight-data` (`SERIAL [position]`), to edit (serial, position: `lat,lon` or a Swiss place, for the weather of Data), and the checked ones pumped (`extraction/pump.sh`, `--delay 300`) over a range (by default the station and the range of the address, from 3 days before: the history of the detectors) or, without dates, their missing days up to now; the end of `out/pump.log` follows. The end of a pumping launched by the app empties the cache of the detectors' events.
|
||||
|
||||
## The Analysis tab
|
||||
|
||||
- **Analyze the range**: a range selected, optional hints, then `server/analysis.py` launches the analyst of the agents repository by `claude -p` (non-interactive), with its instructions (`instructions/analyst.md`) and without the detectors (`DETECTORS: no`). It writes in `labeling/auto/analyses/<STATION>_<start>_<end>/` its labels and a diagnostic report (`report.md` and its figures; its work and claude's log in `work/`, outside git). The page follows its progress, then shows the report; the server submits its labels to `labeling/auto/<STATION>.jsonl` (field `analysis`). "View the report" on such a label opens it again.
|
||||
|
||||
+8
-4
@@ -3,10 +3,11 @@ import {
|
||||
ActionIcon, AppShell, Burger, ColorSwatch, Group, Loader, NavLink, ScrollArea, Text, Tooltip, useComputedColorScheme, useMantineColorScheme,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconChartLine, IconFolder, IconMoon, IconSun } from "@tabler/icons-react";
|
||||
import { IconChartLine, IconFolder, IconMoon, IconSatellite, IconSun } from "@tabler/icons-react";
|
||||
|
||||
const Data = lazy(() => import("./pages/Data.jsx")); // Plotly, loaded only here
|
||||
const PAGES = [["data", "Data", IconChartLine]];
|
||||
const Stations = lazy(() => import("./pages/Stations.jsx"));
|
||||
const PAGES = [["data", "Data", IconChartLine], ["stations", "Stations", IconSatellite]];
|
||||
|
||||
// The address: #/<page>?station=…&start=…&end=…; reloading keeps the page and the selection, Back works; without dates, the
|
||||
// last 5 UTC days, today included (end excluded: tomorrow)
|
||||
@@ -113,7 +114,7 @@ export default function App() {
|
||||
return () => removeEventListener("hashchange", follow);
|
||||
}, []);
|
||||
|
||||
// the same address again (Load, the end of a pumping): read again, a new selection loads the data again
|
||||
// the same address again (Load): read again, a new selection loads the data again
|
||||
const choose = s => { const a = address(page, s); if (location.hash === a) setPlace(readAddress()); else location.hash = a; };
|
||||
// An analysis of the sidebar: Data on its station, days that cover its range (unless the range shown already covers them)
|
||||
function openAnalysis(a) {
|
||||
@@ -128,7 +129,10 @@ export default function App() {
|
||||
<Header mobile={mobile} desktop={desktop} toggle={{ mobile: toggleMobile, desktop: toggleDesktop }} />
|
||||
<Sidebar page={page} selection={selection} close={closeMobile} open={openAnalysis} />
|
||||
<AppShell.Main bg="var(--mantine-color-default-hover)">
|
||||
<Suspense fallback={<Loader m="xl" />}><Data selection={selection} choose={choose} analysis={analysis} setAnalysis={setAnalysis} /></Suspense>
|
||||
<Suspense fallback={<Loader m="xl" />}>
|
||||
{page === "stations" ? <Stations selection={selection} />
|
||||
: <Data selection={selection} choose={choose} analysis={analysis} setAnalysis={setAnalysis} />}
|
||||
</Suspense>
|
||||
</AppShell.Main>
|
||||
</AppShell>
|
||||
);
|
||||
|
||||
+5
-79
@@ -1,7 +1,6 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { ActionIcon, Button, Card, Checkbox, Code, Group, Modal, ScrollArea, Select, Stack, Table, Text, TextInput } from "@mantine/core";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Card, Group, Select, TextInput } from "@mantine/core";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { IconPlus, IconX } from "@tabler/icons-react";
|
||||
|
||||
// A request to the API; a refusal of the server shows as a notification -> the JSON returned, or null
|
||||
export async function call(path, method = "GET", body) {
|
||||
@@ -19,9 +18,9 @@ export async function call(path, method = "GET", body) {
|
||||
|
||||
// The station and the range (UTC, To excluded; empty: the whole period), shared by the pages through the address
|
||||
export function Selector({ selection, choose }) {
|
||||
const [stations, setStations] = useState([]), [s, setS] = useState(selection), [editing, setEditing] = useState(false);
|
||||
useEffect(() => { call("/api/stations").then(l => l && setStations(l)); }, [selection]); // a pumping may add one
|
||||
useEffect(() => setS(selection), [selection]); // a new object at each change of the address, or at each Load
|
||||
const [stations, setStations] = useState([]), [s, setS] = useState(selection);
|
||||
useEffect(() => { call("/api/stations").then(l => l && setStations(l)); }, []);
|
||||
useEffect(() => setS(selection), [selection]); // a new object at each change of the address
|
||||
return (
|
||||
<Card shadow="sm" withBorder>
|
||||
<Group align="flex-end" gap="md">
|
||||
@@ -30,80 +29,7 @@ export function Selector({ selection, choose }) {
|
||||
<TextInput label="From (UTC)" type="date" value={s.start} onChange={e => setS({ ...s, start: e.currentTarget.value })} />
|
||||
<TextInput label="To (excluded)" type="date" value={s.end} onChange={e => setS({ ...s, end: e.currentTarget.value })} />
|
||||
<Button onClick={() => choose(s)} disabled={!s.station}>Load</Button>
|
||||
<Button variant="default" onClick={() => setEditing(true)}>Stations and pumping</Button>
|
||||
</Group>
|
||||
<Stations opened={editing} close={() => setEditing(false)} selection={s} reload={() => choose(selection)} />
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
const shift = (d, n) => (d ? new Date(Date.parse(d) + n * 864e5).toISOString().slice(0, 10) : "");
|
||||
|
||||
// The tracked stations (extraction/stations.txt of ~/aimsight-data): serial and position (for the weather of the Data page);
|
||||
// the checked ones pumped (extraction/pump.sh) over a range, or without range their missing days up to now. The state of
|
||||
// the pumping read every 2 s while the window is open or a pumping runs; at its end, the page loads again
|
||||
function Stations({ opened, close, selection, reload }) {
|
||||
const [rows, setRows] = useState([]), [checked, setChecked] = useState([]), [range, setRange] = useState({});
|
||||
const [images, setImages] = useState(true), [state, setState] = useState(null);
|
||||
useEffect(() => {
|
||||
if (!opened) return;
|
||||
call("/api/tracked").then(l => l && setRows(l));
|
||||
setChecked(selection.station ? [selection.station] : []);
|
||||
setRange({ start: shift(selection.start, -3), end: selection.end }); // 3 days before: the history of the detectors
|
||||
}, [opened]);
|
||||
const watch = opened || !!state?.running;
|
||||
useEffect(() => {
|
||||
if (!watch) return;
|
||||
const read = () => fetch("/api/pump").then(r => r.ok && r.json()).then(p => p && setState(p)).catch(() => {}); // silently
|
||||
read();
|
||||
const timer = setInterval(read, 2000);
|
||||
return () => clearInterval(timer);
|
||||
}, [watch]);
|
||||
const running = !!state?.running, was = useRef(false);
|
||||
useEffect(() => { if (was.current && !running) reload(); was.current = running; }, [running]);
|
||||
|
||||
const set = (i, k, v) => setRows(rows.map((r, n) => (n === i ? { ...r, [k]: v } : r)));
|
||||
const save = () => call("/api/tracked", "PUT", { stations: rows.filter(r => r.serial) }).then(l => l && setRows(l));
|
||||
const pump = () => call("/api/pump", "POST", { stations: checked, ...range, images }).then(p => p && setState(p));
|
||||
return (
|
||||
<Modal opened={opened} onClose={close} title="Stations and pumping" size="xl">
|
||||
<Stack gap="md">
|
||||
<Table withRowBorders={false} verticalSpacing={4}>
|
||||
<Table.Thead><Table.Tr><Table.Th w={40}>Pump</Table.Th><Table.Th>Serial</Table.Th>
|
||||
<Table.Th>Position (lat,lon or a Swiss place, for the weather)</Table.Th><Table.Th w={40} /></Table.Tr></Table.Thead>
|
||||
<Table.Tbody>
|
||||
{rows.map((r, i) => (
|
||||
<Table.Tr key={i}>
|
||||
<Table.Td><Checkbox checked={checked.includes(r.serial)} disabled={!r.serial} aria-label={`Pump ${r.serial}`}
|
||||
onChange={e => setChecked(e.currentTarget.checked ? [...checked, r.serial] : checked.filter(c => c !== r.serial))} /></Table.Td>
|
||||
<Table.Td><TextInput size="xs" value={r.serial} onChange={e => set(i, "serial", e.currentTarget.value.trim())} /></Table.Td>
|
||||
<Table.Td><TextInput size="xs" value={r.position} placeholder="46.6895,7.7790"
|
||||
onChange={e => set(i, "position", e.currentTarget.value)} /></Table.Td>
|
||||
<Table.Td><ActionIcon variant="subtle" color="gray" aria-label="Remove" onClick={() => setRows(rows.filter((_, n) => n !== i))}>
|
||||
<IconX size={16} /></ActionIcon></Table.Td>
|
||||
</Table.Tr>
|
||||
))}
|
||||
</Table.Tbody>
|
||||
</Table>
|
||||
<Group gap="sm">
|
||||
<Button size="xs" variant="default" leftSection={<IconPlus size={14} />}
|
||||
onClick={() => setRows([...rows, { serial: "", position: "" }])}>Add a station</Button>
|
||||
<Button size="xs" onClick={save}>Save the list</Button>
|
||||
</Group>
|
||||
<Group align="flex-end" gap="md">
|
||||
<TextInput label="From (UTC)" type="date" value={range.start || ""} onChange={e => setRange({ ...range, start: e.currentTarget.value })} />
|
||||
<TextInput label="To (excluded)" type="date" value={range.end || ""} onChange={e => setRange({ ...range, end: e.currentTarget.value })} />
|
||||
<Checkbox label="Images" checked={images} onChange={e => setImages(e.currentTarget.checked)} mb={8} />
|
||||
<Button onClick={pump} loading={running} disabled={!checked.length}>Pump {checked.length || ""}</Button>
|
||||
</Group>
|
||||
<Text size="xs" c="dimmed">From is 3 days before the range shown (the history of the detectors); without dates, the missing days of
|
||||
each station up to now. Read-only on the platform; a long range, outside busy hours.</Text>
|
||||
{state?.log?.length > 0 && (
|
||||
<ScrollArea h={220} viewportRef={v => v && (v.scrollTop = v.scrollHeight)}>
|
||||
<Code block>{state.log.join("\n")}</Code>
|
||||
</ScrollArea>
|
||||
)}
|
||||
</Stack>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { ActionIcon, Button, Card, Checkbox, Code, Group, ScrollArea, Stack, Table, Text, TextInput, Title } from "@mantine/core";
|
||||
import { IconPlus, IconX } from "@tabler/icons-react";
|
||||
import { call } from "../common.jsx";
|
||||
|
||||
const shift = (d, n) => (d ? new Date(Date.parse(d) + n * 864e5).toISOString().slice(0, 10) : "");
|
||||
|
||||
// The tracked stations (extraction/stations.txt of ~/aimsight-data): serial and position (for the weather of the Data page);
|
||||
// the checked ones pumped (extraction/pump.sh) over a range, or without range their missing days up to now. The state of
|
||||
// the pumping read every 2 s. By default, the station and the range of the address (From 3 days before: the history of
|
||||
// the detectors)
|
||||
export default function Stations({ selection }) {
|
||||
const [rows, setRows] = useState([]), [checked, setChecked] = useState(selection.station ? [selection.station] : []);
|
||||
const [range, setRange] = useState({ start: shift(selection.start, -3), end: selection.end });
|
||||
const [images, setImages] = useState(true), [state, setState] = useState(null);
|
||||
useEffect(() => { call("/api/tracked").then(l => l && setRows(l)); }, []);
|
||||
useEffect(() => {
|
||||
const read = () => fetch("/api/pump").then(r => r.ok && r.json()).then(p => p && setState(p)).catch(() => {}); // silently
|
||||
read();
|
||||
const timer = setInterval(read, 2000);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
const running = !!state?.running;
|
||||
const set = (i, k, v) => setRows(rows.map((r, n) => (n === i ? { ...r, [k]: v } : r)));
|
||||
const save = () => call("/api/tracked", "PUT", { stations: rows.filter(r => r.serial) }).then(l => l && setRows(l));
|
||||
const pump = () => call("/api/pump", "POST", { stations: checked, ...range, images }).then(p => p && setState(p));
|
||||
return (
|
||||
<Stack gap="lg" maw={1000}>
|
||||
<div>
|
||||
<Title order={2}>Stations</Title>
|
||||
<Text c="dimmed">The tracked stations and their position (for the weather of the Data page); the checked ones pumped from
|
||||
the platform, read-only.</Text>
|
||||
</div>
|
||||
<Card shadow="sm" withBorder>
|
||||
<Stack gap="md">
|
||||
<Table withRowBorders={false} verticalSpacing={4}>
|
||||
<Table.Thead><Table.Tr><Table.Th w={50}>Pump</Table.Th><Table.Th>Serial</Table.Th>
|
||||
<Table.Th>Position (lat,lon or a Swiss place, for the weather)</Table.Th><Table.Th w={40} /></Table.Tr></Table.Thead>
|
||||
<Table.Tbody>
|
||||
{rows.map((r, i) => (
|
||||
<Table.Tr key={i}>
|
||||
<Table.Td><Checkbox checked={checked.includes(r.serial)} disabled={!r.serial} aria-label={`Pump ${r.serial}`}
|
||||
onChange={e => setChecked(e.currentTarget.checked ? [...checked, r.serial] : checked.filter(c => c !== r.serial))} /></Table.Td>
|
||||
<Table.Td><TextInput size="xs" value={r.serial} onChange={e => set(i, "serial", e.currentTarget.value.trim())} /></Table.Td>
|
||||
<Table.Td><TextInput size="xs" value={r.position} placeholder="46.6895,7.7790"
|
||||
onChange={e => set(i, "position", e.currentTarget.value)} /></Table.Td>
|
||||
<Table.Td><ActionIcon variant="subtle" color="gray" aria-label="Remove" onClick={() => setRows(rows.filter((_, n) => n !== i))}>
|
||||
<IconX size={16} /></ActionIcon></Table.Td>
|
||||
</Table.Tr>
|
||||
))}
|
||||
</Table.Tbody>
|
||||
</Table>
|
||||
<Group gap="sm">
|
||||
<Button size="xs" variant="default" leftSection={<IconPlus size={14} />}
|
||||
onClick={() => setRows([...rows, { serial: "", position: "" }])}>Add a station</Button>
|
||||
<Button size="xs" onClick={save}>Save the list</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Card>
|
||||
<Card shadow="sm" withBorder>
|
||||
<Stack gap="md">
|
||||
<Group align="flex-end" gap="md">
|
||||
<TextInput label="From (UTC)" type="date" value={range.start} onChange={e => setRange({ ...range, start: e.currentTarget.value })} />
|
||||
<TextInput label="To (excluded)" type="date" value={range.end} onChange={e => setRange({ ...range, end: e.currentTarget.value })} />
|
||||
<Checkbox label="Images" checked={images} onChange={e => setImages(e.currentTarget.checked)} mb={8} />
|
||||
<Button onClick={pump} loading={running} disabled={!checked.length}>Pump {checked.length || ""}</Button>
|
||||
</Group>
|
||||
<Text size="xs" c="dimmed">By default From is 3 days before the range of the Data page (the history of the detectors);
|
||||
without dates, the missing days of each station up to now. A long range, outside busy hours.</Text>
|
||||
{state?.log?.length > 0 && (
|
||||
<ScrollArea h={320} viewportRef={v => v && (v.scrollTop = v.scrollHeight)}>
|
||||
<Code block>{state.log.join("\n")}</Code>
|
||||
</ScrollArea>
|
||||
)}
|
||||
</Stack>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user