diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5b9d5eda0..3485f37d5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -313,7 +313,7 @@ function App() { - + {activeItem.render?.()} diff --git a/frontend/src/components/RugnuxHero.tsx b/frontend/src/components/RugnuxHero.tsx index 759c24c22..b6b2f2895 100644 --- a/frontend/src/components/RugnuxHero.tsx +++ b/frontend/src/components/RugnuxHero.tsx @@ -1,10 +1,11 @@ -import {Box, Paper, Tooltip, Typography} from "@mui/material"; -import {green, grey, indigo, red} from "@mui/material/colors"; +import {Box, Tooltip, Typography} from "@mui/material"; +import {green, red} from "@mui/material/colors"; import {keyframes} from "@mui/system"; import {rugnux_live_status} from "../client"; -// The headline of a rugnux live run as big numbers, as jfjoch_viewer's merge-statistics window opens: -// resolution, ISa, space group, and whether the model was placed. "—" until the run is over. +// The headline of a rugnux live run as one row of big numbers, read left to right the way a crystallographer +// reads a merge: how far, how clean, how complete, in what symmetry, and whether the model fits. "—" until +// the merge the numbers are of exists (the end of a rotation run, each provisional merge of a serial one). const fadeIn = keyframes` from { opacity: 0; transform: scale(.94); } @@ -13,7 +14,7 @@ const fadeIn = keyframes` // The short Hermann-Mauguin symbol with screw axes subscripted and rotoinversions overlined, as the viewer // writes it: "P 1 21 1" -> P2₁, "P 41 21 2" -> P4₁2₁2, "R 3 :H" -> H3. -function SpaceGroup({hm}: { hm: string }) { +export function SpaceGroup({hm}: { hm: string }) { const [symbol, setting] = hm.split(":").map(x => x.trim()); let s = symbol; // the monoclinic shortening: "P 1 21 1" -> "P 21" @@ -31,107 +32,135 @@ function SpaceGroup({hm}: { hm: string }) { })}; } -type Tone = "plain" | "pending" | "good" | "bad" | "neutral"; +type Tone = "plain" | "pending" | "good" | "bad"; -const TONE: Record = { - plain: {bg: "#fff", border: indigo[100], value: indigo[900]}, - pending: {bg: grey[50], border: grey[200], value: indigo[200]}, - good: {bg: green[50], border: green[400], value: green[800]}, - bad: {bg: red[50], border: red[300], value: red[800]}, - neutral: {bg: grey[100], border: grey[300], value: grey[600]}, -}; +const VALUE_COLOUR: Record = {plain: "text.primary", pending: "text.disabled", good: green[300], bad: red[300]}; -function Card({value, caption, sub, tip, tone}: +function Tile({value, caption, sub, tip, tone}: { value: React.ReactNode, caption: string, sub?: string, tip: React.ReactNode, tone: Tone }) { - const c = TONE[tone]; return ( - + + + {caption} + {value} - - {caption} - - {sub ?? ""} - + ); } +// The run-wide merging statistics exist only as the words of the report's Signal and Completeness rows +// ("I/sigma 35.2 R_meas 4.8 % CC1/2 1.000 ISa 30.2", "85.7 % over the full written range"); they are +// read back out of them here. A status that carried them as numbers would make this go away. +function summaryNumber(s: rugnux_live_status, row: RegExp, key: RegExp): number | undefined { + const text = s.summary.find(r => row.test(r.label))?.value; + const m = text?.match(key); + return m ? parseFloat(m[1]) : undefined; +} + const FIT_TIP = "Fit over random: how far the placed model's R-work stands below that of the same model refitted " - + "in random orientations, in standard deviations of those. It is the test rugnux places a model by, for " - + "molecular replacement and for a model that fits where it is alike. Green: rugnux placed the model; " - + "red: it did not."; + + "in random orientations, in standard deviations of those. It is the test rugnux places a model by. " + + "Green: rugnux placed the model; red: it did not."; -const REFINED_TIP = "R-work and R-free of the placed model after rugnux refined it against these data (rigid bodies " - + "and grouped B, then every atom restrained by the dictionary), R-free on the merge's own free set."; - -// The model card: green where rugnux placed the model (by molecular replacement or where it was), red where it -// did not, grey where there was no model to place; once refined, the refined R-free is its context line. -// modelLoaded: a model is uploaded now. -function ModelCard({s, modelLoaded}: { s: rugnux_live_status, modelLoaded: boolean }) { +// The model tile: green where rugnux placed the model, red where it did not, plain where there was none. +// Once refined, the refined R-work / R-free are the number. modelLoaded: a model is uploaded now. +function ModelTile({s, modelLoaded}: { s: rugnux_live_status, modelLoaded: boolean }) { const m = s.model; const fit = m?.fit_sigma != null ? `${m.fit_sigma >= 0 ? "+" : ""}${m.fit_sigma.toFixed(1)} σ` : undefined; if (m && m.placement !== "NOT_PLACED") { const how = m.placement === "MR" ? `MR · ${m.copies ?? 1} ${m.copies === 1 || m.copies === undefined ? "copy" : "copies"}` : "fits where it is"; - // Refined: its R-work / R-free are the headline, the card's green still says the model was placed const rf = m.refinement?.performed ? m.refinement : undefined; if (rf && rf.r_work != null && rf.r_free != null) - return {REFINED_TIP}{rf.cancelled && " The deadline cut the refinement short."}

{FIT_TIP}}/>; - return ; + return R-work and R-free of the placed model after rugnux refined it against these data, R-free + on the merge's own free set.{rf.cancelled && " The deadline cut the refinement short."} +

