Build Packages / Create release (push) Successful in 24s
Build Packages / build:viewer:macos-arm64:nocuda (push) Successful in 3m29s
Build Packages / build:rugnux:macos-arm64:nocuda (push) Successful in 2m43s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 8m27s
Build Packages / build:rugnux:linux-x86_64:cuda (push) Successful in 9m53s
Build Packages / build:viewer:linux-x86_64:nocuda (push) Successful in 9m58s
Build Packages / build:viewer:linux-x86_64:cuda (push) Successful in 11m22s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 13m39s
Build Packages / build:viewer:windows-x86_64:nocuda (push) Successful in 18m37s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 16m32s
Build Packages / build:viewer:windows-x86_64:cuda (push) Successful in 24m11s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m30s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 19m3s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 20m23s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 19m41s
Build Packages / Generate python client (push) Successful in 50s
Build Packages / Build documentation (push) Successful in 1m16s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 21m0s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 18m38s
Build Packages / build:rugnux:windows-x86_64:cuda (push) Successful in 14m33s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 17m55s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m50s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 18m38s
Build Packages / Unit tests (push) Successful in 1h46m14s
* jfjoch_broker: Optional per-dataset authentication - statistics, images and plots can require a bearer token, which jfjoch_viewer supports. * jfjoch_viewer: Dark mode and a theme-matched colour scheme, a magnifier panel, and simpler contrast and background controls. * Rugnux: Multiple performance improvements on GPU and CPU (CPU-only processing up to 40% faster, faster image decoding on ARM), with unchanged results. * Rugnux: `--model` rigid-body refinement runs on the GPU, and the model-validation check is faster and more reliable. * Rugnux: Improved scaling and merging - error model, outlier rejection, absorption correction and French-Wilson amplitudes now agree more closely with XDS and ctruncate. * Rugnux: Improved integration - radial background on powder and ice rings, crowded rotation data keep their reflections, and CPU-only builds integrate large unit cells as GPU builds do. * Rugnux: More robust detector geometry - measured beam centre, X-ray bandwidth and goniometer rate, and geometry refinement accepted only on significant evidence. * Rugnux: Merged files are written in the standard setting, or in the setting of a reference MTZ, structure-factor mmCIF or model, with its free-R flags. * Rugnux: Richer report - ice and powder rings, further lattices, superstructure candidates and mosaicity, with warnings worded as prompts to check. * Rugnux: Clear error messages when a data set needs more GPU or host memory than is available. Reviewed-on: #83 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
181 lines
8.0 KiB
TypeScript
181 lines
8.0 KiB
TypeScript
import {memo, useState} from 'react';
|
|
|
|
import AppBar from '@mui/material/AppBar';
|
|
import Toolbar from '@mui/material/Toolbar';
|
|
import Typography from '@mui/material/Typography';
|
|
import IconButton from '@mui/material/IconButton';
|
|
import Box from '@mui/material/Box';
|
|
import Stack from '@mui/material/Stack';
|
|
import {indigo, deepOrange} from '@mui/material/colors';
|
|
import MenuIcon from '@mui/icons-material/Menu';
|
|
import KeyIcon from '@mui/icons-material/Key';
|
|
import {Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, Tooltip} from "@mui/material";
|
|
import {useQueryClient} from "@tanstack/react-query";
|
|
import {broker_status} from "../client";
|
|
import ButtonWithSnackbar from "./ButtonWithSnackbar";
|
|
import {getToken, setToken, useTokenRequired} from "../auth";
|
|
|
|
type MyProps = {
|
|
s?: broker_status;
|
|
onMenuClick?: () => void;
|
|
}
|
|
|
|
// A tight, strong palette: lime = good/running, coral = working/alarm (deeper = worse),
|
|
// light-blue (sidebar) = neutral/idle-connection. Measuring and Pedestal are handled separately.
|
|
const STATE_STYLE: Record<string, { fill: string; text: string }> = {
|
|
Idle: { fill: "secondary.main", text: "rgba(0,0,0,.87)" }, // lime + black text
|
|
Busy: { fill: deepOrange[300], text: "rgba(0,0,0,.87)" }, // light coral
|
|
Error: { fill: deepOrange[700], text: "#fff" }, // deep coral
|
|
Inactive: { fill: indigo[100], text: "rgba(0,0,0,.87)" }, // sidebar light blue
|
|
};
|
|
|
|
// Fixed width so the pill fits the longest label ("Calibration · 100 %") and never
|
|
// resizes as the state changes.
|
|
const pillSx = {
|
|
position: "relative", width: 200, height: 36, borderRadius: 999, overflow: "hidden",
|
|
display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0,
|
|
} as const;
|
|
const pillLabelSx = { position: "relative", fontWeight: 600, fontSize: "0.95rem", whiteSpace: "nowrap" } as const;
|
|
|
|
// Three action-button tiers so exactly one button reads as "click me now":
|
|
// hot = lime — the action to take right now
|
|
// active = blue-on-blue (no frame), white text — available, secondary emphasis
|
|
// off = faint ghost — not relevant in this state
|
|
const activeColdSx = { bgcolor: "primary.dark", color: "#fff",
|
|
"&:hover": { bgcolor: "primary.dark", filter: "brightness(1.12)" } };
|
|
const offSx = { bgcolor: "rgba(255,255,255,.10)", color: "rgba(255,255,255,.6)", boxShadow: "none",
|
|
"&:hover": { bgcolor: "rgba(255,255,255,.18)" } };
|
|
const TIER = {
|
|
hot: { color: "secondary", variant: "contained" },
|
|
active: { color: "primary", variant: "contained", sx: activeColdSx },
|
|
off: { color: "inherit", variant: "contained", sx: offSx },
|
|
} as const;
|
|
type Tier = keyof typeof TIER;
|
|
|
|
function StatusChip({s}: {s?: broker_status}) {
|
|
if (s === undefined)
|
|
return (
|
|
<Box sx={{...pillSx, border: "1px solid rgba(255,255,255,.6)"}}>
|
|
<Typography component="span" sx={{...pillLabelSx, color: "#fff"}}>Not connected</Typography>
|
|
</Box>
|
|
);
|
|
|
|
// Measuring and Pedestal both fill a light-blue (sidebar) track to the progress
|
|
// fraction, with black text legible over both track and fill. Measuring fills lime;
|
|
// Pedestal fills coral (matching its flat-pill colour elsewhere). The "Pedestal"
|
|
// state is shown as "Calibration" — the internal name is kept only for back-compat.
|
|
if (s.state === "Measuring" || s.state === "Pedestal") {
|
|
const pct = Math.max(0, Math.min(100, (s.progress ?? 0) * 100.0));
|
|
const fill = s.state === "Measuring" ? "secondary.main" : deepOrange[300];
|
|
const label = s.state === "Measuring" ? "Measuring" : "Calibration";
|
|
return (
|
|
<Box sx={{...pillSx, bgcolor: indigo[100]}}>
|
|
<Box sx={{position: "absolute", left: 0, top: 0, bottom: 0, width: `${pct}%`,
|
|
bgcolor: fill, transition: "width .4s ease"}}/>
|
|
<Typography component="span" sx={{...pillLabelSx, color: "rgba(0,0,0,.87)"}}>
|
|
{label} · {pct.toFixed(0)} %
|
|
</Typography>
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
const style = STATE_STYLE[s.state] ?? { fill: "grey.500", text: "#fff" };
|
|
return (
|
|
<Box sx={{...pillSx, bgcolor: style.fill}}>
|
|
<Typography component="span" sx={{...pillLabelSx, color: style.text}}>{s.state.toString()}</Typography>
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
// The dataset token: a key button that turns lime while the broker refuses the dataset's
|
|
// statistics, images and plots (401) and a small dialog to enter or clear the token.
|
|
function TokenButton() {
|
|
const [open, setOpen] = useState(false);
|
|
const [value, setValue] = useState('');
|
|
const required = useTokenRequired();
|
|
const queryClient = useQueryClient();
|
|
|
|
const apply = (token: string) => {
|
|
setToken(token);
|
|
setOpen(false);
|
|
// Refetch everything so the polls pick up the new header right away.
|
|
queryClient.invalidateQueries();
|
|
};
|
|
|
|
return <>
|
|
<Tooltip title={required ? "Dataset token required" : "Dataset token"}>
|
|
<IconButton color={required ? "secondary" : "inherit"}
|
|
onClick={() => { setValue(getToken() ?? ''); setOpen(true); }}>
|
|
<KeyIcon/>
|
|
</IconButton>
|
|
</Tooltip>
|
|
<Dialog open={open} onClose={() => setOpen(false)}>
|
|
<DialogTitle>Dataset token</DialogTitle>
|
|
<DialogContent>
|
|
<TextField autoFocus fullWidth margin="dense" type="password" label="Token"
|
|
helperText="Bearer token given by whoever started the current dataset. Kept only in this tab."
|
|
value={value}
|
|
onChange={(e) => setValue(e.target.value)}
|
|
onKeyDown={(e) => { if (e.key === 'Enter') apply(value); }}/>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<Button onClick={() => apply('')}>Clear</Button>
|
|
<Button onClick={() => setOpen(false)}>Cancel</Button>
|
|
<Button variant="contained" onClick={() => apply(value)}>Apply</Button>
|
|
</DialogActions>
|
|
</Dialog>
|
|
</>;
|
|
}
|
|
|
|
function StatusBar({s, onMenuClick}: MyProps) {
|
|
// Pick each button's tier from the current state, so the one action that makes
|
|
// sense right now is lime and the rest recede.
|
|
const st = s?.state;
|
|
const cancelTier: Tier = (st === 'Measuring' || st === 'Pedestal') ? 'hot'
|
|
: (st === 'Busy' || st === 'Error') ? 'active' : 'off';
|
|
const initTier: Tier = (s === undefined || st === 'Inactive') ? 'hot'
|
|
: (st === 'Idle') ? 'active' : 'off';
|
|
const pedestalActive = st === 'Idle';
|
|
|
|
return <AppBar sx={{zIndex: (theme) => theme.zIndex.drawer + 1}}>
|
|
<Toolbar>
|
|
{onMenuClick && (
|
|
<IconButton color="inherit" edge="start" onClick={onMenuClick} sx={{mr: 2}}>
|
|
<MenuIcon/>
|
|
</IconButton>
|
|
)}
|
|
<Typography variant="h6" component="div" noWrap
|
|
sx={{flexGrow: 0.5, fontWeight: 500, letterSpacing: '.02em'}}>
|
|
Jungfraujoch
|
|
</Typography>
|
|
|
|
<Box sx={{flexGrow: 2.0, display: 'flex', justifyContent: 'center'}}>
|
|
<StatusChip s={s}/>
|
|
</Box>
|
|
|
|
<Box sx={{flexGrow: 2.0}}/>
|
|
<TokenButton/>
|
|
<Stack direction="row" spacing={1} sx={{ml: 1}}>
|
|
<ButtonWithSnackbar
|
|
text={"Cancel"}
|
|
path={"/cancel"}
|
|
{...TIER[cancelTier]}
|
|
/>
|
|
<ButtonWithSnackbar
|
|
text={"Calibrate"}
|
|
path={"/pedestal"}
|
|
disabled={!pedestalActive}
|
|
{...(pedestalActive ? TIER.active : TIER.off)}
|
|
/>
|
|
<ButtonWithSnackbar
|
|
text={"Initialize"}
|
|
path={"/initialize"}
|
|
{...TIER[initTier]}
|
|
/>
|
|
</Stack>
|
|
</Toolbar>
|
|
</AppBar>
|
|
}
|
|
|
|
export default memo(StatusBar);
|