add link from alarm summary to installation itself

This commit is contained in:
Yinyin Liu 2026-06-09 10:51:18 +02:00
parent aefeb75641
commit bf0aa4d959
1 changed files with 35 additions and 12 deletions

View File

@ -270,6 +270,39 @@ function Report() {
});
};
// Deep-link to an installation's Log tab (mirrors the Ticket detail navigation).
const openInstallationLog = (product: number, installationId: number) => {
const productRoutes: Record<number, string> = {
0: routes.installations,
1: routes.salidomo_installations,
2: routes.sodiohome_installations,
3: routes.sodistore_installations,
4: routes.sodistoregrid_installations,
5: routes.sodistorepro_installations
};
const prefix = productRoutes[product] ?? routes.installations;
navigate(prefix + routes.list + routes.installation + installationId + '/' + routes.log);
};
const installationCell = (name: string, product: number, installationId: number) => (
<TableCell>
<Typography
variant="body2"
onClick={() => openInstallationLog(product, installationId)}
sx={{
color: 'primary.main',
cursor: 'pointer',
'&:hover': { textDecoration: 'underline' }
}}
>
{name}
</Typography>
<Typography variant="caption" color="text.secondary">
{productLabel(product)}
</Typography>
</TableCell>
);
const severityIcon = (sev: 'error' | 'warning') =>
sev === 'error' ? (
<ErrorIcon color="error" />
@ -640,12 +673,7 @@ function Report() {
)}
</IconButton>
</TableCell>
<TableCell>
<Typography variant="body2">{g.installationName}</Typography>
<Typography variant="caption" color="text.secondary">
{productLabel(g.product)}
</Typography>
</TableCell>
{installationCell(g.installationName, g.product, g.installationId)}
<TableCell>{deviceLabel(g.device)}</TableCell>
<TableCell>{alarmDisplayName(g.description)}</TableCell>
<TableCell align="center">{severityIcon(g.severity)}</TableCell>
@ -682,12 +710,7 @@ function Report() {
))
: rawSorted.map((r) => (
<TableRow hover key={r.id}>
<TableCell>
<Typography variant="body2">{r.installationName}</Typography>
<Typography variant="caption" color="text.secondary">
{productLabel(r.product)}
</Typography>
</TableCell>
{installationCell(r.installationName, r.product, r.installationId)}
<TableCell>{deviceLabel(r.device)}</TableCell>
<TableCell>{alarmDisplayName(r.description)}</TableCell>
<TableCell align="center">{severityIcon(r.severity)}</TableCell>