From cafbfec3766cb6d598e296d8861220ce0f134cc8 Mon Sep 17 00:00:00 2001 From: Kenia <19161242+kaxcode@users.noreply.github.com> Date: Wed, 18 Nov 2020 14:02:13 -0500 Subject: [PATCH] ui: Fix empty state conditional for Series Graph (#9221) --- .../app/components/topology-metrics/series/index.hbs | 10 ++++++---- .../app/components/topology-metrics/series/index.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/packages/consul-ui/app/components/topology-metrics/series/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/series/index.hbs index 2d32390724..fda4fdeef3 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/series/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/series/index.hbs @@ -8,20 +8,22 @@ {{on-window 'resize' (action 'redraw')}} -{{#if data.labels}} -Key +{{#if (not empty)}} + {{#if data.labels}} + Key + {{/if}} {{/if}}
Timestamp
- {{#unless data}} + {{#if empty}} - {{/unless}} + {{/if}}
diff --git a/ui/packages/consul-ui/app/components/topology-metrics/series/index.js b/ui/packages/consul-ui/app/components/topology-metrics/series/index.js index 42b2673ee3..238e0d6657 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/series/index.js +++ b/ui/packages/consul-ui/app/components/topology-metrics/series/index.js @@ -7,6 +7,7 @@ import { scaleLinear, scaleTime, scaleOrdinal } from 'd3-scale'; import { schemeTableau10 } from 'd3-scale-chromatic'; import { area, stack, stackOrderReverse } from 'd3-shape'; import { max, extent, bisector } from 'd3-array'; +import { set } from '@ember/object'; dayjs.extend(Calendar); @@ -21,7 +22,7 @@ function niceTimeWithSeconds(d) { export default Component.extend({ data: null, - + empty: false, actions: { redraw: function(evt) { this.drawGraphs(); @@ -35,6 +36,7 @@ export default Component.extend({ drawGraphs: function() { if (!this.data) { + set(this, 'empty', true); return; } @@ -59,10 +61,10 @@ export default Component.extend({ if (series.length == 0 || keys.length == 0) { // Put the graph in an error state that might get fixed if metrics show up // on next poll. - let loader = this.element.querySelector('.sparkline-loader'); - loader.innerHTML = 'No Metrics Available'; - loader.style.display = 'block'; + set(this, 'empty', true); return; + } else { + set(this, 'empty', false); } let st = stack()