From 2f6e5a7648c61bf24f2e3b5c92e5684fc8e24513 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Mon, 14 Oct 2024 11:55:59 +0200 Subject: [PATCH] Move common logic into systems view again - adds backend log if subcluster for node not configured --- internal/graph/schema.resolvers.go | 7 +- web/frontend/src/Systems.root.svelte | 245 +++++++++++++++- web/frontend/src/generic/PlotGrid.svelte | 4 +- .../src/generic/plots/MetricPlot.svelte | 2 +- web/frontend/src/generic/utils.js | 15 +- web/frontend/src/systems/NodeList.svelte | 271 ++++-------------- web/frontend/src/systems/NodeOverview.svelte | 243 +++------------- .../src/systems/nodelist/NodeInfo.svelte | 2 +- .../src/systems/nodelist/NodeListRow.svelte | 6 +- 9 files changed, 350 insertions(+), 445 deletions(-) diff --git a/internal/graph/schema.resolvers.go b/internal/graph/schema.resolvers.go index 58d664b..73090a8 100644 --- a/internal/graph/schema.resolvers.go +++ b/internal/graph/schema.resolvers.go @@ -438,7 +438,7 @@ func (r *queryResolver) NodeMetrics(ctx context.Context, cluster string, nodes [ data, err := metricDataDispatcher.LoadNodeData(cluster, metrics, nodes, scopes, from, to, ctx) if err != nil { - log.Warn("Error while loading node data") + log.Warn("error while loading node data") return nil, err } @@ -448,7 +448,10 @@ func (r *queryResolver) NodeMetrics(ctx context.Context, cluster string, nodes [ Host: hostname, Metrics: make([]*model.JobMetricWithName, 0, len(metrics)*len(scopes)), } - host.SubCluster, _ = archive.GetSubClusterByNode(cluster, hostname) + host.SubCluster, err = archive.GetSubClusterByNode(cluster, hostname) + if err != nil { + log.Warnf("error in nodeMetrics resolver: %s", err) + } for metric, scopedMetrics := range metrics { for _, scopedMetric := range scopedMetrics { diff --git a/web/frontend/src/Systems.root.svelte b/web/frontend/src/Systems.root.svelte index baef2d0..8ff25c8 100644 --- a/web/frontend/src/Systems.root.svelte +++ b/web/frontend/src/Systems.root.svelte @@ -9,36 +9,259 @@ --> -{#if displayType === 'OVERVIEW'} - -{:else if displayType === 'LIST'} - -{:else} - - - - Unknown displayList type! - - + + + {#if $initq.data} + + {#if !displayNodeOverview} + + + + Metrics + + + + {/if} + + + + + Find Node(s) + + + + + + + + + {#if displayNodeOverview} + + + + Metric + + {#each systemMetrics as metric} + + {/each} + + + + {/if} + + + { + const diff = Date.now() - to; + from = new Date(from.getTime() + diff); + to = new Date(to.getTime() + diff); + }} + /> + + {/if} + + +{#if displayType !== "OVERVIEW" && displayType !== "LIST"} + + + Unknown displayList type! + + +{:else if $nodesQuery.error} + + + {$nodesQuery.error.message} + + +{:else if $nodesQuery.fetching } + + + + + +{:else if $initialized && $nodesQuery?.data} + {#if displayNodeOverview} + + + + {:else} + + + + + + + + + {/if} {/if} diff --git a/web/frontend/src/generic/PlotGrid.svelte b/web/frontend/src/generic/PlotGrid.svelte index 3bbee55..a56ffef 100644 --- a/web/frontend/src/generic/PlotGrid.svelte +++ b/web/frontend/src/generic/PlotGrid.svelte @@ -22,10 +22,10 @@ function tile(items, itemsPerRow) { const rows = [] - for (let ri = 0; ri < items.length; ri += itemsPerRow) { + for (let ri = 0; ri < items?.length; ri += itemsPerRow) { const row = [] for (let ci = 0; ci < itemsPerRow; ci += 1) { - if (ri + ci < items.length) + if (ri + ci < items?.length) row.push(items[ri + ci]) else row.push({ _is_placeholder: true, ri, ci }) diff --git a/web/frontend/src/generic/plots/MetricPlot.svelte b/web/frontend/src/generic/plots/MetricPlot.svelte index 09f313c..bf3dd45 100644 --- a/web/frontend/src/generic/plots/MetricPlot.svelte +++ b/web/frontend/src/generic/plots/MetricPlot.svelte @@ -227,7 +227,7 @@ function update(u) { const { left, top } = u.cursor; - const width = u.over.querySelector(".u-legend").offsetWidth; + const width = u?.over?.querySelector(".u-legend")?.offsetWidth ? u.over.querySelector(".u-legend").offsetWidth : 0; legendEl.style.transform = "translate(" + (left - width - 15) + "px, " + (top + 15) + "px)"; } diff --git a/web/frontend/src/generic/utils.js b/web/frontend/src/generic/utils.js index 57248fc..0e06c0f 100644 --- a/web/frontend/src/generic/utils.js +++ b/web/frontend/src/generic/utils.js @@ -303,8 +303,19 @@ export function stickyHeader(datatableHeaderSelector, updatePading) { export function checkMetricDisabled(m, c, s) { // [m]etric, [c]luster, [s]ubcluster const metrics = getContext("globalMetrics"); - const result = metrics?.find((gm) => gm.name === m)?.availability?.find((av) => av.cluster === c)?.subClusters?.includes(s) - return !result + const available = metrics?.find((gm) => gm.name === m)?.availability?.find((av) => av.cluster === c)?.subClusters?.includes(s) + // Return inverse logic + return !available +} + +export function checkMetricsDisabled(ma, c, s) { // [m]etric[a]rray, [c]luster, [s]ubcluster + let result = {}; + const metrics = getContext("globalMetrics"); + ma.forEach((m) => { + // Return named inverse logic: !available + result[m] = !(metrics?.find((gm) => gm.name === m)?.availability?.find((av) => av.cluster === c)?.subClusters?.includes(s)) + }); + return result } export function getStatsItems() { diff --git a/web/frontend/src/systems/NodeList.svelte b/web/frontend/src/systems/NodeList.svelte index a5538e9..935a068 100644 --- a/web/frontend/src/systems/NodeList.svelte +++ b/web/frontend/src/systems/NodeList.svelte @@ -1,5 +1,10 @@ -
+
- {#if showFootprint} - - {/if} - {#each metrics as metric (metric)} + + {#each selectedMetrics as metric (metric)} {/each} - {#if $jobsStore.error} - - - + {#each nodes as node (node)} + {node} + {:else} - {#each jobs as job (job)} - - {:else} - - - - {/each} - {/if} - {#if $jobsStore.fetching || !$jobsStore.data} - + - {/if} + {/each}
- Job Info + Node Info - Job Footprint - - {metric} - {#if $initialized} - ({getUnit(metric)}) - {/if} + {metric} ({systemUnits[metric]})
-

{$jobsStore.error.message}

-
No jobs found
-
- -
-
No nodes found
-{#if usePaging} - { - if (detail.itemsPerPage != itemsPerPage) { - updateConfiguration(detail.itemsPerPage.toString(), detail.page); - } else { - jobs = [] - paging = { itemsPerPage: detail.itemsPerPage, page: detail.page }; - } - }} - /> -{/if} -