Fix job view scope dropdown data load

This commit is contained in:
Christoph Kluge 2023-06-13 16:42:32 +02:00
parent 8aa7f4eb07
commit cdd25eaa15

View File

@ -18,9 +18,9 @@
let selectedHost = null, plot, fetching = false, error = null let selectedHost = null, plot, fetching = false, error = null
let selectedScope = minScope(scopes) let selectedScope = minScope(scopes)
let selectedScopeIndex = scopes.findIndex(s => s == selectedScope)
$: avaliableScopes = scopes $: availableScopes = scopes
$: selectedScopeIndex = scopes.findIndex(s => s == selectedScope)
$: data = rawData[selectedScopeIndex] $: data = rawData[selectedScopeIndex]
$: series = data?.series.filter(series => selectedHost == null || series.hostname == selectedHost) $: series = data?.series.filter(series => selectedHost == null || series.hostname == selectedHost)
@ -43,11 +43,11 @@
for (let jm of response.data.jobMetrics) { for (let jm of response.data.jobMetrics) {
if (jm.scope != "node") { if (jm.scope != "node") {
scopes.push(jm.metric) scopes = [...scopes, jm.scope]
rawData.push(jm.metric)
selectedScope = jm.scope selectedScope = jm.scope
selectedScopeIndex = scopes.findIndex(s => s == jm.scope)
dispatch('more-loaded', jm) dispatch('more-loaded', jm)
if (!avaliableScopes.includes(selectedScope))
avaliableScopes = [...avaliableScopes, selectedScope]
} }
} }
} }
@ -59,11 +59,11 @@
{metricName} ({(metricConfig?.unit?.prefix ? metricConfig.unit.prefix : '') + {metricName} ({(metricConfig?.unit?.prefix ? metricConfig.unit.prefix : '') +
(metricConfig?.unit?.base ? metricConfig.unit.base : '')}) (metricConfig?.unit?.base ? metricConfig.unit.base : '')})
</InputGroupText> </InputGroupText>
<select class="form-select" bind:value={selectedScope}> <select id="scopeselector" class="form-select" bind:value={selectedScope}>
{#each avaliableScopes as scope} {#each availableScopes as scope}
<option value={scope}>{scope}</option> <option value={scope}>{scope}</option>
{/each} {/each}
{#if avaliableScopes.length == 1 && metricConfig?.scope != "node"} {#if availableScopes.length == 1 && metricConfig?.scope != "node"}
<option value={"load-more"}>Load more...</option> <option value={"load-more"}>Load more...</option>
{/if} {/if}
</select> </select>