mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-11-04 01:25:06 +01:00 
			
		
		
		
	Add warning card if no data to plot
- series.data array empty, but toplevel data return itself OK
This commit is contained in:
		@@ -181,7 +181,7 @@
 | 
			
		||||
                        >Metric disabled for subcluster '{job.subCluster}'</Card
 | 
			
		||||
                    >
 | 
			
		||||
                {:else}
 | 
			
		||||
                    <Card body color="warning">Missing Data</Card>
 | 
			
		||||
                    <Card body color="warning">Missing Full Dataset</Card>
 | 
			
		||||
                {/if}
 | 
			
		||||
            </td>
 | 
			
		||||
        {/each}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@
 | 
			
		||||
    import uPlot from 'uplot'
 | 
			
		||||
    import { formatNumber } from '../units.js'
 | 
			
		||||
    import { getContext, onMount, onDestroy } from 'svelte'
 | 
			
		||||
    import { Card } from 'sveltestrap'
 | 
			
		||||
 | 
			
		||||
    export let width
 | 
			
		||||
    export let height
 | 
			
		||||
@@ -219,11 +220,15 @@
 | 
			
		||||
        }, resizeSleepTime)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $: onSizeChange(width, height)
 | 
			
		||||
    $: if (series[0].data.length > 0) {
 | 
			
		||||
         onSizeChange(width, height)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    onMount(() => {
 | 
			
		||||
        plotWrapper.style.backgroundColor = backgroundColor()
 | 
			
		||||
        render()
 | 
			
		||||
        if (series[0].data.length > 0) {
 | 
			
		||||
            plotWrapper.style.backgroundColor = backgroundColor()
 | 
			
		||||
            render()
 | 
			
		||||
        }
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    onDestroy(() => {
 | 
			
		||||
@@ -312,9 +317,11 @@
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<!--Add empty series warning card-->
 | 
			
		||||
<div bind:this={plotWrapper} class="cc-plot"></div>
 | 
			
		||||
 | 
			
		||||
{#if series[0].data.length > 0}
 | 
			
		||||
    <div bind:this={plotWrapper} class="cc-plot"></div>
 | 
			
		||||
{:else}
 | 
			
		||||
    <Card style="margin-left: 2rem;margin-right: 2rem;" body color="warning">Cannot render plot: No series data found for <code>{metric}</code></Card>
 | 
			
		||||
{/if}
 | 
			
		||||
<style>
 | 
			
		||||
    .cc-plot {
 | 
			
		||||
        border-radius: 5px;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user