mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-11-04 01:25:06 +01:00 
			
		
		
		
	feat: add subCluster level frontend keys for metric selections
- applies to jobView and nodeList
This commit is contained in:
		@@ -128,15 +128,24 @@
 | 
			
		||||
    if (!job) return;
 | 
			
		||||
 | 
			
		||||
    const pendingMetrics = [
 | 
			
		||||
      ...(ccconfig[`job_view_selectedMetrics:${job.cluster}`] ||
 | 
			
		||||
      $initq.data.globalMetrics.reduce((names, gm) => {
 | 
			
		||||
      ...(
 | 
			
		||||
        (
 | 
			
		||||
          ccconfig[`job_view_selectedMetrics:${job.cluster}:${job.subCluster}`] ||
 | 
			
		||||
          ccconfig[`job_view_selectedMetrics:${job.cluster}`]
 | 
			
		||||
        ) ||
 | 
			
		||||
        $initq.data.globalMetrics
 | 
			
		||||
          .reduce((names, gm) => {
 | 
			
		||||
            if (gm.availability.find((av) => av.cluster === job.cluster && av.subClusters.includes(job.subCluster))) {
 | 
			
		||||
              names.push(gm.name);
 | 
			
		||||
            }
 | 
			
		||||
            return names;
 | 
			
		||||
          }, [])
 | 
			
		||||
      ),
 | 
			
		||||
      ...(ccconfig[`job_view_nodestats_selectedMetrics:${job.cluster}`] ||
 | 
			
		||||
      ...(
 | 
			
		||||
        (
 | 
			
		||||
          ccconfig[`job_view_nodestats_selectedMetrics:${job.cluster}:${job.subCluster}`] ||
 | 
			
		||||
          ccconfig[`job_view_nodestats_selectedMetrics:${job.cluster}`]
 | 
			
		||||
        ) ||
 | 
			
		||||
        ccconfig[`job_view_nodestats_selectedMetrics`]
 | 
			
		||||
      ),
 | 
			
		||||
    ];
 | 
			
		||||
 
 | 
			
		||||
@@ -137,5 +137,5 @@
 | 
			
		||||
  bind:metrics
 | 
			
		||||
  bind:isOpen={isMetricsSelectionOpen}
 | 
			
		||||
  bind:showFootprint
 | 
			
		||||
  footprintSelect={true}
 | 
			
		||||
  footprintSelect
 | 
			
		||||
/>
 | 
			
		||||
 
 | 
			
		||||
@@ -29,8 +29,8 @@
 | 
			
		||||
  import Refresher from "./generic/helper/Refresher.svelte";
 | 
			
		||||
 | 
			
		||||
  export let displayType;
 | 
			
		||||
  export let cluster;
 | 
			
		||||
  export let subCluster = "";
 | 
			
		||||
  export let cluster = null;
 | 
			
		||||
  export let subCluster = null;
 | 
			
		||||
  export let from = null;
 | 
			
		||||
  export let to = null;
 | 
			
		||||
 | 
			
		||||
@@ -60,7 +60,10 @@
 | 
			
		||||
  let hostnameFilter = "";
 | 
			
		||||
  let pendingHostnameFilter = "";
 | 
			
		||||
  let selectedMetric = ccconfig.system_view_selectedMetric || "";
 | 
			
		||||
  let selectedMetrics = ccconfig[`node_list_selectedMetrics:${cluster}`] || [ccconfig.system_view_selectedMetric];
 | 
			
		||||
  let selectedMetrics = (
 | 
			
		||||
    ccconfig[`node_list_selectedMetrics:${cluster}:${subCluster}`] ||
 | 
			
		||||
    ccconfig[`node_list_selectedMetrics:${cluster}`]
 | 
			
		||||
  ) || [ccconfig.system_view_selectedMetric];
 | 
			
		||||
  let isMetricsSelectionOpen = false;
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
@@ -191,6 +194,7 @@
 | 
			
		||||
 | 
			
		||||
<MetricSelection
 | 
			
		||||
  {cluster}
 | 
			
		||||
  {subCluster}
 | 
			
		||||
  configName="node_list_selectedMetrics"
 | 
			
		||||
  metrics={selectedMetrics}
 | 
			
		||||
  bind:isOpen={isMetricsSelectionOpen}
 | 
			
		||||
 
 | 
			
		||||
@@ -352,7 +352,7 @@
 | 
			
		||||
  bind:metrics
 | 
			
		||||
  bind:isOpen={isMetricsSelectionOpen}
 | 
			
		||||
  bind:showFootprint
 | 
			
		||||
  footprintSelect={true}
 | 
			
		||||
  footprintSelect
 | 
			
		||||
/>
 | 
			
		||||
 | 
			
		||||
<HistogramSelection
 | 
			
		||||
 
 | 
			
		||||
@@ -47,12 +47,12 @@
 | 
			
		||||
 | 
			
		||||
  $: {
 | 
			
		||||
    if (allMetrics != null) {
 | 
			
		||||
      if (cluster == null) {
 | 
			
		||||
      if (!cluster) {
 | 
			
		||||
        for (let metric of globalMetrics) allMetrics.add(metric.name);
 | 
			
		||||
      } else {
 | 
			
		||||
        allMetrics.clear();
 | 
			
		||||
        for (let gm of globalMetrics) {
 | 
			
		||||
          if (subCluster == null) {
 | 
			
		||||
          if (!subCluster) {
 | 
			
		||||
            if (gm.availability.find((av) => av.cluster === cluster)) allMetrics.add(gm.name);
 | 
			
		||||
          } else {
 | 
			
		||||
            if (gm.availability.find((av) => av.cluster === cluster && av.subClusters.includes(subCluster))) allMetrics.add(gm.name);
 | 
			
		||||
@@ -67,7 +67,7 @@
 | 
			
		||||
 | 
			
		||||
  function printAvailability(metric, cluster) {
 | 
			
		||||
    const avail = globalMetrics.find((gm) => gm.name === metric)?.availability
 | 
			
		||||
    if (cluster == null) {
 | 
			
		||||
    if (!cluster) {
 | 
			
		||||
      return avail.map((av) => av.cluster).join(',')
 | 
			
		||||
    } else {
 | 
			
		||||
      return avail.find((av) => av.cluster === cluster).subClusters.join(',')
 | 
			
		||||
@@ -112,10 +112,17 @@
 | 
			
		||||
    metrics = newMetricsOrder.filter((m) => unorderedMetrics.includes(m));
 | 
			
		||||
    isOpen = false;
 | 
			
		||||
 | 
			
		||||
    showFootprint = !!pendingShowFootprint;
 | 
			
		||||
    let configKey;
 | 
			
		||||
    if (cluster && subCluster) {
 | 
			
		||||
      configKey = `${configName}:${cluster}:${subCluster}`;
 | 
			
		||||
    } else if (cluster && !subCluster) {
 | 
			
		||||
      configKey = `${configName}:${cluster}`;
 | 
			
		||||
    } else {
 | 
			
		||||
      configKey = `${configName}`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    updateConfigurationMutation({
 | 
			
		||||
      name: cluster == null ? configName : `${configName}:${cluster}`,
 | 
			
		||||
      name: configKey,
 | 
			
		||||
      value: JSON.stringify(metrics),
 | 
			
		||||
    }).subscribe((res) => {
 | 
			
		||||
      if (res.fetching === false && res.error) {
 | 
			
		||||
@@ -123,9 +130,11 @@
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (footprintSelect) {
 | 
			
		||||
      showFootprint = !!pendingShowFootprint;
 | 
			
		||||
      updateConfigurationMutation({
 | 
			
		||||
        name:
 | 
			
		||||
        cluster == null
 | 
			
		||||
          !cluster
 | 
			
		||||
            ? "plot_list_showFootprint"
 | 
			
		||||
            : `plot_list_showFootprint:${cluster}`,
 | 
			
		||||
        value: JSON.stringify(showFootprint),
 | 
			
		||||
@@ -134,6 +143,7 @@
 | 
			
		||||
          throw res.error;
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    dispatch('update-metrics', metrics);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -37,9 +37,10 @@
 | 
			
		||||
    sorting = {},
 | 
			
		||||
    isMetricSelectionOpen = false,
 | 
			
		||||
    availableMetrics = new Set(),
 | 
			
		||||
    selectedMetrics =
 | 
			
		||||
      getContext("cc-config")[`job_view_nodestats_selectedMetrics:${job.cluster}`] ||
 | 
			
		||||
      getContext("cc-config")["job_view_nodestats_selectedMetrics"];
 | 
			
		||||
    selectedMetrics = (
 | 
			
		||||
      getContext("cc-config")[`job_view_nodestats_selectedMetrics:${job.cluster}:${job.subCluster}`] ||
 | 
			
		||||
      getContext("cc-config")[`job_view_nodestats_selectedMetrics:${job.cluster}`]
 | 
			
		||||
    ) || getContext("cc-config")["job_view_nodestats_selectedMetrics"];
 | 
			
		||||
 | 
			
		||||
  for (let metric of sortedJobMetrics) {
 | 
			
		||||
    // Not Exclusive or Multi-Node: get maxScope directly (mostly: node)
 | 
			
		||||
 
 | 
			
		||||
@@ -217,6 +217,7 @@
 | 
			
		||||
          <tr>
 | 
			
		||||
            <td colspan={selectedMetrics.length + 1}>
 | 
			
		||||
              <div style="text-align:center;">
 | 
			
		||||
                {#if !usePaging}
 | 
			
		||||
                  <p><b>
 | 
			
		||||
                    Loading nodes {nodes.length + 1} to 
 | 
			
		||||
                    { matchedNodes 
 | 
			
		||||
@@ -224,6 +225,7 @@
 | 
			
		||||
                      : (nodes.length + paging.itemsPerPage)
 | 
			
		||||
                    }
 | 
			
		||||
                  </b></p>
 | 
			
		||||
                {/if}
 | 
			
		||||
                <Spinner secondary />
 | 
			
		||||
              </div>
 | 
			
		||||
            </td>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user