mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
Add more reactivity to metricSelection
This commit is contained in:
parent
483443afe6
commit
7fc6f6b0af
@ -25,18 +25,33 @@
|
|||||||
let unorderedMetrics = [...metrics]
|
let unorderedMetrics = [...metrics]
|
||||||
|
|
||||||
onInit(() => {
|
onInit(() => {
|
||||||
if (allMetrics == null) {
|
if (allMetrics == null) allMetrics = new Set()
|
||||||
allMetrics = new Set()
|
|
||||||
for (let c of clusters)
|
for (let c of clusters)
|
||||||
if (cluster == null || c.name == cluster)
|
for (let metric of c.metricConfig)
|
||||||
|
allMetrics.add(metric.name)
|
||||||
|
})
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (allMetrics != null) {
|
||||||
|
if (cluster == null) {
|
||||||
|
// console.log('Reset to full metric list')
|
||||||
|
for (let c of clusters)
|
||||||
for (let metric of c.metricConfig)
|
for (let metric of c.metricConfig)
|
||||||
allMetrics.add(metric.name)
|
allMetrics.add(metric.name)
|
||||||
}
|
} else {
|
||||||
|
// console.log('Recalculate available metrics for ' + cluster)
|
||||||
|
allMetrics.clear()
|
||||||
|
for (let c of clusters)
|
||||||
|
if (c.name == cluster)
|
||||||
|
for (let metric of c.metricConfig)
|
||||||
|
allMetrics.add(metric.name)
|
||||||
|
}
|
||||||
|
|
||||||
newMetricsOrder = [...allMetrics].filter(m => !metrics.includes(m))
|
newMetricsOrder = [...allMetrics].filter(m => !metrics.includes(m))
|
||||||
newMetricsOrder.unshift(...metrics.filter(m => allMetrics.has(m)))
|
newMetricsOrder.unshift(...metrics.filter(m => allMetrics.has(m)))
|
||||||
unorderedMetrics = unorderedMetrics.filter(m => allMetrics.has(m))
|
unorderedMetrics = unorderedMetrics.filter(m => allMetrics.has(m))
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const updateConfiguration = mutation({
|
const updateConfiguration = mutation({
|
||||||
query: `mutation($name: String!, $value: String!) {
|
query: `mutation($name: String!, $value: String!) {
|
||||||
@ -115,14 +130,15 @@
|
|||||||
<span style="float: right;">
|
<span style="float: right;">
|
||||||
{cluster == null ?
|
{cluster == null ?
|
||||||
clusters // No single cluster specified: List Clusters with Metric
|
clusters // No single cluster specified: List Clusters with Metric
|
||||||
.filter(cluster => cluster.metricConfig.find(m => m.name == metric) != null)
|
.filter(c => c.metricConfig.find(m => m.name == metric) != null)
|
||||||
.map(cluster => cluster.name).join(', ') :
|
.map(c => c.name).join(', ') :
|
||||||
clusters // Single cluster requested: List Subclusters with do not have metric remove flag
|
clusters // Single cluster requested: List Subclusters with do not have metric remove flag
|
||||||
.filter(cluster => cluster.metricConfig.find(m => m.name == metric) != null)
|
.filter(c => c.name == cluster)
|
||||||
.map(function(cluster) {
|
.filter(c => c.metricConfig.find(m => m.name == metric) != null)
|
||||||
let scNames = cluster.subClusters.map(sc => sc.name)
|
.map(function(c) {
|
||||||
|
let scNames = c.subClusters.map(sc => sc.name)
|
||||||
scNames.forEach(function(scName){
|
scNames.forEach(function(scName){
|
||||||
let met = cluster.metricConfig.find(m => m.name == metric)
|
let met = c.metricConfig.find(m => m.name == metric)
|
||||||
let msc = met.subClusters.find(msc => msc.name == scName)
|
let msc = met.subClusters.find(msc => msc.name == scName)
|
||||||
if (msc != null) {
|
if (msc != null) {
|
||||||
if (msc.remove == true) {
|
if (msc.remove == true) {
|
||||||
|
Loading…
Reference in New Issue
Block a user