simplify plotGrid, add cancel to metricSelect, improve metricPlot render logic

This commit is contained in:
Christoph Kluge
2024-10-16 12:41:15 +02:00
parent 673fdc443c
commit 3dfeabcec6
13 changed files with 90 additions and 154 deletions

View File

@@ -4,7 +4,6 @@
Properties:
- `itemsPerRow Number`: Elements to render per row
- `items [Any]`: List of plot components to render
- `renderFor String`: If 'job', filter disabled metrics
-->
<script>
@@ -15,43 +14,13 @@
export let itemsPerRow
export let items
export let renderFor
let rows = [];
const isPlaceholder = x => x._is_placeholder === true;
function tile(items, itemsPerRow) {
const rows = []
for (let ri = 0; ri < items?.length; ri += itemsPerRow) {
const row = []
for (let ci = 0; ci < itemsPerRow; ci += 1) {
if (ri + ci < items?.length)
row.push(items[ri + ci])
else
row.push({ _is_placeholder: true, ri, ci })
}
rows.push(row)
}
return rows
}
$: if (renderFor === 'job') {
rows = tile(items.filter(item => item.disabled === false), itemsPerRow)
} else {
rows = tile(items, itemsPerRow)
}
</script>
{#each rows as row}
<Row cols={{ xs: 1, sm: 1, md: 2, lg: itemsPerRow}}>
{#each row as item (item)}
<Col class="px-1">
{#if !isPlaceholder(item)}
<slot item={item}/>
{/if}
</Col>
{/each}
</Row>
{/each}
<Row cols={{ xs: 1, sm: 2, md: 3, lg: itemsPerRow}}>
{#each items as item}
<Col class="px-1">
<slot {item}/>
</Col>
{/each}
</Row>