diff --git a/ui/packages/consul-ui/app/components/consul/tomography/graph/index.hbs b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.hbs
index f4332892b9..15ceb90173 100644
--- a/ui/packages/consul-ui/app/components/consul/tomography/graph/index.hbs
+++ b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.hbs
@@ -1,35 +1,46 @@
-
+
+
+
diff --git a/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js
index 095a1bc349..26d3764c28 100644
--- a/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js
+++ b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.js
@@ -1,5 +1,5 @@
-import Component from '@ember/component';
-import { computed, set, get } from '@ember/object';
+import Component from '@glimmer/component';
+import { tracked } from '@glimmer/tracking';
const size = 336;
const insetSize = size / 2 - 8;
@@ -9,52 +9,39 @@ const inset = function(num) {
const milliseconds = function(num, max) {
return max > 0 ? parseInt(max * num) / 100 : 0;
};
-export default Component.extend({
- size: size,
- tomography: 0,
- max: -999999999,
- init: function() {
- this._super(...arguments);
- this.circle = [inset(1), inset(0.25), inset(0.5), inset(0.75), inset(1)];
- this.labels = [inset(-0.25), inset(-0.5), inset(-0.75), inset(-1)];
- },
- milliseconds: computed('distances', 'max', function() {
- const max = get(this, 'max');
- return [
- milliseconds(25, max),
- milliseconds(50, max),
- milliseconds(75, max),
- milliseconds(100, max),
- ];
- }),
- distances: computed('tomography', function() {
- const tomography = get(this, 'tomography');
- let distances = get(tomography, 'distances') || [];
- // TODO: This should probably be moved into the milliseconds computedProperty
- /*eslint ember/no-side-effects: "warn"*/
- distances.forEach((d, i) => {
- if (d.distance > get(this, 'max')) {
- set(this, 'max', d.distance);
- }
- });
- let n = get(distances, 'length');
- if (n > 360) {
+export default class TomographyGraph extends Component {
+ @tracked max = -999999999;
+ size = size;
+
+ circle = [inset(1), inset(0.25), inset(0.5), inset(0.75), inset(1)];
+ labels = [inset(-0.25), inset(-0.5), inset(-0.75), inset(-1)];
+
+ get milliseconds() {
+ const distances = this.args.distances || [];
+ const max = distances.reduce((prev, d) => Math.max(prev, d.distance), this.max);
+ return [25, 50, 75, 100].map(item => milliseconds(item, max));
+ }
+
+ get distances() {
+ const distances = this.args.distances || [];
+ const max = distances.reduce((prev, d) => Math.max(prev, d.distance), this.max);
+ const len = distances.length;
+ if (len > 360) {
// We have more nodes than we want to show, take a random sampling to keep
// the number around 360.
- const sampling = 360 / n;
+ const sampling = 360 / len;
distances = distances.filter(function(_, i) {
- return i == 0 || i == n - 1 || Math.random() < sampling;
+ return i == 0 || i == len - 1 || Math.random() < sampling;
});
- n = get(distances, 'length');
}
return distances.map((d, i) => {
return {
- rotate: (i * 360) / n,
- y2: -insetSize * (d.distance / get(this, 'max')),
+ rotate: (i * 360) / distances.length,
+ y2: -insetSize * (d.distance / max),
node: d.node,
distance: d.distance,
segment: d.segment,
};
});
- }),
-});
+ }
+}
diff --git a/ui/packages/consul-ui/app/components/consul/tomography/graph/index.scss b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.scss
new file mode 100644
index 0000000000..45f343d816
--- /dev/null
+++ b/ui/packages/consul-ui/app/components/consul/tomography/graph/index.scss
@@ -0,0 +1,33 @@
+.tomography-graph {
+ .background {
+ fill: $gray-050;
+ }
+ .axis {
+ fill: none;
+ stroke: $gray-300;
+ stroke-dasharray: 4 4;
+ }
+ .border {
+ fill: none;
+ stroke: $gray-300;
+ }
+ .point {
+ stroke: $gray-400;
+ fill: $magenta-600;
+ }
+ .lines line {
+ stroke: $magenta-600;
+ }
+ .lines line:hover {
+ stroke: $gray-300;
+ stroke-width: 2px;
+ }
+ .tick line {
+ stroke: $gray-300;
+ }
+ .tick text {
+ font-size: $typo-size-600;
+ text-anchor: start;
+ color: $gray-900;
+ }
+}
diff --git a/ui/packages/consul-ui/app/services/repository/coordinate.js b/ui/packages/consul-ui/app/services/repository/coordinate.js
index 92b4ea9c3b..5978893f08 100644
--- a/ui/packages/consul-ui/app/services/repository/coordinate.js
+++ b/ui/packages/consul-ui/app/services/repository/coordinate.js
@@ -30,7 +30,7 @@ export default class CoordinateService extends RepositoryService {
if (get(coordinates, 'length') > 1) {
results = tomography(
node,
- coordinates.map(item => get(item, 'data'))
+ coordinates
);
}
results.meta = get(coordinates, 'meta');
diff --git a/ui/packages/consul-ui/app/styles/components.scss b/ui/packages/consul-ui/app/styles/components.scss
index b25af87ff6..c0ec50a3c4 100644
--- a/ui/packages/consul-ui/app/styles/components.scss
+++ b/ui/packages/consul-ui/app/styles/components.scss
@@ -22,7 +22,6 @@
@import './components/healthcheck-output';
@import './components/freetext-filter';
@import './components/filter-bar';
-@import './components/tomography-graph';
@import './components/flash-message';
@import './components/code-editor';
@import './components/confirmation-dialog';
@@ -55,6 +54,7 @@
@import 'consul-ui/components/notice';
@import 'consul-ui/components/modal-dialog';
+@import 'consul-ui/components/consul/tomography/graph';
@import 'consul-ui/components/consul/discovery-chain';
@import 'consul-ui/components/consul/upstream-instance/list';
@import 'consul-ui/components/consul/exposed-path/list';
diff --git a/ui/packages/consul-ui/app/styles/components/tomography-graph.scss b/ui/packages/consul-ui/app/styles/components/tomography-graph.scss
deleted file mode 100644
index b61f62776c..0000000000
--- a/ui/packages/consul-ui/app/styles/components/tomography-graph.scss
+++ /dev/null
@@ -1,31 +0,0 @@
-.tomography .background {
- fill: $gray-050;
-}
-.tomography .axis {
- fill: none;
- stroke: $gray-300;
- stroke-dasharray: 4 4;
-}
-.tomography .border {
- fill: none;
- stroke: $gray-300;
-}
-.tomography .point {
- stroke: $gray-400;
- fill: $magenta-600;
-}
-.tomography .lines line {
- stroke: $magenta-600;
-}
-.tomography .lines line:hover {
- stroke: $gray-300;
- stroke-width: 2px;
-}
-.tomography .tick line {
- stroke: $gray-300;
-}
-.tomography .tick text {
- font-size: $typo-size-600;
- text-anchor: start;
- color: $gray-900;
-}
diff --git a/ui/packages/consul-ui/app/templates/dc/nodes/show/rtt.hbs b/ui/packages/consul-ui/app/templates/dc/nodes/show/rtt.hbs
index f6715fbd72..2767303d9c 100644
--- a/ui/packages/consul-ui/app/templates/dc/nodes/show/rtt.hbs
+++ b/ui/packages/consul-ui/app/templates/dc/nodes/show/rtt.hbs
@@ -22,7 +22,7 @@
-
+