checkers: show children checkers on domain page and hide scheduling for non-domain checkers

Add a separate section on the domain checks page to display zone and
service-level checkers that can be configured but won't produce results
at the domain scope. Hide the scheduling and rules cards when configuring
a non-domain checker from the domain context.
This commit is contained in:
nemunaire 2026-04-05 08:59:13 +07:00
commit 9057cea94f
4 changed files with 33 additions and 23 deletions

View file

@ -50,9 +50,10 @@
domainName: string;
editableGroups: (status: any) => { label: string; opts: any[] }[];
readOnlyGroups: (status: any) => { key: string; label: string; opts: any[] }[];
showSchedule?: boolean;
}
let { scope, checksBase, checkerId, domainName, editableGroups, readOnlyGroups }: Props = $props();
let { scope, checksBase, checkerId, domainName, editableGroups, readOnlyGroups, showSchedule = true }: Props = $props();
let checkStatusPromise = $derived(getCheckStatus(checkerId));
let checkOptionsPromise = $derived(getScopedCheckOptions(scope, checkerId));
@ -145,6 +146,7 @@
{@const editable = editableGroups(status)}
{@const readOnly = readOnlyGroups(status)}
<Row class="mb-4">
{#if showSchedule}
<Col md={6}>
<CheckerScheduleCard {scope} {checkerId} bind:plan />
@ -159,6 +161,7 @@
/>
{/if}
</Col>
{/if}
<Col md={6}>
<CheckerOptionsPanel

View file

@ -22,15 +22,7 @@
-->
<script lang="ts">
import {
Alert,
Badge,
Card,
CardBody,
CardHeader,
Icon,
Table,
} from "@sveltestrap/sveltestrap";
import { Alert, Badge, Card, Icon, Table } from "@sveltestrap/sveltestrap";
import { t } from "$lib/translations";
import type { CheckerScope } from "$lib/api/checkers";
@ -63,6 +55,16 @@
([id, def]) => !configuredIds.has(id) && def.availability?.[filterAvailability],
);
}
function getChildrenCheckers(configuredIds: Set<string>): [string, any][] {
if (!$checkers) return [];
return Object.entries($checkers).filter(
([id, def]) =>
!configuredIds.has(id) &&
!def.availability?.[filterAvailability] &&
(def.availability?.applyToZone || def.availability?.applyToService),
);
}
</script>
<svelte:head>
@ -70,7 +72,7 @@
</svelte:head>
<div class="flex-fill mt-1 mb-5">
<PageTitle title={title} domain={domainName}></PageTitle>
<PageTitle {title} domain={domainName}></PageTitle>
{#await checkersPromise}
<Card body>
@ -159,18 +161,16 @@
{@const configuredIds = getConfiguredCheckerIds(checkerStatuses)}
{@const unconfigured = getUnconfiguredCheckers(configuredIds)}
{#if unconfigured.length > 0}
<Card>
<CardHeader>
<strong>{$t("checkers.other-checkers.title")}</strong>
</CardHeader>
<CardBody>
<p class="text-muted">{$t("checkers.other-checkers.description")}</p>
<CheckersAvailabilityTable
checkers={unconfigured}
basePath={checksBase}
/>
</CardBody>
</Card>
<h4 class="mt-4">{$t("checkers.other-checkers.title")}</h4>
<p class="text-muted">{$t("checkers.other-checkers.description")}</p>
<CheckersAvailabilityTable checkers={unconfigured} basePath={checksBase} />
{/if}
{@const children = getChildrenCheckers(configuredIds)}
{#if children.length > 0}
<h4 class="mt-4">{$t("checkers.children-checkers.title")}</h4>
<p class="text-muted">{$t("checkers.children-checkers.description")}</p>
<CheckersAvailabilityTable checkers={children} basePath={checksBase} />
{/if}
{:catch error}
<Alert color="danger">

View file

@ -672,6 +672,10 @@
"no-checkers": "No other checkers available.",
"configure": "Configure"
},
"children-checkers": {
"title": "Zone & service checkers",
"description": "These checkers apply to zones or individual services. You can configure them here, but results will only appear when running checks at the appropriate scope."
},
"schedule": {
"title": "Schedule",
"card-title": "Automatic scheduling",

View file

@ -27,11 +27,13 @@
import { t } from "$lib/translations";
import type { Domain } from "$lib/model/domain";
import { domainLink } from "$lib/stores/domains";
import { checkers } from "$lib/stores/checkers";
import CheckerConfigPage from "$lib/components/checkers/CheckerConfigPage.svelte";
let domain: Domain = $derived(page.data.domain);
let checkerId = $derived(page.params.checkerId!);
let checksBase = $derived(`/domains/${domainLink(domain.id)}/checks`);
let isDomainChecker = $derived(!!$checkers?.[checkerId]?.availability?.applyToDomain);
</script>
<CheckerConfigPage
@ -39,6 +41,7 @@
{checksBase}
{checkerId}
domainName={domain.domain}
showSchedule={isDomainChecker}
editableGroups={(status) => [
{
label: $t("checkers.option-groups.domain-settings"),