From 7f4673ae4be7ddca1fd698c699d92a1f668edbdc Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Wed, 16 Sep 2015 12:53:33 +0200 Subject: [PATCH] Show message in UI when topology too big to render --- client/app/scripts/charts/nodes-chart.js | 58 ++++++++++++------------ client/app/scripts/components/nodes.js | 26 +++++------ client/app/styles/main.less | 25 +++++++++- 3 files changed, 65 insertions(+), 44 deletions(-) diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index 9db84f0cb..b6101992d 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -48,7 +48,7 @@ const NodesChart = React.createClass({ .scaleExtent([0.1, 2]) .on('zoom', this.zoomed); - d3.select('.nodes-chart') + d3.select('.canvas') .on('click', this.handleBackgroundClick) .call(this.zoom); }, @@ -81,7 +81,7 @@ const NodesChart = React.createClass({ componentWillUnmount: function() { // undoing .call(zoom) - d3.select('.nodes-chart') + d3.select('.canvas') .on('click', null) .on('mousedown.zoom', null) .on('onwheel', null) @@ -161,35 +161,34 @@ const NodesChart = React.createClass({ translate = shiftTranslate; wasShifted = true; } - - if (this.state.maxNodesExceeded) { - return ( -
- -
- ); - } + const errorClassNames = this.state.maxNodesExceeded ? 'nodes-chart-error' : 'nodes-chart-error hide'; return ( - - - {function(interpolated) { - let interpolatedTranslate = wasShifted ? interpolated.val : panTranslate; - const transform = 'translate(' + interpolatedTranslate + ')' + - ' scale(' + scale + ')'; - return ( - - - {edgeElements} +
+
+ +
Too many nodes to show in the browser.
Please select a different topology.
+
+ + + {function(interpolated) { + let interpolatedTranslate = wasShifted ? interpolated.val : panTranslate; + const transform = 'translate(' + interpolatedTranslate + ')' + + ' scale(' + scale + ')'; + return ( + + + {edgeElements} + + + {nodeElements} + - - {nodeElements} - - - ); - }} - - + ); + }} + + +
); }, @@ -413,7 +412,8 @@ const NodesChart = React.createClass({ nodes: nodes, edges: edges, nodeScale: nodeScale, - scale: zoomScale + scale: zoomScale, + maxNodesExceeded: false }; }, diff --git a/client/app/scripts/components/nodes.js b/client/app/scripts/components/nodes.js index c2e088c19..c6737d4e5 100644 --- a/client/app/scripts/components/nodes.js +++ b/client/app/scripts/components/nodes.js @@ -29,20 +29,18 @@ const Nodes = React.createClass({ render: function() { return ( -
- -
+ ); }, diff --git a/client/app/styles/main.less b/client/app/styles/main.less index f7d843f60..2970640cb 100644 --- a/client/app/styles/main.less +++ b/client/app/styles/main.less @@ -35,6 +35,14 @@ text-overflow: ellipsis; } +.hideable { + transition: opacity .5s ease-in-out; +} + +.hide { + opacity: 0; +} + * { box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); @@ -174,7 +182,22 @@ h2 { } } -#nodes { +.nodes-chart { + + &-error { + .hideable; + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + text-align: center; + color: @text-secondary-color; + + &-icon { + opacity: 0.25; + font-size: 320px; + } + } svg { position: absolute;