From 5e002def0a6a5ecf7a7012c3e5c075ed0e5bfe20 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Sun, 11 Sep 2022 07:11:17 +0200 Subject: [PATCH] Cleanup and shift FilterRanges to configuration --- web/frontend/src/filters/Cluster.svelte | 2 +- web/frontend/src/filters/Resources.svelte | 8 +++++--- web/frontend/src/utils.js | 11 +++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/web/frontend/src/filters/Cluster.svelte b/web/frontend/src/filters/Cluster.svelte index 83c4d91..2740b74 100644 --- a/web/frontend/src/filters/Cluster.svelte +++ b/web/frontend/src/filters/Cluster.svelte @@ -38,7 +38,7 @@ {cluster.name} {/each} - + {/if} {#if $initialized && pendingCluster != null}
diff --git a/web/frontend/src/filters/Resources.svelte b/web/frontend/src/filters/Resources.svelte index 4f895b5..8cad9ee 100644 --- a/web/frontend/src/filters/Resources.svelte +++ b/web/frontend/src/filters/Resources.svelte @@ -4,6 +4,7 @@ import DoubleRangeSlider from './DoubleRangeSlider.svelte' const clusters = getContext('clusters'), + ccconfig = getContext('cc-config'), initialized = getContext('initialized'), dispatch = createEventDispatcher() @@ -26,16 +27,17 @@ $: { if ($initialized) { if (cluster != null) { - const { filterRanges, subClusters } = clusters.find(c => c.name == cluster) + const { subClusters } = clusters.find(c => c.name == cluster) + const { filterRanges } = ccconfig.clusters.find(c => c.name == cluster) minNumNodes = filterRanges.numNodes.from maxNumNodes = filterRanges.numNodes.to maxNumAccelerators = findMaxNumAccels([{ subClusters }]) } else if (clusters.length > 0) { - const { filterRanges } = clusters[0] + const { filterRanges } = ccconfig.clusters[0] minNumNodes = filterRanges.numNodes.from maxNumNodes = filterRanges.numNodes.to maxNumAccelerators = findMaxNumAccels(clusters) - for (let cluster of clusters) { + for (let cluster of ccconfig.clusters) { const { filterRanges } = cluster minNumNodes = Math.min(minNumNodes, filterRanges.numNodes.from) maxNumNodes = Math.max(maxNumNodes, filterRanges.numNodes.to) diff --git a/web/frontend/src/utils.js b/web/frontend/src/utils.js index da5e471..f306249 100644 --- a/web/frontend/src/utils.js +++ b/web/frontend/src/utils.js @@ -9,7 +9,7 @@ import { readable } from 'svelte/store' * * It does several things: * - Initialize the GraphQL client - * - Creates a readable store 'initialization' which indicates when the values below can be used. + * - Creates a readable store 'initialization' which indicates when the values below can be used. * - Adds 'tags' to the context (list of all tags) * - Adds 'clusters' to the context (object with cluster names as keys) * - Adds 'metrics' to the context, a function that takes a cluster and metric name and returns the MetricConfig (or undefined) @@ -43,11 +43,6 @@ export function init(extraInitQuery = '') { aggregation, subClusters { name, peak, normal, caution, alert } } - filterRanges { - duration { from, to } - numNodes { from, to } - startTime { from, to } - } partitions subClusters { name, processorType @@ -104,7 +99,7 @@ export function init(extraInitQuery = '') { for (let tag of data.tags) tags.push(tag) - + for (let cluster of data.clusters) clusters.push(cluster) @@ -241,7 +236,7 @@ export async function fetchMetrics(job, metrics, scopes) { if (res.status != 200) { return { error: { status: res.status, message: await res.text() } } } - + return await res.json() } catch (e) { return { error: e }