{FIT_TIP}}/>; + if (m.r_work != null && m.r_free != null) + return ; + return ; } if (m) { // "NOT_PLACED: no group of ..." -> "no group of ..." const why = m.reason || m.mr_decision.replace(/^[A-Z_]+: /, ""); - return {FIT_TIP}{why && <>

{why}}}/>; } if (s.state === "Running" && modelLoaded) { const step = s.steps.length > 0 ? s.steps[s.steps.length - 1].title : ""; const sub = step === "Molecular replacement" ? "searching…" : step === "Refinement" ? "refining…" - : "placed after merging"; - return ; + : "placed after the merge"; + return ; } if (s.state === "Running" || !modelLoaded) - return ; - return ; + return ; } function RugnuxHero({s, modelLoaded}: { s: rugnux_live_status, modelLoaded: boolean }) { - const pending = s.state === "Running"; - const later = pending ? "when the run is over" : undefined; - const tone: Tone = pending ? "pending" : "plain"; + // the numbers are of a merge that exists: rotation - the run is over; serial - a provisional merge is in + const merged = s.d_min !== undefined || (s.shells !== undefined && s.shells.length > 0); + const pending: Tone = merged ? "plain" : "pending"; + const later = merged ? undefined : s.stills ? "at the first provisional merge" : "when the run is over"; + const num = (v: number | undefined, fmt: (x: number) => string) => v !== undefined ? fmt(v) : "—"; + const pct = (x: number) => `${x.toFixed(1)} %`; + + const ccHalf = summaryNumber(s, /^signal/i, /CC1\/2\s+([\d.]+)/); + const iSigma = summaryNumber(s, /^signal/i, /I\/sigma\s+([\d.]+)/); + const rMeas = summaryNumber(s, /^signal/i, /R_meas\s+([\d.]+)\s*%/); + const rSplit = summaryNumber(s, /^signal/i, /R_split\s+([\d.]+)\s*%/); + const completeness = summaryNumber(s, /^completeness/i, /([\d.]+)\s*%/); + const cell = s.summary.find(r => /^unit cell/i.test(r.label))?.value; const mrGroup = s.model?.mr_space_group; + const indexed = s.stills && s.stills.images_analysed > 0 + ? 100 * s.stills.images_indexed / s.stills.images_analysed : undefined; + return ( - - + `${x.toFixed(2)} Å`)} caption="Resolution" sub={later} tone={pending} tip="High-resolution limit of the merge (d_min); the Resolution row of the result says where the CC½ fall-off is fitted."/> - - : "—"} caption="Space group" - sub={later ?? (mrGroup && s.space_group && mrGroup !== s.space_group ? `model placed in ${mrGroup}` : s.space_group)} - tone={s.space_group ? "plain" : tone} - tip="Space group rugnux determined from the data. Where molecular replacement placed the model in another group, the card says which."/> - + x.toFixed(3))} caption="CC½" sub={later ?? "all reflections"} tone={pending} + tip="CC½ of the whole merge, the half-dataset correlation; the plot on the right has it by shell."/> + x.toFixed(1))} caption="I/σ" sub={later ?? "mean over the merge"} tone={pending} + tip="Mean I/σ of the merged reflections over the whole written range."/> + + {s.stills + ? + : } + {s.stills + ? + : x.toFixed(1))} caption="ISa" sub={later ?? (s.isa === undefined ? "not determined" : "error model")} + tone={pending} + tip="ISa: the I/σ the strongest reflections level off at, from the error model (XDS's meaning). It measures the crystal and the instrument, not the exposure."/>} + : "—"} caption="Space group" tone={s.space_group ? "plain" : pending} + sub={later ?? (mrGroup && s.space_group && mrGroup !== s.space_group ? `model placed in ${mrGroup}` : cell)} + tip={<>Space group rugnux determined from the data{cell && <>, unit cell {cell}}. Where molecular + replacement placed the model in another group, the tile says which.}/> + ); } diff --git a/frontend/src/components/RugnuxPage.tsx b/frontend/src/components/RugnuxPage.tsx index 7fd37906c..0cbc46b37 100644 --- a/frontend/src/components/RugnuxPage.tsx +++ b/frontend/src/components/RugnuxPage.tsx @@ -1,8 +1,9 @@ -import {Alert, Box, LinearProgress, Paper, Stack, Typography} from "@mui/material"; -import {indigo, lime, grey} from "@mui/material/colors"; +import {Alert, Box, Button, Collapse, Paper, Stack, ThemeProvider, Typography, createTheme} from "@mui/material"; +import {green, indigo, lime, orange, red, grey} from "@mui/material/colors"; +import {keyframes} from "@mui/system"; import {useQuery} from "@tanstack/react-query"; import {getConfigRugnuxOptions, getRugnuxStatusOptions} from "../client/@tanstack/react-query.gen"; -import {rugnux_live_status} from "../client"; +import {rugnux_live_status, rugnux_live_step, rugnux_live_stills} from "../client"; import {useTokenRequired} from "../auth"; import EmptyState from "./EmptyState"; import RugnuxTriage from "./RugnuxTriage"; @@ -11,28 +12,183 @@ import RugnuxSettings from "./RugnuxSettings"; import RugnuxHero from "./RugnuxHero"; import RugnuxStills from "./RugnuxStills"; import RugnuxShellPlots from "./RugnuxShellPlots"; -import {CutAlert, lastImageTime, ModelScores, ProbeAlert, RunMessage, StateChip, StepTable, VerdictAlert} from "./RugnuxParts"; +import {lastImageTime, ModelScores, StepTable, VerdictAlert} from "./RugnuxParts"; import BoltIcon from "@mui/icons-material/Bolt"; -import {lazy, Suspense} from "react"; -import {keyframes} from "@mui/system"; +import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; +import CheckIcon from "@mui/icons-material/Check"; +import {lazy, Suspense, useEffect, useRef, useState} from "react"; + +// The live page as one control-room screen: a dark stage that holds, top to bottom, the state and the two +// progress bars (the detector's and rugnux's), the hero numbers of the merge, and the stage proper - the placed +// model in Mol* on the left, the triage list and the merging statistics by shell on the right. While there is +// no model the left half shows the run's steps. Everything else - the timeline, step notes, summary rows, +// warnings, the serial pre-pass geometry - sits under a "Details" fold below the stage, and the settings +// under that, on the page's ordinary light background. // Mol* is large: loaded only when there is a model to show. const RugnuxStructureViewer = lazy(() => import("./RugnuxStructureViewer")); -// The summary rows rugnux writes; the ones a crystallographer looks at first get a stronger tile. -const KEY_ROW = /unit cell|space group|resolution|signal|r-?free|model/i; +// The dark room: the app's indigo/lime, on a navy stage the viewer's black blends into. +const liveTheme = createTheme({ + palette: { + mode: "dark", + primary: {main: indigo[300]}, + secondary: {main: lime[500]}, + background: {default: "#0c1122", paper: "#151c33"}, + text: {primary: "#e9edf7", secondary: "#9aa5c4", disabled: "#596483"}, + divider: "rgba(154,165,196,.22)", + }, + shape: {borderRadius: 8}, +}); -// The model section's entrance under the timeline, once the run has placed a model -const slideIn = keyframes` - from { opacity: 0; transform: translateY(24px); } - to { opacity: 1; transform: none; } +const stripes = keyframes` + from { background-position: 0 0; } + to { background-position: 40px 0; } +`; +const pulse = keyframes` + 0%, 100% { opacity: 1; } + 50% { opacity: .45; } `; -function Section({title, children, sx}: { title: string, children: React.ReactNode, sx?: object }) { +const runningSx = { + backgroundImage: "linear-gradient(135deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, " + + "rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%, transparent)", + backgroundSize: "40px 40px", + animation: `${stripes} 1s linear infinite`, + "@media (prefers-reduced-motion: reduce)": {animation: "none"}, +}; + +// What the run is doing, in one word, with the colour the rest of the screen takes from it. +function phase(s: rugnux_live_status): { label: string, colour: string } { + if (s.state === "Running") + return lastImageTime(s) === undefined + ? {label: "Collecting", colour: lime[500]} : {label: "Processing", colour: indigo[300]}; + if (s.state === "Done") + return s.verdict === "OK" ? {label: "Done", colour: green[400]} + : s.verdict === "WARNINGS" ? {label: "Done · warnings", colour: orange[400]} + : {label: `Done · ${s.verdict.toLowerCase()}`, colour: red[400]}; + if (s.state === "Failed") + return {label: "Failed", colour: red[400]}; + return {label: s.state, colour: grey[500]}; +} + +// The serial pre-pass in one line: its state, and what it decided for the whole collection +function prepassLine(st: rugnux_live_stills) { + if (st.prepass === "Holding") + return `Pre-pass: holding ${st.images_held} / ${st.images_needed} images`; + if (st.prepass === "Running") + return `Pre-pass on the first ${st.images_held} images`; + if (st.prepass === "Failed") + return "Pre-pass failed: the stated beam centre and mask are used"; + const shift = st.beam_x_pxl !== undefined && st.beam_y_pxl !== undefined + ? Math.hypot(st.beam_x_pxl - st.file_beam_x_pxl, st.beam_y_pxl - st.file_beam_y_pxl) : undefined; + return `Pre-pass on ${st.images_held} images in ${st.prepass_s?.toFixed(1)} s` + + (shift !== undefined ? ` · beam centre moved ${shift.toFixed(1)} px` : "") + + (st.distance_mm !== undefined ? ` · distance ${(st.distance_mm - st.file_distance_mm) >= 0 ? "+" : ""}${(st.distance_mm - st.file_distance_mm).toFixed(2)} mm` : "") + + (st.analysis_rate_hz !== undefined ? ` · GPU analysis ${st.analysis_rate_hz.toFixed(0)} Hz` : ""); +} + +// A progress bar with its caption inside: fraction undefined = busy without a measure (striped, full). +function Bar({caption, detail, fraction, colour, busy}: + { caption: string, detail: string, fraction?: number, colour: string, busy: boolean }) { + const width = fraction === undefined ? (busy ? 100 : 0) : 100 * Math.min(1, Math.max(0, fraction)); return ( - - + + + + + {caption} + + + {detail} + + + + ); +} + +// Phase, the two bars and the clock: images against the collection on the detector's bar, the step rugnux is +// on against its own pass on rugnux's - the second chases the first while collecting - and, at the right, +// the number the run is judged by: seconds since the first image while it runs, from the last image to all +// results written once it is over. +function Header({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) { + const p = phase(s); + const running = s.state === "Running"; + const lastImage = lastImageTime(s); + const collecting = running && lastImage === undefined; + const rate = s.images_received > 1 && s.elapsed_s > 0 ? (s.images_received - 1) / (lastImage ?? s.elapsed_s) : 0; + const remaining = collecting && rate > 0 ? (s.images_expected - s.images_received) / rate : undefined; + const detectorDetail = `${s.images_received.toLocaleString()} / ${s.images_expected.toLocaleString()} images` + + (rate > 0 ? ` · ${rate.toFixed(0)} Hz` : "") + + (remaining !== undefined ? ` · ${remaining.toFixed(0)} s to go` : lastImage !== undefined ? ` · collected in ${lastImage.toFixed(1)} s` : ""); + + const step = s.steps.length > 0 ? s.steps[s.steps.length - 1] : undefined; + let rugnuxDetail: string, rugnuxFraction: number | undefined; + if (running && step) { + rugnuxDetail = `${step.title} · step ${s.steps.length}` + (s.step_progress !== undefined ? ` · ${(100 * s.step_progress).toFixed(0)} %` : ""); + rugnuxFraction = s.step_progress; + } else if (running) { + rugnuxDetail = "waiting for images"; + rugnuxFraction = 0; + } else { + rugnuxDetail = s.cut ? `cut (${s.cut}) after ${s.steps.length} steps` : `${s.steps.length} steps · ${s.elapsed_s.toFixed(1)} s`; + rugnuxFraction = 1; + } + + const latency = s.last_image_to_written_s; + const clock = latency !== undefined + ? {caption: "last image → all written", value: latency, colour: p.colour} + : lastImage !== undefined + ? {caption: "since the last image", value: s.elapsed_s - lastImage, colour: indigo[200]} + : {caption: "since the first image", value: s.elapsed_s, colour: "text.primary"}; + const deadline = running && lastImage !== undefined && deadline_s > 0 ? lastImage + deadline_s - s.elapsed_s : undefined; + + return ( + + + + + {p.label} + + + {s.message || s.verdict_text || (s.stills ? prepassLine(s.stills) : s.probe) || "Rugnux live"} + + + 0 ? s.images_received / s.images_expected : undefined}/> + + + + + {clock.caption} + + + {clock.value.toFixed(1)}s + + + {deadline !== undefined ? `deadline in ${Math.max(0, deadline).toFixed(0)} s` + : s.cut ? `analysis cut (${s.cut})${s.cut_s !== undefined ? ` at ${s.cut_s.toFixed(1)} s` : ""}` + : s.start_to_first_image_s !== undefined ? `START → first image ${s.start_to_first_image_s.toFixed(1)} s` : ""} + + + + ); +} + +function Panel({title, children, sx}: { title: React.ReactNode, children: React.ReactNode, sx?: object }) { + return ( + + {title} {children} @@ -40,104 +196,152 @@ function Section({title, children, sx}: { title: string, children: React.ReactNo ); } -function Header({s}: { s: rugnux_live_status }) { - const latency = s.last_image_to_written_s; - const lastImage = lastImageTime(s); - return ( - - - - - Rugnux live - - - - {s.images_received} / {s.images_expected} images - {lastImage !== undefined && ` · collected in ${lastImage.toFixed(1)} s`} - {` · ${s.elapsed_s.toFixed(1)} s since the first image`} - {s.start_to_first_image_s !== undefined && ` · START → first image ${s.start_to_first_image_s.toFixed(1)} s`} - +function Later({text}: { text: string }) { + return {text}; +} + +// The run's steps as a sequence, the running one with its progress: what fills the stage while there is no +// model to show. +function StepSequence({s}: { s: rugnux_live_status }) { + const running = s.state === "Running"; + const row = (step: rugnux_live_step, i: number) => { + const open = step.duration_s === undefined; + return ( + + {open && running + ? + : } + + {step.title} + {step.notes.length > 0 && + {step.notes[step.notes.length - 1]}} - - - {latency !== undefined ? "Last image → all results written" : "Processing for"} - - - {(latency ?? s.elapsed_s).toFixed(1)} s - + + {open ? (running && s.step_progress !== undefined ? `${(100 * s.step_progress).toFixed(0)} %` : "") : `${step.duration_s!.toFixed(1)} s`} + + + ); + }; + return ( + + {s.steps.length === 0 && } + {s.steps.map(row)} + {s.probe && + Lattice probe{s.probe_s !== undefined && ` at ${s.probe_s.toFixed(1)} s`}: {s.probe} + } + + ); +} + +function Stage({s}: { s: rugnux_live_status }) { + const m = s.model; + // The model shows once a rotation run is over; serial data place it on each provisional merge, and the viewer + // reloads when the model step has a new result, not every time the status is polled. + if (m && s.placed_model && (s.state !== "Running" || s.stills)) { + const resultKey = s.stills + ? `${m.placement} ${m.r_work} ${m.r_free} ${m.refinement?.r_free} ${s.refined_model}` + : `${s.elapsed_s}`; + return ( + {m.placement === "MR" ? "Molecular replacement" : "Model"}{m.predicted && " · predicted model"} + {s.refined_model && " · refined"} · {m.model_name}} sx={{flexGrow: 1}}> + + }> + + + + + ); + } + return ( + + + + ); +} + +// Height of an element in px, kept up to date as the page resizes: the shell plots need theirs in pixels. +function useHeight() { + const ref = useRef(null); + const [height, setHeight] = useState(0); + useEffect(() => { + if (!ref.current) + return; + const observer = new ResizeObserver(entries => setHeight(entries[0].contentRect.height)); + observer.observe(ref.current); + return () => observer.disconnect(); + }, []); + return [ref, height] as const; +} + +function Dashboard({s, deadline_s, modelLoaded}: { s: rugnux_live_status, deadline_s: number, modelLoaded: boolean }) { + const [plotsRef, plotsHeight] = useHeight(); + const attention = s.triage?.filter(i => i.severity === "serious" || i.severity === "attention").length ?? 0; + const later = s.stills ? "at the first provisional merge" : "when the run is over"; + return ( + +
+ + + + + + + Triage{attention > 0 && · {attention} need attention}} + sx={{flex: "0 1 auto", maxHeight: "45%", overflowY: "auto", "& > *": {flexShrink: 0}}}> + {s.triage && s.triage.length > 0 ? : } + + By resolution{s.shells_merge && ` · merge of ${s.shells_merge}`}} sx={{flex: "1 1 0"}}> + + {s.shells && s.shells.length > 0 + ? + + + : } + + - - - ); -} - -function CurrentStep({s}: { s: rugnux_live_status }) { - const current = s.state === 'Running' && s.steps.length > 0 ? s.steps[s.steps.length - 1] : undefined; - if (!current) - return null; - return ( - - - {current.title} - {s.step_progress !== undefined && - {(s.step_progress * 100).toFixed(0)} %} - - ); } -function SummaryTiles({s}: { s: rugnux_live_status }) { - if (s.summary.length === 0) - return null; - return ( - - {s.summary.map((row, i) => { - const key = KEY_ROW.test(row.label); - const short = row.value.length <= 24; - return ( - - - {row.label} - - - {row.value} - - - ); - })} - - ); -} - -function ModelSection({s}: { s: rugnux_live_status }) { - const m = s.model!; +// What the stage leaves out, on the light page: the timeline, the steps with their notes, the summary rows +// and warnings, the model's scores, and the serial pre-pass geometry. +function Details({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) { + const [open, setOpen] = useState(false); const mrSeconds = s.steps.find(step => step.title === "Molecular replacement")?.duration_s; - // Serial data place the model on each provisional merge while collecting: the viewer reloads when the model - // step has a new result, not every time the status is polled. - const resultKey = s.stills - ? `${m.placement} ${m.r_work} ${m.r_free} ${m.refinement?.r_free} ${s.refined_model}` - : `${s.elapsed_s}`; return ( -
- - {s.placed_model && - Loading viewer...}> - - - } -
+ + + + + + {s.stills && } + {s.model && } + + + + + {s.summary.length > 0 && + + {s.summary.map((row, i) => {row.label}{row.value})} + } + {s.warnings.map((w, i) => {w})} + + + + + ); } @@ -151,58 +355,29 @@ function RugnuxPage({measuring}: { measuring: boolean }) { }); const tokenRequired = useTokenRequired(); - let live; + let empty; if (settings !== undefined && !enabled) - live = } - text="Rugnux live mode is off - enable it below"/>; + empty = "Rugnux live mode is off - enable it below"; else if (isError && tokenRequired) - live = } - text="Dataset token required (key button in the top bar)"/>; + empty = "Dataset token required (key button in the top bar)"; else if (isError || s === undefined || s.state === 'Idle') - live = } - text="No rugnux run yet - start a collection with live processing enabled"/>; - else - live = ( - -
- {s.stills - ?
- : } - - - {s.triage && s.triage.length > 0 &&
} -
- -
- {s.model && (s.state !== 'Running' || s.stills) && } - {s.shells && s.shells.length > 0 && -
- -
} - -
- - -
- {!s.stills &&
- {s.verdict - ? - : - {s.state === 'Running' ? "Results appear when the run is over." : "No result."} - } - - 0 ? 2 : 0}}> - {s.warnings.map((w, i) => {w})} - -
} -
- - ); + empty = "No rugnux run yet - start a collection with live processing enabled"; + // The stage is the height of the window less the app's bars, so the essentials never scroll on a desktop + // screen; below the lg breakpoint it flows. return ( - {live} + + + {empty || !s + ? + } text={empty ?? ""}/> + + : } + + + {s && !empty &&
} ); diff --git a/frontend/src/components/RugnuxShellPlots.tsx b/frontend/src/components/RugnuxShellPlots.tsx index 98603d539..8b93f6e0e 100644 --- a/frontend/src/components/RugnuxShellPlots.tsx +++ b/frontend/src/components/RugnuxShellPlots.tsx @@ -1,4 +1,4 @@ -import {Box, Typography} from "@mui/material"; +import {Box, Typography, useTheme} from "@mui/material"; import {rugnux_live_shell} from "../client"; import Plot from "./Plot"; @@ -24,7 +24,12 @@ const PANELS: { title: string, percent: boolean, legendLeft?: boolean, series: S ]}, ]; -function RugnuxShellPlots({shells, merge}: { shells: rugnux_live_shell[], merge?: string }) { +// height: of each panel in px. The plots take the colours of the enclosing MUI theme, so they read the +// same on the light dashboard card and on the dark live page. +function RugnuxShellPlots({shells, merge, height = 300}: { shells: rugnux_live_shell[], merge?: string, height?: number }) { + const theme = useTheme(); + const dark = theme.palette.mode === "dark"; + const grid = dark ? "rgba(255,255,255,.12)" : "#eee"; const x = shells.map(sh => 1 / (sh.d_min * sh.d_min)); // At most six d labels, the finest shell always among them const step = Math.ceil(shells.length / 6); @@ -51,22 +56,27 @@ function RugnuxShellPlots({shells, merge}: { shells: rugnux_live_shell[], merge? return null; return ( 1, legend: panel.legendLeft ? {x: 0, xanchor: "left", y: 1} : {x: 1, xanchor: "right", y: 1}, xaxis: { - title: {text: "d [Å]"}, + title: {text: "d [Å]", standoff: 4}, + gridcolor: grid, zerolinecolor: grid, tickvals: ticks.map(sh => 1 / (sh.d_min * sh.d_min)), ticktext: ticks.map(sh => sh.d_min.toFixed(2)), }, - yaxis: {rangemode: "tozero"}, + yaxis: {rangemode: "tozero", gridcolor: grid, zerolinecolor: grid}, uirevision: "shells", }} - config={{responsive: true}}/> + config={{responsive: true, displayModeBar: false}}/> ); })} diff --git a/frontend/src/components/RugnuxStructureViewer.tsx b/frontend/src/components/RugnuxStructureViewer.tsx index c69c23445..74c4f41d2 100644 --- a/frontend/src/components/RugnuxStructureViewer.tsx +++ b/frontend/src/components/RugnuxStructureViewer.tsx @@ -74,10 +74,11 @@ const BLOB_LABELS: [string, string][] = [['LIGAND', 'ligand'], ['WATER', 'water' // resultKey: changes when a new result is there to load; anomalous: it has an anomalous difference map; // anomalousSignal: the data carry usable anomalous signal, so that map is worth showing from the start; -// refined: the broker serves the refined model and its maps; blobs: what the refined model leaves unexplained. -function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined, blobs}: +// refined: the broker serves the refined model and its maps; blobs: what the refined model leaves unexplained; +// fill: take the parent's height (the live page's stage) instead of the viewer's own. +function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined, blobs, fill}: { resultKey: string, anomalous: boolean, anomalousSignal: boolean, - refined: boolean, blobs: Blob[] }) { + refined: boolean, blobs: Blob[], fill?: boolean }) { const pluginRef = useRef(null); const [pluginReady, setPluginReady] = useState(0); const [error, setError] = useState(); @@ -220,8 +221,9 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined, const mapsDisabled = mapsLoading; return ( - + borderColor: 'divider', borderRadius: 1, overflow: 'hidden', height: fill ? '100%' : undefined}}> + @@ -232,7 +234,7 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined, {modelLoading ? 'loading model…' : 'computing density maps…'} } - + {error && {error}} {refined ? 'Model · refined' : 'Model'}