fix(web): adapt metric plots to policy-based resample config

The backend resample config changed from {trigger, resolutions[]} to a
policy/targetPoints model, but several components still spread
resampleConfig.resolutions, throwing "resolutions is not iterable" and
breaking the job list render. Default the initial resolution to null (the
backend resolves it from the configured policy; zoom overrides it) and
drop the now-obsolete resolution selector and admin display fields.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 27516ce259fd
This commit is contained in:
2026-06-18 10:29:12 +02:00
parent d89f526eb2
commit 6f1c36099b
4 changed files with 11 additions and 25 deletions

View File

@@ -70,8 +70,6 @@
const ccconfig = $derived(thisInit ? getContext("cc-config") : null); const ccconfig = $derived(thisInit ? getContext("cc-config") : null);
const globalMetrics = $derived(thisInit ? getContext("globalMetrics") : null); const globalMetrics = $derived(thisInit ? getContext("globalMetrics") : null);
const resampleConfig = $derived(thisInit ? getContext("resampling") : null); const resampleConfig = $derived(thisInit ? getContext("resampling") : null);
const resampleResolutions = $derived(resampleConfig ? [...resampleConfig.resolutions] : []);
const resampleDefault = $derived(resampleConfig ? Math.max(...resampleConfig.resolutions) : 0);
const displayNodeOverview = $derived((displayType === 'OVERVIEW')); const displayNodeOverview = $derived((displayType === 'OVERVIEW'));
const systemMetrics = $derived(globalMetrics ? [...globalMetrics.filter((gm) => gm?.availability.find((av) => av.cluster == cluster))] : []); const systemMetrics = $derived(globalMetrics ? [...globalMetrics.filter((gm) => gm?.availability.find((av) => av.cluster == cluster))] : []);
@@ -85,7 +83,8 @@
return {...pendingUnits}; return {...pendingUnits};
}); });
let selectedResolution = $derived(resampleDefault); // null lets the backend resolve the resolution from the configured resample policy.
let selectedResolution = $state(null);
let to = $derived(presetTo ? presetTo : new Date(Date.now())); let to = $derived(presetTo ? presetTo : new Date(Date.now()));
let from = $derived(presetFrom ? presetFrom : new Date(nowDate.setHours(nowDate.getHours() - 4))); let from = $derived(presetFrom ? presetFrom : new Date(nowDate.setHours(nowDate.getHours() - 4)));
@@ -159,7 +158,7 @@
</script> </script>
<!-- ROW1: Tools--> <!-- ROW1: Tools-->
<Row cols={{ xs: 2, lg: !displayNodeOverview ? (resampleConfig ? 6 : 5) : 5 }} class="mb-3"> <Row cols={{ xs: 2, lg: 5 }} class="mb-3">
{#if thisInit} {#if thisInit}
<!-- List Metric Select Col--> <!-- List Metric Select Col-->
{#if !displayNodeOverview} {#if !displayNodeOverview}
@@ -176,21 +175,6 @@
</Button> </Button>
</InputGroup> </InputGroup>
</Col> </Col>
{#if resampleConfig}
<Col>
<InputGroup>
<InputGroupText><Icon name="plus-slash-minus" /></InputGroupText>
<InputGroupText>Resolution</InputGroupText>
<Input type="select" bind:value={selectedResolution}>
{#each resampleResolutions as res}
<option value={res}
>{res} sec</option
>
{/each}
</Input>
</InputGroup>
</Col>
{/if}
{/if} {/if}
<!-- Node Col--> <!-- Node Col-->
<Col class="mt-2 mt-lg-0"> <Col class="mt-2 mt-lg-0">

View File

@@ -77,8 +77,8 @@
<Card class="h-100"> <Card class="h-100">
<CardBody> <CardBody>
<CardTitle class="mb-3">Metric Plot Resampling Info</CardTitle> <CardTitle class="mb-3">Metric Plot Resampling Info</CardTitle>
<p>Triggered at {resampleConfig.trigger} datapoints.</p> <p>Resampling is enabled.</p>
<p>Configured resolutions: {resampleConfig.resolutions}</p> <p>Target data points per plot: {resampleConfig.targetPoints}</p>
</CardBody> </CardBody>
</Card> </Card>
</Col> </Col>

View File

@@ -84,7 +84,6 @@
let thresholdStates = $state({}); let thresholdStates = $state({});
/* Derived */ /* Derived */
const resampleDefault = $derived(resampleConfig ? Math.max(...resampleConfig.resolutions) : 0);
const jobId = $derived(job.id); const jobId = $derived(job.id);
const scopes = $derived.by(() => { const scopes = $derived.by(() => {
if (job.numNodes == 1) { if (job.numNodes == 1) {
@@ -95,7 +94,9 @@
}; };
}); });
let selectedResolution = $derived(resampleDefault); // null lets the backend resolve the resolution from the configured resample
// policy; zoom interactions override it with an explicit value.
let selectedResolution = $state(null);
let isSelected = $derived(previousSelect); let isSelected = $derived(previousSelect);
let metricsQuery = $derived(queryStore({ let metricsQuery = $derived(queryStore({
client: client, client: client,

View File

@@ -44,7 +44,6 @@
const client = getContextClient(); const client = getContextClient();
const statsPattern = /(.*)-stat$/; const statsPattern = /(.*)-stat$/;
const resampleConfig = getContext("resampling") || null; const resampleConfig = getContext("resampling") || null;
const resampleDefault = resampleConfig ? Math.max(...resampleConfig.resolutions) : 0;
const subQuery = gql` const subQuery = gql`
query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!, $selectedResolution: Int) { query ($dbid: ID!, $selectedMetrics: [String!]!, $selectedScopes: [MetricScope!]!, $selectedResolution: Int) {
singleUpdate: jobMetrics(id: $dbid, metrics: $selectedMetrics, scopes: $selectedScopes, resolution: $selectedResolution) { singleUpdate: jobMetrics(id: $dbid, metrics: $selectedMetrics, scopes: $selectedScopes, resolution: $selectedResolution) {
@@ -78,7 +77,9 @@
`; `;
/* State Init */ /* State Init */
let selectedResolution = $state(resampleDefault); // null lets the backend resolve the resolution from the configured resample
// policy; zoom interactions override it with an explicit value.
let selectedResolution = $state(null);
let selectedHost = $state(null); let selectedHost = $state(null);
let zoomState = $state(null); let zoomState = $state(null);
let thresholdState = $state(null); let thresholdState = $state(null);