From a7672cc5bad8a8b2daa265bb9c26beba3ffc872e Mon Sep 17 00:00:00 2001 From: kenia Date: Tue, 13 Apr 2021 12:17:53 -0400 Subject: [PATCH] Create placeholder *(All Services) Card --- .../topology-metrics/card/index.hbs | 10 ++++++- .../topology-metrics/card/index.scss | 3 ++ .../app/components/topology-metrics/index.hbs | 10 ++++--- .../app/components/topology-metrics/index.js | 30 +++++++++++++++++-- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs index c65439e06..ce64ce59b 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs @@ -1,3 +1,10 @@ +{{#if (eq @item.Name '*(All Services)')}} + +

+ {{@item.Name}} +

+
+{{else}} {{yield}} - \ No newline at end of file + +{{/if}} \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/topology-metrics/card/index.scss b/ui/packages/consul-ui/app/components/topology-metrics/card/index.scss index 8e61da3c3..3567c5db7 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/card/index.scss +++ b/ui/packages/consul-ui/app/components/topology-metrics/card/index.scss @@ -16,6 +16,9 @@ font-weight: $typo-weight-semibold; margin-bottom: 0 !important; } + p.empty { + padding: 12px !important; + } div { display: inline-flex; dl { diff --git a/ui/packages/consul-ui/app/components/topology-metrics/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/index.hbs index 43bbeac1e..72d78f584 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/index.hbs @@ -81,15 +81,17 @@ @oncreate={{action @oncreate}} /> -{{#if (gt @topology.Upstreams.length 0)}} +{{#if (gt this.upstreams.length 0)}}
- {{#each-in (group-by "Datacenter" @topology.Upstreams) as |dc upstreams|}} + {{#each-in (group-by "Datacenter" this.upstreams) as |dc upstreams|}}
+ {{#if dc}}

{{dc}}

+ {{/if}} {{#each upstreams as |item|}}
diff --git a/ui/packages/consul-ui/app/components/topology-metrics/index.js b/ui/packages/consul-ui/app/components/topology-metrics/index.js index 31e6eae93..cffbfd63a 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/index.js +++ b/ui/packages/consul-ui/app/components/topology-metrics/index.js @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; +import { action, get } from '@ember/object'; export default class TopologyMetrics extends Component { // =attributes @@ -66,6 +66,24 @@ export default class TopologyMetrics extends Component { }); } + get upstreams() { + const upstreams = get(this.args.topology, 'Upstreams') || []; + const items = [...upstreams]; + const defaultAllow = get(this.args.topology, 'DefaultAllow'); + const wildcardIntention = get(this.args.topology, 'WildcardIntention'); + if (defaultAllow || wildcardIntention) { + items.push({ + Name: '*(All Services)', + Datacenter: '', + Namespace: '', + Intention: { + Allowed: true, + }, + }); + } + return items; + } + // =actions @action setHeight(el, item) { @@ -89,7 +107,15 @@ export default class TopologyMetrics extends Component { // Calculate viewBox dimensions this.downView = document.getElementById('downstream-lines').getBoundingClientRect(); - this.upView = document.getElementById('upstream-lines').getBoundingClientRect(); + const upstreamLines = document.getElementById('upstream-lines').getBoundingClientRect(); + const upstreamColumn = document.getElementById('upstream-column').getBoundingClientRect(); + + this.upView = { + x: upstreamLines.x, + y: upstreamLines.y, + width: upstreamLines.width, + height: upstreamColumn.height, + }; // Get Card elements positions const downCards = [