mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-01 11:13:50 +02:00
Migrate plotgrid, adapt parent components with new snippets
This commit is contained in:
parent
79a6c9e90d
commit
db5f6c7540
@ -562,8 +562,19 @@
|
|||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
|
{#snippet histoGridContent(item)}
|
||||||
|
<Histogram
|
||||||
|
data={convert2uplot(item.bins)}
|
||||||
|
usesBins={true}
|
||||||
|
title="Average Distribution of '{item.metric}'"
|
||||||
|
xlabel={`${item.metric} bin maximum [${metricUnits[item.metric]}]`}
|
||||||
|
xunit={`${metricUnits[item.metric]}`}
|
||||||
|
ylabel="Normalized Hours"
|
||||||
|
yunit="Hours"
|
||||||
|
/>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
<PlotGrid
|
<PlotGrid
|
||||||
let:item
|
|
||||||
items={metricsInHistograms.map((metric) => ({
|
items={metricsInHistograms.map((metric) => ({
|
||||||
metric,
|
metric,
|
||||||
...binsFromFootprint(
|
...binsFromFootprint(
|
||||||
@ -576,17 +587,8 @@
|
|||||||
),
|
),
|
||||||
}))}
|
}))}
|
||||||
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
||||||
>
|
gridContent={histoGridContent}
|
||||||
<Histogram
|
/>
|
||||||
data={convert2uplot(item.bins)}
|
|
||||||
usesBins={true}
|
|
||||||
title="Average Distribution of '{item.metric}'"
|
|
||||||
xlabel={`${item.metric} bin maximum [${metricUnits[item.metric]}]`}
|
|
||||||
xunit={`${metricUnits[item.metric]}`}
|
|
||||||
ylabel="Normalized Hours"
|
|
||||||
yunit="Hours"
|
|
||||||
/>
|
|
||||||
</PlotGrid>
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<br />
|
<br />
|
||||||
@ -604,9 +606,19 @@
|
|||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
|
{#snippet metricsGridContent(item)}
|
||||||
|
<ScatterPlot
|
||||||
|
height={250}
|
||||||
|
color={"rgba(0, 102, 204, 0.33)"}
|
||||||
|
xLabel={`${item.m1} [${metricUnits[item.m1]}]`}
|
||||||
|
yLabel={`${item.m2} [${metricUnits[item.m2]}]`}
|
||||||
|
X={item.f1}
|
||||||
|
Y={item.f2}
|
||||||
|
S={$footprintsQuery.data.footprints.timeWeights.nodeHours}
|
||||||
|
/>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
<PlotGrid
|
<PlotGrid
|
||||||
let:item
|
|
||||||
let:width
|
|
||||||
items={metricsInScatterplots.map(([m1, m2]) => ({
|
items={metricsInScatterplots.map(([m1, m2]) => ({
|
||||||
m1,
|
m1,
|
||||||
f1: $footprintsQuery.data.footprints.metrics.find(
|
f1: $footprintsQuery.data.footprints.metrics.find(
|
||||||
@ -618,18 +630,8 @@
|
|||||||
).data,
|
).data,
|
||||||
}))}
|
}))}
|
||||||
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
||||||
>
|
gridContent={metricsGridContent}
|
||||||
<ScatterPlot
|
/>
|
||||||
{width}
|
|
||||||
height={250}
|
|
||||||
color={"rgba(0, 102, 204, 0.33)"}
|
|
||||||
xLabel={`${item.m1} [${metricUnits[item.m1]}]`}
|
|
||||||
yLabel={`${item.m2} [${metricUnits[item.m2]}]`}
|
|
||||||
X={item.f1}
|
|
||||||
Y={item.f2}
|
|
||||||
S={$footprintsQuery.data.footprints.timeWeights.nodeHours}
|
|
||||||
/>
|
|
||||||
</PlotGrid>
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -334,14 +334,8 @@
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{:else if $initq?.data && $jobMetrics?.data?.jobMetrics}
|
{:else if $initq?.data && $jobMetrics?.data?.jobMetrics}
|
||||||
<PlotGrid
|
<!-- Note: Ignore 'Expected If ...' Error in IDE -->
|
||||||
let:item
|
{#snippet gridContent(item)}
|
||||||
items={orderAndMap(
|
|
||||||
groupByScope($jobMetrics.data.jobMetrics),
|
|
||||||
selectedMetrics,
|
|
||||||
)}
|
|
||||||
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
|
||||||
>
|
|
||||||
{#if item.data}
|
{#if item.data}
|
||||||
<Metric
|
<Metric
|
||||||
bind:this={plots[item.metric]}
|
bind:this={plots[item.metric]}
|
||||||
@ -373,7 +367,16 @@
|
|||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
{/if}
|
{/if}
|
||||||
</PlotGrid>
|
{/snippet}
|
||||||
|
|
||||||
|
<PlotGrid
|
||||||
|
items={orderAndMap(
|
||||||
|
groupByScope($jobMetrics.data.jobMetrics),
|
||||||
|
selectedMetrics,
|
||||||
|
)}
|
||||||
|
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
||||||
|
{gridContent}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -204,20 +204,7 @@
|
|||||||
{:else if $nodeMetricsData.fetching || $initq.fetching}
|
{:else if $nodeMetricsData.fetching || $initq.fetching}
|
||||||
<Spinner />
|
<Spinner />
|
||||||
{:else}
|
{:else}
|
||||||
<PlotGrid
|
{#snippet gridContent(item)}
|
||||||
let:item
|
|
||||||
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
|
||||||
items={$nodeMetricsData.data.nodeMetrics[0].metrics
|
|
||||||
.map((m) => ({
|
|
||||||
...m,
|
|
||||||
disabled: checkMetricDisabled(
|
|
||||||
m.name,
|
|
||||||
cluster,
|
|
||||||
$nodeMetricsData.data.nodeMetrics[0].subCluster,
|
|
||||||
),
|
|
||||||
}))
|
|
||||||
.sort((a, b) => a.name.localeCompare(b.name))}
|
|
||||||
>
|
|
||||||
<h4 style="text-align: center; padding-top:15px;">
|
<h4 style="text-align: center; padding-top:15px;">
|
||||||
{item.name}
|
{item.name}
|
||||||
{systemUnits[item.name] ? "(" + systemUnits[item.name] + ")" : ""}
|
{systemUnits[item.name] ? "(" + systemUnits[item.name] + ")" : ""}
|
||||||
@ -246,7 +233,22 @@
|
|||||||
>No dataset returned for <code>{item.name}</code></Card
|
>No dataset returned for <code>{item.name}</code></Card
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
</PlotGrid>
|
{/snippet}
|
||||||
|
|
||||||
|
<PlotGrid
|
||||||
|
items={$nodeMetricsData.data.nodeMetrics[0].metrics
|
||||||
|
.map((m) => ({
|
||||||
|
...m,
|
||||||
|
disabled: checkMetricDisabled(
|
||||||
|
m.name,
|
||||||
|
cluster,
|
||||||
|
$nodeMetricsData.data.nodeMetrics[0].subCluster,
|
||||||
|
),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name))}
|
||||||
|
itemsPerRow={ccconfig.plot_view_plotsPerRow}
|
||||||
|
{gridContent}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -676,22 +676,24 @@
|
|||||||
<!-- Selectable Stats as Histograms : Average Values of Running Jobs -->
|
<!-- Selectable Stats as Histograms : Average Values of Running Jobs -->
|
||||||
|
|
||||||
{#if selectedHistograms}
|
{#if selectedHistograms}
|
||||||
|
{#snippet gridContent(item)}
|
||||||
|
<Histogram
|
||||||
|
data={convert2uplot(item.data)}
|
||||||
|
usesBins={true}
|
||||||
|
title="Distribution of '{item.metric}' averages"
|
||||||
|
xlabel={`${item.metric} bin maximum ${item?.unit ? `[${item.unit}]` : ``}`}
|
||||||
|
xunit={item.unit}
|
||||||
|
ylabel="Number of Jobs"
|
||||||
|
yunit="Jobs"
|
||||||
|
/>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
{#key $mainQuery.data.stats[0].histMetrics}
|
{#key $mainQuery.data.stats[0].histMetrics}
|
||||||
<PlotGrid
|
<PlotGrid
|
||||||
let:item
|
|
||||||
items={$mainQuery.data.stats[0].histMetrics}
|
items={$mainQuery.data.stats[0].histMetrics}
|
||||||
itemsPerRow={2}
|
itemsPerRow={2}
|
||||||
>
|
{gridContent}
|
||||||
<Histogram
|
/>
|
||||||
data={convert2uplot(item.data)}
|
|
||||||
usesBins={true}
|
|
||||||
title="Distribution of '{item.metric}' averages"
|
|
||||||
xlabel={`${item.metric} bin maximum ${item?.unit ? `[${item.unit}]` : ``}`}
|
|
||||||
xunit={item.unit}
|
|
||||||
ylabel="Number of Jobs"
|
|
||||||
yunit="Jobs"
|
|
||||||
/>
|
|
||||||
</PlotGrid>
|
|
||||||
{/key}
|
{/key}
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -335,22 +335,24 @@
|
|||||||
</Row>
|
</Row>
|
||||||
{:else}
|
{:else}
|
||||||
<hr class="my-2"/>
|
<hr class="my-2"/>
|
||||||
|
{#snippet gridContent(item)}
|
||||||
|
<Histogram
|
||||||
|
data={convert2uplot(item.data)}
|
||||||
|
title="Distribution of '{item.metric} ({item.stat})' footprints"
|
||||||
|
xlabel={`${item.metric} bin maximum ${item?.unit ? `[${item.unit}]` : ``}`}
|
||||||
|
xunit={item.unit}
|
||||||
|
ylabel="Number of Jobs"
|
||||||
|
yunit="Jobs"
|
||||||
|
usesBins
|
||||||
|
/>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
{#key $stats.data.jobsStatistics[0].histMetrics}
|
{#key $stats.data.jobsStatistics[0].histMetrics}
|
||||||
<PlotGrid
|
<PlotGrid
|
||||||
let:item
|
|
||||||
items={$stats.data.jobsStatistics[0].histMetrics}
|
items={$stats.data.jobsStatistics[0].histMetrics}
|
||||||
itemsPerRow={3}
|
itemsPerRow={3}
|
||||||
>
|
{gridContent}
|
||||||
<Histogram
|
/>
|
||||||
data={convert2uplot(item.data)}
|
|
||||||
title="Distribution of '{item.metric} ({item.stat})' footprints"
|
|
||||||
xlabel={`${item.metric} bin maximum ${item?.unit ? `[${item.unit}]` : ``}`}
|
|
||||||
xunit={item.unit}
|
|
||||||
ylabel="Number of Jobs"
|
|
||||||
yunit="Jobs"
|
|
||||||
usesBins
|
|
||||||
/>
|
|
||||||
</PlotGrid>
|
|
||||||
{/key}
|
{/key}
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -12,26 +12,19 @@
|
|||||||
Col,
|
Col,
|
||||||
} from "@sveltestrap/sveltestrap";
|
} from "@sveltestrap/sveltestrap";
|
||||||
|
|
||||||
export let itemsPerRow
|
/* Svelte 5 Props */
|
||||||
export let items
|
let {
|
||||||
|
items,
|
||||||
/* Migtation Notes
|
itemsPerRow,
|
||||||
* Requirements
|
gridContent
|
||||||
* - Parent Components must be already Migrated
|
} = $props();
|
||||||
* - TODO: Job.root.svelte, Node.root.svelte
|
|
||||||
* - DONE: Analysis, Status, User
|
|
||||||
*
|
|
||||||
* How-To
|
|
||||||
* - Define "Plot-Slotcode" as SV5 Snippet with argument "item" in parent (!)
|
|
||||||
* - Pass new snippet as argument/prop to here
|
|
||||||
* - @render snippet in items-loop with argument == item
|
|
||||||
*/
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Row cols={{ xs: 1, sm: 2, md: 3, lg: itemsPerRow}}>
|
<Row cols={{ xs: 1, sm: 2, md: 3, lg: itemsPerRow}}>
|
||||||
{#each items as item}
|
{#each items as item}
|
||||||
<Col class="px-1">
|
<Col class="px-1">
|
||||||
<slot {item}/>
|
<!-- Note: Ignore '@' Error in IDE -->
|
||||||
|
{@render gridContent(item)}
|
||||||
</Col>
|
</Col>
|
||||||
{/each}
|
{/each}
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -182,6 +182,6 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="cc-plot">
|
<div class="cc-plot" bind:clientWidth={width}>
|
||||||
<canvas bind:this={canvasElement} width="{width}" height="{height}"></canvas>
|
<canvas bind:this={canvasElement} {width} {height}></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user