diff --git a/ui/app/components/topo-viz.js b/ui/app/components/topo-viz.js index ee3616102..3e6c7ab04 100644 --- a/ui/app/components/topo-viz.js +++ b/ui/app/components/topo-viz.js @@ -14,9 +14,10 @@ export default class TopoViz extends Component { @tracked activeAllocation = null; @tracked activeEdges = []; @tracked edgeOffset = { x: 0, y: 0 }; + @tracked viewportColumns = 2; get isSingleColumn() { - if (this.topology.datacenters.length <= 1) return true; + if (this.topology.datacenters.length <= 1 || this.viewportColumns === 1) return true; // Compute the coefficient of variance to determine if it would be // better to stack datacenters or place them in columns @@ -32,6 +33,7 @@ export default class TopoViz extends Component { get datacenterIsSingleColumn() { // If there are enough nodes, use two columns of nodes within // a single column layout of datacenters to increase density. + if (this.viewportColumns === 1) return true; return !this.isSingleColumn || (this.isSingleColumn && this.args.nodes.length <= 20); } @@ -124,6 +126,7 @@ export default class TopoViz extends Component { @action captureElement(element) { this.element = element; + this.determineViewportColumns(); } @action @@ -184,6 +187,12 @@ export default class TopoViz extends Component { if (this.args.onNodeSelect) this.args.onNodeSelect(this.activeNode); } + @action + determineViewportColumns() { + console.log(this.element.clientWidth); + this.viewportColumns = this.element.clientWidth < 900 ? 1 : 2; + } + @action computedActiveEdges() { // Wait a render cycle diff --git a/ui/app/styles/components/dashboard-metric.scss b/ui/app/styles/components/dashboard-metric.scss index 8a6fff846..b9b151ba0 100644 --- a/ui/app/styles/components/dashboard-metric.scss +++ b/ui/app/styles/components/dashboard-metric.scss @@ -1,4 +1,7 @@ .dashboard-metric { + width: 350px; + max-width: 350px; + &:not(:last-child) { margin-bottom: 1.5em; } @@ -7,6 +10,11 @@ margin-bottom: 0; } + &.column { + width: auto; + max-width: auto; + } + .metric { text-align: left; font-weight: $weight-bold; diff --git a/ui/app/templates/components/topo-viz.hbs b/ui/app/templates/components/topo-viz.hbs index 63d123417..4d78bd044 100644 --- a/ui/app/templates/components/topo-viz.hbs +++ b/ui/app/templates/components/topo-viz.hbs @@ -1,4 +1,9 @@ -
+
-
+
Legend